ML Systems Lab Open interactive version →
Intermediate 45 min read calibrationECEtemperature scalingPlatt scalingreliability diagram

Probabilistic Calibration

Reliability diagrams, ECE, overconfidence in NNs, temperature scaling, Platt scaling, isotonic regression

Your risk team is using a random forest to score loan applications. When the model outputs 0.8, they treat it as an 80% probability of default. They set loss reserves, calculate expected portfolio losses, and make approval decisions based on these numbers. Then you run an audit. Among all loans where the model predicted "80% default probability," only 55% actually defaulted. The model is overconfident by 25 percentage points. Every risk calculation built on those numbers is wrong. This is a calibration failure, and it is costing real money.

Calibration asks a simple question: when a model says 70%, does 70% of the time the positive outcome actually occur? A calibration curve — also called a reliability diagram — makes this visible. Bin all predictions into intervals (0–10%, 10–20%, and so on). For each bin, plot the mean predicted probability against the fraction of actual positives. A perfectly calibrated model produces a diagonal line. An overconfident model produces a curve that sags below the diagonal — predictions of 80% correspond to actual rates of 55%.

Different model families have characteristic calibration behavior. Logistic regression is well-calibrated by design: it optimizes a proper scoring rule that directly rewards accurate probability estimates. Random forests are routinely overconfident — the trees output class proportions in their leaves, and these leaf proportions cluster near 0 and 1 because fully grown trees tend to be pure. The result: probabilities pile up at the extremes and are miscalibrated relative to observed rates. Gradient boosting has the same problem. SVMs produce scores that are not probabilities at all by default and need Platt scaling before any probability interpretation is valid. Neural networks are documented to be systematically overconfident after cross-entropy training (Guo et al., 2017) — the optimizer pushes logits toward infinity with no incentive to stop once labels are correctly ranked, and larger models are worse, not better. Label smoothing during training softens the one-hot targets and dampens this effect somewhat, but does not eliminate it — temperature scaling after training is still the standard fix.

Three methods fix this. Platt scaling fits a logistic regression on top of model outputs using a held-out calibration set — two parameters, handles asymmetric miscalibration, needs at least a few hundred calibration examples. Isotonic regression fits a non-parametric monotone function from predicted probabilities to observed frequencies — maximally flexible, but overfits aggressively below about 1,000 examples per class. Temperature scaling divides all logits by a single scalar T before the softmax — one parameter, zero retraining, accuracy unchanged, and it works remarkably well for neural networks.

NOT this. A high AUC does not mean a model is well-calibrated. AUC measures discrimination: can the model rank positives above negatives? Calibration measures accuracy of probability estimates: are the numbers themselves trustworthy? A model can have AUC = 0.95 and predict 80% for everything that ends up at 55%. These are orthogonal properties. AUC tells you the model can rank correctly. Calibration tells you the numbers mean what they say. For risk modeling, insurance pricing, and medical decisions, you need both — ranking without calibration means you can order applicants but cannot price the risk correctly. The Brier score = (1/n)Σ(pᵢ - yᵢ)² penalizes both failures jointly and is the single number that captures the full picture. ECE (Expected Calibration Error) isolates the calibration component.

Key points

Takeaway

Temperature scaling cannot hurt accuracy (argmax is unchanged) and fixes most of the systematic overconfidence that cross-entropy training induces — it is the mandatory post-training step before using a neural classifier for probabilistic decisions. The AUC vs ECE tradeoff is the calibration insight that matters most: AUC measures ranking quality, ECE measures whether probabilities are accurate at the threshold you actually use for decisions. A model with high AUC but poor calibration is systematically mispricing risk at every decision boundary.

Recap

Check your understanding

Q1. Your model has AUC = 0.92 but ECE = 12%. Select the two correct statements about what this means and what to do.

Q2. You need to compare two models for a medical triage application. Model A has AUC=0.88, ECE=0.03. Model B has AUC=0.91, ECE=0.11. Which do you deploy?

Q3. Why does standard cross-entropy training produce overconfident neural networks, and does label smoothing fix it?

Try it interactively

ML Systems Lab is a free interview-prep platform for ML engineers — work through the full interactive module, quizzes, and drills.

Open ML Systems Lab →