Skip to main content

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.
  • Histogram and calibrate_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.14. 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.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for khalib 0.7
File Size Uploaded Provenance Actions
khalib-0.7.tar.gz 22.6 kB With provenance Details for khalib-0.7.tar.gz

Release files / khalib-0.7.tar.gz

Download URL khalib-0.7.tar.gz
Size 22.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9995e2c23b524c5499b753b71099667f4b8c3dac991e2f2afae930bd5dee4b37
BLAKE2b-256 checksum
How to use checksums
ea2e10ac2c7249b9c469d2c55267e5d731d6fb068d518791c625c99fd9a2eba8
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 6, 2026.

Transparency log

Security for khalib 0.7

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.7.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 6, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page