Skip to main content

XGBOrdinal: An XGBoost Extension for Ordinal Data

Project description

XGBOrdinal

This GitHub repository contains the code used in the paper:

XGBOrdinal: An XGBoost Extension for Ordinal Data
Fabian Kahl, Iris Kahl, Stephan M. Jonas
Presented at MIE 2025
Published in Studies in Health Technology and Informatics, Volume 327, Pages 462–466

Citation

@article{kahl2025xgbordinal,
  title={XGBOrdinal: An XGBoost Extension for Ordinal Data},
  author={Kahl, Fabian and Kahl, Iris and Jonas, Stephan M},
  journal={Studies in health technology and informatics},
  volume={327},
  pages={462--466},
  year={2025}
}

Requirements

To install the required packages, run the following command:

git clone https://github.com/digital-medicine/XGBOrdinal.git
cd XGBOrdinal
pip install -r requirements.txt

Demos

  • ./demo.ipynb to run XGBOrdinal with and without GridSearchCV in Jupyter Notebook.
  • ./demo.py to run XGBOrdinal with and without GridSearchCV in Python.

Parameters

XGBOrdinal(aggregation='weighted', norm=True, **extra_params)

  • aggregation: str
    • Description: Defines the method for aggregating model across the classifiers.
    • Purpose: Controls how to combine the classifiers. Supported values:
      • 'weighted': Uses class distribution-based weights.
      • 'equal': Uses equal weights for all classifiers.
    • Default: 'weighted'.
  • norm: bool
    • Description: Whether to replace all negative outcomes with zero and normalize them so they sum to 1.
    • Purpose: Ensures the outputs are probabilities for each sample.
    • Default: True.
  • **extra_params:
    • Description: Additional parameters passed to the underlying XGBClassifiers.
    • Purpose: Customize the underlying classifiers in terms of hyperparameters.
    • Example: 'learning_rate'=0.1, 'max_depth'=3.

Methods

  • fit(X, y, **fit_params)
    • Description: Trains multiple binary classifiers based on the ordinal thresholds derived from unique_classes.
    • Parameters:
      • X: The feature matrix for training.
      • y: The target vector for training.
      • **fit_params: Additional parameters passed to the underlying XGBClassifiers (e.g., eval_set).
  • predict(X)
    • Description: Predicts the class label for each sample based on the highest predicted probability.
    • Parameters:
      • X: The feature matrix for prediction.
    • Returns: The predicted class labels.
  • predict_proba(X)
    • Description: Predicts the probabilities for each ordinal class.
    • Parameters:
      • X: The feature matrix for prediction.
    • Returns: A 2D array where each row contains the predicted probabilities for each class.
    • Note: If norm=True, the probabilities will sum to 1 for each sample.
  • feature_importance(importance_type='gain')
    • Description: Computes feature importance across all classifiers, aggregated using the specified aggregation strategy.
    • Parameters:
      • importance_type: Type of XGBoost importance to compute (e.g., 'gain', 'weight', 'cover').
    • Returns: A dictionary of feature importance scores.

Folder Structure

  • ./experiments contains the experiments of the paper.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xgbordinal-1.0.1.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xgbordinal-1.0.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file xgbordinal-1.0.1.tar.gz.

File metadata

  • Download URL: xgbordinal-1.0.1.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.17

File hashes

Hashes for xgbordinal-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d8b370b2d42f319da8ff649a154a1cc81a7b38a518315e5dd47aa7d162e0d731
MD5 cbbfe2ca638081d79fb3acbd21d499ec
BLAKE2b-256 0ba4fce1eb25ddc9a5cdd4ce1bb07f0d9d2043558c8f7ce15f6748e750f4071f

See more details on using hashes here.

File details

Details for the file xgbordinal-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: xgbordinal-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.17

File hashes

Hashes for xgbordinal-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3cccd3534937a9059e0e3616e0c2bf1e46a63e666b16b82ec1f7c8d01ba5cbca
MD5 72ede93a00b43fd0509b27b059ddd2cb
BLAKE2b-256 5712af39ee0cca40c5ca04ce66c73271aef2b56a34294096774c7c0a84a05008

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page