khalib
khalib is a binary and multiclass classifier probability calibration package powered by the
Khiops AutoML suite.
Features
KhalibClassifier: A scikit-learn estimator to calibrate classifiers with a similar interface as CalibratedClassifierCV.calibration_error: A function to estimate the Estimated Calibration Error (ECE).build_reliability_diagram: A function to build a reliability diagram.Histogramandcalibrate_binary: Lower-level APIs for histogram construction and binary score calibration.
These features are based on Khiops's non-parametric supervised histograms, so there is no need to specify the number and width of the bins, as they are automatically estimated from data.
Installation
Requires Python 3.11 through 3.15. Khiops is installed automatically; no separate installation is needed.
pip install khalib
Example
Train a classifier, calibrate it on held-out data, and evaluate on a separate test set:
from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from khalib import KhalibClassifier, calibration_error
X, y = load_breast_cancer(return_X_y=True)
X_train, X_heldout, y_train, y_heldout = train_test_split(
X, y, test_size=0.4, stratify=y, random_state=42
)
X_calib, X_test, y_calib, y_test = train_test_split(
X_heldout, y_heldout, test_size=0.5, stratify=y_heldout, random_state=42
)
estimator = make_pipeline(StandardScaler(), LogisticRegression())
estimator.fit(X_train, y_train)
calibrated = KhalibClassifier(estimator=estimator).fit(X_calib, y_calib)
raw_probabilities = estimator.predict_proba(X_test)
probabilities = calibrated.predict_proba(X_test)
print("Raw ECE: ", calibration_error(raw_probabilities, y_test))
print("Calibrated ECE:", calibration_error(probabilities, y_test))
Binary probability column 1 corresponds to calibrated.classes_[1].
Documentation
See the documentation for tutorials and API details, and the changelog for release notes.
Metadata
Release files for khalib 0.8
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 |
|---|---|---|---|---|
| khalib-0.8.tar.gz | 23.9 kB | With provenance | Details for khalib-0.8.tar.gz |
Release files / khalib-0.8.tar.gz
| Download URL | khalib-0.8.tar.gz |
|---|---|
| Size | 23.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b11f2fa3b59bbe563e4c9e03609eada42afa4c0a14ecadaa5572dc16783ebf4b
|
|
BLAKE2b-256 checksum How to use checksums |
5020c7c88c2738b37561301db53c1e743f315e9bd23e0030f45b2eaae2c4a987
|
| 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 Nov 18, 2026.
Transparency logSecurity for khalib 0.8
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
1 file in this release has been uploaded with provenance metadata.
Attestation for khalib-0.8.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 Nov 18, 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.