Platt and isotonic calibration
Quick answer
Platt-style sigmoid calibration learns a logistic mapping from model scores to probabilities. Isotonic calibration learns a nondecreasing mapping that is more flexible but may overfit small calibration samples. Static examples tested locally with Python 3.13.5, scikit-learn 1.8.0 SciPy 1.17.0 and NumPy 2.3.5 where imported. ByteMind package execution is unverified.
Pool adjacent violations
from sklearn.isotonic import IsotonicRegressionm=IsotonicRegression(out_of_bounds="clip").fit([0,1,2,3],[0,1,0,1])print(m.predict([-1,0,1,2,3,4]).tolist())Observed local output:
[0.0, 0.0, 0.5, 0.5, 1.0, 1.0]The middle observations share a fitted value; clipping outside the observed interval is explicit.
How it works
For a raw score s, a sigmoid mapping can be written p=1/(1+exp(-(a*s+b))). Fit a and b on independent calibration scores and labels, not the data used to train the score model. Classical Platt scaling uses a particular target-smoothing procedure; the logistic mapping illustrated here is a simplified demonstration. Isotonic regression minimizes squared error under a monotonicity constraint, pooling adjacent violations; interpolation and out-of-range behavior depend on implementation. In scikit-learn, CalibratedClassifierCV supports sigmoid and isotonic methods; when calibrating an already fitted estimator with FrozenEstimator, the user must ensure disjoint fitting and calibration data. Isotonic may create score ties and affect ranking; a strictly increasing sigmoid preserves ranking. For rare events, a calibration set with few positives may make both methods uncertain. Compare on a separate validation set using Brier, log loss and reliability counts, then lock the method before testing.
Fit an independent sigmoid calibrator
from sklearn.linear_model import LogisticRegressionfrom sklearn.calibration import CalibratedClassifierCVfrom sklearn.frozen import FrozenEstimatorbase=LogisticRegression().fit([[-3],[-2],[2],[3]],[0,0,1,1])cal=CalibratedClassifierCV(FrozenEstimator(base),method="sigmoid",cv=2).fit([[-1],[-.5],[.5],[1]],[0,0,1,1])p=cal.predict_proba([[-2.5],[0],[2.5]])[:,1]print(bool(0<p[0]<p[1]<p[2]<1),round(float(p[1]),2))Observed local output:
True 0.5Calibration rows are independent from model-fit rows in this toy fixture; cv=2 fits the small calibration sample with two folds and the frozen model is not retrained. Symmetric data center the sigmoid.
Common mistakes
Never fit a calibrator on in-sample predictions or the final test labels. Do not claim isotonic extrapolation works outside observed scores. Do not select calibration based only on training Brier.
Practice and next steps
For ordered scores with outcomes [0,1,0,1], pool the middle violation and explain why the result contains ties. Complete the knowledge check and staged exercise. Next: Cost threshold and abstention.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Platt and isotonic calibration — knowledge check
Apply platt and isotonic calibration to new scenarios.
Calibration data should be?
Isotonic mapping is?
Which is more flexible?
What can isotonic ties change?
FrozenEstimator ensures data disjointness automatically?