calibration_proba
Calibrate predicted probabilities for binary and multiclass classifiers with
ProbCalib.
- Binary (
task="binary")isotonic_linear(default)isotonicsigmoidtemperature_scaling
- Multiclass (
task="multiclass")temperature_scaling(default)sigmoidisotonic_linear
How the calibration methods work
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 |
|---|---|
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.1
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 |
|---|---|---|---|---|
| calibration_proba-0.1.1.tar.gz | 56.6 kB | Without provenance | Details for calibration_proba-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| calibration_proba-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for calibration_proba-0.1.1-py3-none-any.whl |
Total release size: 103.9 kB
Release files / calibration_proba-0.1.1.tar.gz
| Download URL | calibration_proba-0.1.1.tar.gz |
|---|---|
| Size | 56.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
853b66233864e4e30f97c19bf16bc9365745b4bcc61da2bfa4fef860325e3067
|
|
BLAKE2b-256 checksum How to use checksums |
481f9633cbd27071a83bb1ab398b28daba3cff669c73a5fe1e66bde613cd0c34
|
| 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.1-py3-none-any.whl
| Download URL | calibration_proba-0.1.1-py3-none-any.whl |
|---|---|
| Size | 47.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c04bf624fb468a90cafed93e8abba7a8744464a0549efbe1fffd155ccacc26e
|
|
BLAKE2b-256 checksum How to use checksums |
3507e53be067c44d4dd7b155b5fe4cd4a1be28f2feccfadf718e336222b23c40
|
| 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.1
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.