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
- Calibration asks one question: when the model says 70%, does the positive outcome happen 70% of the time? It is not the same question as "does the model rank correctly." A random forest that outputs 0.8 for a loan default where only 55% of those loans actually defaulted is overconfident by 25 percentage points — every risk reserve and pricing decision built on that number is wrong, even though the model may still separate good and bad loans well.
- The reliability diagram is the diagnostic: bin predictions into equal-frequency buckets (0–10%, 10–20%, ...), plot mean predicted probability against the actual positive rate per bucket. A perfectly calibrated model traces the diagonal. A curve that sags below the diagonal is overconfident — the gap between the curve and the diagonal at any point is the calibration error there. The practical test: take all predictions in the 0.7–0.8 bucket and check what fraction of outcomes were actually positive. If it is not approximately 75%, the model is miscalibrated at that decision boundary.
- Calibration is not a universal default — it depends on the model family. Logistic regression is calibrated by construction: it optimizes a proper scoring rule that directly rewards accurate probability estimates. Random forests and gradient boosting trees are routinely overconfident because their leaf proportions cluster near 0 and 1 once trees are fully grown. SVM scores are not probabilities at all by default and need Platt scaling before any probabilistic interpretation is valid.
- Neural networks are systematically overconfident after standard cross-entropy training (Guo et al., 2017), and it gets worse with scale, not better. The optimizer keeps pushing logits toward infinity even after labels are correctly ranked, since cross-entropy has no incentive to stop once ranking is right. Label smoothing softens this by damping the one-hot targets during training, but only partially — temperature scaling after training is still the standard, expected fix on top of it.
- Temperature scaling is the first thing to try for a neural network: divide all logits by a single scalar T before the softmax. One parameter, zero retraining, and accuracy is unchanged because argmax is invariant to positive rescaling. Fit T on a held-out set by minimizing NLL of softmax(logits/T). ECE typically drops from 10–15% down to 1–3% — it corrects uniform overconfidence but assumes the miscalibration pattern is the same shape at every probability level.
- Platt scaling handles the case temperature scaling can't: non-uniform miscalibration. It fits a full logistic regression on top of the model's outputs using a held-out calibration set — two parameters instead of one, so it can correct overconfidence that behaves differently at high vs. low predicted probabilities. It needs at least a few hundred calibration examples to fit reliably.
- Isotonic regression is the most flexible fix, and the most data-hungry. It fits a non-parametric monotone function from predicted probabilities to observed frequencies, so it can correct any monotone miscalibration shape — not just the uniform or two-parameter patterns temperature and Platt scaling assume. That flexibility overfits aggressively below roughly 1,000 calibration examples per class, so it is the last resort, not the default.
- AUC and calibration are orthogonal, and confusing them is the most common production trap. AUC measures discrimination — can the model rank positives above negatives. Calibration measures whether the probability numbers themselves are trustworthy. A model can have AUC = 0.92 and still predict 80% for cases that resolve positive only 55% of the time: it ranks correctly and prices risk wrong at the same time. For risk modeling, insurance pricing, or medical decisions you need both properties, not just the one that shows up in standard evaluation reports.
- Brier score and ECE answer different questions. Brier score = (1/n)Σ(pᵢ − yᵢ)² penalizes discrimination and calibration failures jointly in one number, which is why it is the single metric that captures the full picture. ECE isolates just the calibration component — it is the number to report when the question is specifically "are these probabilities accurate," not "is this model good overall."
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
- Calibration: when the model says 70%, does the positive outcome happen 70% of the time? "0.8 predicted, 55% actual" = overconfident.
- Reliability diagram: bin predictions, plot mean predicted vs actual positive rate; perfect = diagonal, overconfident sags below.
- Family behaviour: logistic regression calibrated by design; random forests / GBMs overconfident (leaf proportions near 0/1); NNs overconfident post-CE.
- Temperature scaling: divide logits by scalar T — one param, no retrain, accuracy unchanged; ECE 10–15% → 1–3%. Do it first.
- Platt scaling for non-uniform miscalibration; isotonic regression for any monotone pattern but needs > 1,000 examples/class.
- AUC ⊥ calibration: AUC measures ranking, ECE measures probability accuracy at the threshold — a model can rank well and misprice risk.
- Brier score $=rac1nsum(p_i-y_i)^2$ penalises both discrimination and calibration jointly; ECE isolates the calibration part.
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.
- A) The model ranks correctly (high AUC) but its predicted probabilities are miscalibrated, roughly 12 points off on average.
- B) Applying temperature scaling and re-checking the reliability diagram on held-out data is the appropriate next step.
- C) ECE = 12% means the training set has 12% label noise, requiring a full re-annotation pass before retraining.
- D) A 12% ECE is expected and acceptable at AUC = 0.92, since calibration error naturally scales with AUC gains.
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?
- A) For threshold-driven triage, calibration matters. Try recalibrating Model B first; deploy it only if that fixes ECE without hurting AUC.
- B) Always deploy the higher-AUC model in medical settings, since ranking quality alone determines triage prioritisation correctness under audit.
- C) Neither model is deployable; medical applications strictly require ECE below 0.01 and AUC above 0.95 under regulatory standards.
- D) Deploy Model A only — ECE is always more important than AUC in every medical application regardless of how the output is used.
Q3. Why does standard cross-entropy training produce overconfident neural networks, and does label smoothing fix it?
- A) Cross-entropy pushes softmax toward one-hot, inflating logits; label smoothing helps but temperature scaling is still recommended.
- B) Cross-entropy training is not actually the cause of overconfidence; the real cause is batch normalisation, which should be replaced entirely with layer norm.
- C) Label smoothing fully and permanently fixes overconfidence, eliminating any need for post-hoc calibration methods of any kind.
- D) Cross-entropy training produces underconfidence rather than overconfidence; label smoothing corrects this by sharpening the output logits.
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 →