OrdBoost
Table of content
Overview
ordboost is a Python library providing ordinal-binning gradient boosting models for discrete and continuous targets with full scikit-learn compatibility.
By framing continuous regression as a dynamic ordinal binning problem, ordboost generates full, non-parametric probabilistic distributions without forcing strict Gaussian or parametric assumptions on target data.
Key Features
- Scikit-Learn API Compatibility: Fits seamlessly into standard ML workflows using
fit,predict, andpredict_dist. - Non-Parametric Probabilistic Output: Obtains complete predictive distribution objects capable of extracting probability mass functions (PMF), cumulative distribution functions (CDF), percentiles (
ppf), and dynamic prediction intervals. - Flexible Continuous Target Mapping: Maps continuous values to discrete target spaces using configurable binning strategies (
QuantileBinMapper,UniformBinMapper,EmpiricalMeanBinMapper,EmpiricalMedianBinMapper,ContinuousBinMapper). - Monotonic Ordinal Constraints: Supports constrained ordinal boosting (e.g., isotonic constraints) across sequential boundaries.
- Probabilistic Evaluation: Evaluates probabilistic predictions directly using CRPS (
crps_score), quantile loss (pinball_loss), and their skill scores. - Prediction Intervals Measures: Measures the prediction interval coverage (
interval_coverage_rate), sharpness (sharpness), and Winkler score (winkler_score). - Calibration Diagnostics: Computes marginal calibration (
marginal_calibration_curve) and probabilistic calibration (pit_diagnostics).
Installation
Install the latest release from PyPI:
pip install ordboost
Note: It is recommended to install the package inside a virtual environment (venv or conda).
Some of the plotting examples (calibration and bounded-data) additionally need
matplotlib. Install it with pip install matplotlib, or install the development
extras with pip install -e ".[dev]" from a clone of the repository.
Quickstart Examples
OrdBoostClassifier
import numpy as np
from ordboost import OrdBoostClassifier, crps_score, pinball_loss
# 1. Prepare ordinal target dataset (e.g., discrete ratings 1 to 5)
np.random.seed(42)
X_train = np.random.randn(200, 4)
y_train = np.random.choice([1, 2, 3, 4, 5], size=200)
X_test = np.random.randn(50, 4)
y_test = np.random.choice([1, 2, 3, 4, 5], size=50)
# 2. Fit OrdBoostClassifier
model = OrdBoostClassifier(
max_iter=50,
learning_rate=0.05,
monotonicity="isotonic",
max_leaf_nodes=15,
random_state=42,
)
model.fit(X_train, y_train)
# 3. Predict point estimates (mean or median)
y_pred_mean = model.predict(X_test, method="mean")
# 4. Extract discrete probability distribution
dist = model.predict_dist(X_test)
pmf = dist.pmf # Probability mass function shape: (50, 5)
cdf = dist.cdf # Cumulative distribution function shape: (50, 5)
y_pred_q90 = dist.ppf(0.90) # 90th percentile prediction
# 5. Evaluate probabilistic performance
crps = crps_score(y_test, dist)
p_loss = pinball_loss(y_test, y_pred_q90, alpha=0.9)
print(f"Discrete CRPS: {crps:.4f}")
print(f"Pinball Loss (q=0.9): {p_loss:.4f}")
OrdBoostRegressor
import numpy as np
from ordboost.models import OrdBoostRegressor
# 1. Generate synthetic continuous regression data with non-linear skew
rng = np.random.default_rng(42)
X_train = rng.standard_normal((300, 3))
y_train = np.exp(X_train[:, 0] * 0.6) + rng.normal(0.0, 0.5, size=300)
X_test = rng.standard_normal((3, 3))
# 2. Instantiate and fit OrdBoostRegressor using dependency injection
reg = OrdBoostRegressor(
bin_edges=[0.0, 1.0, 2.5, 5.0, 15.0],
mapper="quantile",
mapper_kwargs={"quantiles": (0.10, 0.25, 0.50, 0.75, 0.90)},
learning_rate=0.05,
max_iter=50,
random_state=42,
)
reg.fit(X_train, y_train)
# 3. Generate continuous point predictions
y_pred_mean = reg.predict(X_test, method="mean")
y_pred_median = reg.predict(X_test, method="median")
# 4. Extract continuous predictive distribution object
dist = reg.predict_dist(X_test)
# Evaluate 80% prediction intervals and cumulative probability P(Y <= 3.0)
lower_80, upper_80 = dist.interval(alpha=0.20)
prob_under_3 = dist.cdf(3.0)
# Display predictions for test samples
for i in range(len(X_test)):
print(f"Sample {i + 1}:")
print(f" Predicted Mean: {y_pred_mean[i]:.2f}")
print(f" Predicted Median: {y_pred_median[i]:.2f}")
print(f" 80% Interval: [{lower_80[i]:.2f}, {upper_80[i]:.2f}]")
print(f" P(Y <= 3.0): {prob_under_3[i]:.2%}\n")
Acknowledgements
This package was developed using Gemini 3.6 Thinking and Claude Sonnet 5. The code was reviewed and edited by humans.
Metadata
Release files for ordboost 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ordboost-0.6.0.tar.gz | 48.4 kB | With provenance | Details for ordboost-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ordboost-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for ordboost-0.6.0-py3-none-any.whl |
Total release size: 84.7 kB
Release files / ordboost-0.6.0.tar.gz
| Download URL | ordboost-0.6.0.tar.gz |
|---|---|
| Size | 48.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a6acfca087bf0dcce6fa4e9c9941a567c082c98884659b6c40f87cdd00ff81d
|
|
BLAKE2b-256 checksum How to use checksums |
9a505203145f75fe7d3271c2ab351fbc99749980455b4c9bdb300d6a59d3a30f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / ordboost-0.6.0-py3-none-any.whl
| Download URL | ordboost-0.6.0-py3-none-any.whl |
|---|---|
| Size | 36.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9f8009a6f7d3addb8b8986cf01220fa1baa00f8097c423aacf7f24ca8a57892
|
|
BLAKE2b-256 checksum How to use checksums |
0dc82b1acf7f2e0db5204c13d3315953c73fe25baf4c8361bfce2beb581dfedd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for ordboost 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ordboost-0.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.