Skip to main content

Gradient Boosting Ordinal Regression

Project description

Gradient Boosting for Ordinal Regression (GBOR)

gbor is a scikit-learn-compatible, Python package designed for gradient boosting tailored to ordinal regression problems. It does so by alternating between fitting a base learner - GradientBoostingRegressor, by default - to predict a latent score that specifies the mean of a cumulative density function for the observed discrete outcomes, and fitting a set of thresholds that convert the latent score to the discrete outcome. It can be viewed as coordinate-descent optimization that combines functional gradient descent (the boosting stage) with ordinary gradient descent (for adjusting thresholds).

The main class in the package, GradientBoostingOrdinal, supports custom link functions, sample weighting, early stopping criteria, and staged predictions. In addition to methods for predicting class labels and probabilities, similar to nominal classifiers, the decision_function method of the class predicts the latent score, which can be used to achieve superior performance in discreiminative/ranking tasks.

Features

  • Fully compatible with scikit-learn pipelines.
  • Customizable link functions: Probit, Logit, and Complementary Log-Log.
  • Supports sample weighting for robust handling of imbalanced datasets.
  • Subsampling for stochastic gradient boosting.
  • Early stopping based on validation loss.
  • Utilities for data loading and evaluation metrics.

Installation

Clone the repository and install the package:

git clone https://github.com/yourusername/gbor.git
cd gbor
pip install .

Quick Start

Load the Wine Quality Dataset

The package includes a utility to load the wine quality dataset from the UCI repository.

from gbor.data import load_wine_quality

# Load data
red_wine, white_wine = load_wine_quality()
X = red_wine.drop(columns="quality")
y = red_wine["quality"]

Train a Gradient Boosting Ordinal Model

from gbor.main import GradientBoostingOrdinal

# Initialize and fit the model
model = GradientBoostingOrdinal(n_estimators=100, link_function='logit', verbose=1)
model.fit(X, y)

# Predict class labels and probabilities
predicted_labels = model.predict(X)
predicted_probabilities = model.predict_proba(X)

# Evaluate using the concordance index
from gbor.main import concordance_index
c_index = concordance_index(y, model.decision_function(X))
print(f"Concordance Index: {c_index:.3f}")

License

This package is licensed under the MIT License.


For issues or contributions, feel free to create a pull request or open an issue on the GitHub repository.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

ogboost-0.5.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file ogboost-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ogboost-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for ogboost-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 548bba39e58fe6c5679782dc2e1dbb4c97f34e3fa3f1a3a26fb21a50eb7badc9
MD5 5cc6f0017ef1928626a4bb60b2aa2b07
BLAKE2b-256 9ce69d150c853b6bf0c989e181419e49db968deff9315c14b5fefa3a2431a412

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