Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.When “70% chance” really means 70%
A weather forecaster who says “70% chance of rain” is trustworthy if it actually rains on about 70% of the days they say that. If it only rains on 40% of those days, the forecaster is overconfident, and you’d be wise to mentally turn their numbers down. Calibration is checking and fixing exactly this for a model.
Risk calculations multiply probabilities by consequences. A collision probability that is ten times too low, or a failure probability inflated by an overconfident model, leads to wrong safety decisions even when the model ranks cases perfectly.
- 1. A model says 90% for many cases but only 60% are positive. It is…
- 2. A calibrated model's 30% predictions are positive about…
- 3. Calibration matters most when…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Diagnosing calibration
- Reliability diagram: bin predictions (for example 10 bins), plot mean predicted probability against observed frequency. A calibrated model lies on the diagonal; below it means overconfident in that range.
- ECE: the count-weighted average gap |confidence − frequency| over bins. MCE is the largest gap.
- Brier score = mean (p − y)², decomposed as reliability − resolution + uncertainty. Reliability is the calibration error; resolution is how much predictions vary with the truth.
- Log-loss also rewards calibration.
Typical behaviour
| Model | Usual miscalibration |
|---|---|
| logistic regression | well calibrated (it optimises log-loss) |
| naive Bayes | overconfident (independence assumption) |
| SVM, boosted trees | scores not probabilities; sigmoid-shaped distortion |
| random forest | pulled away from 0 and 1 (averaging) |
| deep networks | often overconfident |
from sklearn.calibration import CalibratedClassifierCV, calibration_curve
cal = CalibratedClassifierCV(model, method="sigmoid", cv=5).fit(X, y) # Platt; method="isotonic" for PAV
frac_pos, mean_pred = calibration_curve(y_test, cal.predict_proba(X_test)[:, 1], n_bins=10)- 1. A reliability curve below the diagonal at high probabilities means…
- 2. Which model is usually well calibrated out of the box?
- 3. ECE averages the gaps weighted by…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.Recalibration methods
All of them are fitted on a held-out calibration set, or by cross-validation, never on the training data.
- Platt scaling: p = σ(a·s + b), fitted by logistic regression on the scores. Two parameters fix any affine distortion of the logit (too sharp, too flat, shifted).
- Temperature scaling: p = σ(s / T), one parameter. It fixes sharpness but not a shift. It is the standard for neural networks, where the multiclass version divides all logits by T.
- Isotonic regression: the best non-decreasing step function, fitted with the pool-adjacent-violators (PAV) algorithm. It fixes any monotone distortion but needs more data and can overfit.
- Histogram binning: replace each bin’s predictions by its observed frequency.
- Prior shift: if training prevalence π differs from deployment prevalence π′, multiply the odds by (π′/π)·(1 − π)/(1 − π′).
- 1. Temperature scaling cannot fix…
- 2. Isotonic regression assumes the calibration map is…
- 3. Calibrators must be fitted on…
Level 3: Advanced
★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.Calibration in practice
- Small calibration sets (hundreds of examples): prefer Platt or temperature scaling. Large sets: isotonic regression or binning can fix any shape.
- Calibration does not change ranking for monotone methods, so ROC-AUC is unchanged. Isotonic regression can create ties.
- Multiclass: temperature scaling, or one-vs-rest Platt or isotonic followed by renormalisation. Use classwise ECE as well as confidence ECE.
- ECE is a noisy, binning-dependent estimate. Report the number of bins, use enough test data, and look at the diagram.
- Recalibrate after distribution shift, and for each deployment site if prevalence differs.
Interview questions.
- Why are boosted trees poorly calibrated? Boosting pushes margins toward ±∞ on training data, and its scores are not optimised as probabilities.
- Can a model have AUC 0.99 and terrible calibration? Yes. Ranking and calibration are separate properties.
- 1. Does Platt scaling change ROC-AUC?
- 2. With 200 calibration examples, prefer…
- 3. A model trained with 50% positives is deployed where 5% are positive. Fix?
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Which calibrator for which problem?
Exercise 1.
- True probabilities give ECE 0.007, which is sampling noise.
- An overconfident map gives ECE 0.089.
- On scores three times too sharp, Platt scaling recovers a = 0.343, close to the true 1/3.
- The Brier score 0.1655 splits into reliability 0.0001 − resolution 0.0836 + uncertainty 0.25.
Exercise 2: four distortions, five calibrators, three calibration-set sizes. Values are test ECE on 10 000 examples, averaged over 15 repetitions. The ECE floor from finite test data is about 0.012.
| Distortion | n | Uncalibrated | Temperature | Platt | Isotonic | 10-bin histogram |
|---|---|---|---|---|---|---|
| overconfident (3 × logit) | 100 | 0.142 | 0.036 | 0.057 | 0.078 | 0.069 |
| 1 000 | 0.139 | 0.013 | 0.016 | 0.025 | 0.021 | |
| underconfident (0.4 × logit) | 1 000 | 0.129 | 0.013 | 0.016 | 0.025 | 0.021 |
| shifted (logit + 2) | 1 000 | 0.342 | 0.251 | 0.016 | 0.025 | 0.021 |
| curved (l + l³/6) | 1 000 | 0.043 | 0.040 | 0.040 | 0.025 | 0.021 |
| 10 000 | 0.043 | 0.041 | 0.042 | 0.016 | 0.014 |
- Parametric calibrators win when their form matches the distortion. Temperature fixes sharpness; Platt also fixes shifts; they need only about 100–1 000 examples.
- Temperature scaling cannot remove a shift. ECE stays at 0.25.
- For a non-sigmoid distortion, Platt and temperature are stuck at 0.040 however much data they get. Isotonic regression and binning keep improving with data.
- Isotonic regression and binning use only the order of the scores. Their results are identical for all four distortions, but with 100 examples their excess log-loss is 11× that of temperature scaling (overfitting).
Calibration in AI, robotics and aerospace
- Probabilistic risk assessment: failure-probability models must be calibrated before being multiplied by consequence costs.
- Perception confidence: detector confidences feed tracking filters and planners; overconfident detections cause brittle behaviour.
- Weather and space-weather forecasting: reliability diagrams are the standard verification tool.
- LLMs and deep classifiers: temperature scaling and selective prediction (abstain when uncertain).
References
- J. Platt (1999). “Probabilistic outputs for support vector machines and comparisons to regularized likelihood methods.” Advances in Large Margin Classifiers.
- B. Zadrozny, C. Elkan (2002). “Transforming classifier scores into accurate multiclass probability estimates.” KDD.
- A. Niculescu-Mizil, R. Caruana (2005). “Predicting good probabilities with supervised learning.” ICML.
- C. Guo, G. Pleiss, Y. Sun, K. Q. Weinberger (2017). “On calibration of modern neural networks.” ICML.
- A. H. Murphy (1973). “A new vector partition of the probability score.” Journal of Applied Meteorology 12(4).