Skip to main content

calibration_proba

Calibrate predicted probabilities for binary and multiclass classifiers with ProbCalib.

  • Binary (task="binary")
    • isotonic_linear (default)
    • isotonic
    • sigmoid
    • temperature_scaling
  • Multiclass (task="multiclass")
    • temperature_scaling (default)
    • sigmoid
    • isotonic_linear

Installation

pip install calibration-proba

Calibrate probabilities

Fit the calibrator on a separate calibration set, then apply it to the test predictions. This binary example uses the predicted probability of class 1.

from calibration_proba import ProbCalib

p_cal = model.predict_proba(X_cal)[:, 1]
p_test = model.predict_proba(X_test)[:, 1]

calib = ProbCalib(task="binary", method="isotonic_linear", max_bins=10)
calib.fit(p_cal, y_cal)
p_calibrated = calib.predict(p_test)

calib.save_model("calibrator.npz")
calib = ProbCalib.load_model("calibrator.npz")

Plot the mapping and reliability diagram

from calibration_proba import plot_calibration_curve

mapping = calib.plot()
reliability = plot_calibration_curve(y_test, p_calibrated)

mapping.savefig("mapping.png", dpi=180)
reliability.savefig("reliability.png", dpi=180)
Fitted calibration mapping Reliability diagram
Fitted calibration mapping Reliability diagram

Benchmark on Adult with CatBoost

ECE before calibration was 0.0098. The table shows changes on the test set relative to the uncalibrated predictions. Both isotonic methods use max_bins=None. See the full benchmark report.

Method Δ ECE Δ ECE (%) Δ ROC AUC
isotonic_linear -0.0047 -47.75% 0
isotonic -0.0041 -42.04% -0.00035
sigmoid -0.0002 -2.51% 0
temperature_scaling +0.0008 +7.92% 0

Metadata

Release files for calibration-proba 0.1.0

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

Source distribution (sdist)

Source distribution for calibration-proba 0.1.0
File Size Uploaded Provenance Actions
calibration_proba-0.1.0.tar.gz 56.1 kB Without provenance Details for calibration_proba-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for calibration-proba 0.1.0
File Interpreter ABI Platform Actions
calibration_proba-0.1.0-py3-none-any.whl Python 3 none any Details for calibration_proba-0.1.0-py3-none-any.whl

Total release size: 103.2 kB

Release files / calibration_proba-0.1.0.tar.gz

Download URL calibration_proba-0.1.0.tar.gz
Size 56.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ef57dfba57f9d4ccd9e1a3bcf0dae5359f8cc8e9e4c204715ff2ba4482da1265
BLAKE2b-256 checksum
How to use checksums
5d870fa3e077acc4debc9fc9e152c4ecf17c8f1288ba0dfe02ae0b317843fed9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / calibration_proba-0.1.0-py3-none-any.whl

Download URL calibration_proba-0.1.0-py3-none-any.whl
Size 47.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
313f65dbcedb0a5c0b8d4e4fc9ee09d3254e907ba51ffa030cab770832bae5ef
BLAKE2b-256 checksum
How to use checksums
a7c20441c9727232f0a13a42f7237611cd8426fdd88c109ae5e43088d6eefeb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Security for calibration-proba 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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