Model Evaluation · ML Systems Lab

Model Calibration: Why Neural Networks Are Overconfident and How to Fix It

A model that predicts 90% confidence should be right 90% of the time. Most neural networks are not. Modern deep networks are systematically overconfident — their predicted probabilities are higher than their actual accuracy. This matters for any downstream decision that uses probabilities: risk scoring, medical diagnosis, fraud thresholds. Calibration diagnosis, Platt scaling, and temperature scaling are the tools.

A well-calibrated model means exactly what it says: when it assigns probability 0.7 to an event, the event occurs 70% of the time. Calibration is distinct from accuracy — a model can be accurate on average but badly miscalibrated, assigning 0.99 confidence to predictions where it is wrong 20% of the time. For applications that use model outputs as probabilities (fraud scores, medical risk, credit scoring), calibration is as important as accuracy.

The calibration problem with modern deep networks

Guo et al. (2017) showed that modern neural networks are systematically miscalibrated despite high accuracy. Models trained before ~2010 (SVM, logistic regression, shallow networks) were reasonably well-calibrated. Modern deep networks with batch norm, weight decay, and deeper architectures are overconfident: they assign probabilities close to 0 or 1 more often than their actual accuracy warrants. The paper attributed this to the combination of model capacity (deep networks memorise training data, driving probabilities toward 1) and the cross-entropy loss (which rewards confidence even beyond what accuracy justifies).

Reliability diagrams and Expected Calibration Error

A reliability diagram plots model confidence (x-axis) against empirical accuracy (y-axis) by grouping predictions into confidence bins. A perfectly calibrated model lies on the diagonal. Overconfident models lie below the diagonal (confidence > accuracy); underconfident models lie above it.

Expected Calibration Error (ECE) = Σ_{b} (|B_b|/n) * |acc(B_b) - conf(B_b)|, summing over confidence bins weighted by bin size. Lower ECE = better calibrated. Modern deep networks have ECE of 10-15% on ImageNet; a well-calibrated model should have ECE below 2-3%.

Platt scaling: post-hoc calibration with logistic regression

Platt scaling trains a logistic regression on the model's raw scores (pre-softmax logits) using a small held-out calibration set. The two parameters (w and b) of logistic regression adjust the scale and shift of the score distribution to match the true label frequencies. Simple, fast, and effective for binary classification. The calibration set must be separate from the training set (to avoid overconfidence on training data leaking into the calibration).

Temperature scaling: single-parameter calibration

Temperature scaling (Guo et al., 2017) is the simplest calibration method for multi-class neural networks. The softmax is computed over logits / T, where T is a single temperature parameter. T > 1 softens the distribution (reduces confidence); T < 1 sharpens it (increases confidence). For overconfident networks, T > 1 is appropriate. T is found by minimising the NLL on the calibration set. Temperature scaling does not change the argmax prediction — it only changes the confidence — so it cannot hurt accuracy while improving calibration.

Isotonic regression: non-parametric calibration

Isotonic regression is a non-parametric monotone calibrator: it learns a step-function mapping from uncalibrated to calibrated probabilities, constrained to be monotonically increasing. More flexible than Platt scaling but requires more calibration data to avoid overfitting. Effective when the miscalibration pattern is complex and non-linear.

When calibration is critical in production

Credit scoring: a score of 0.7 feeds a decision tree with a specific threshold. If the model is overconfident (true default rate at 0.7 confidence is 0.4), the risk model sets incorrect thresholds and the business takes on more risk than modelled. Medical diagnosis: a 0.9 probability of disease feeds treatment decisions. Miscalibration can cause over- or under-treatment. Ensemble models: if you combine predictions from multiple models, each model's confidence should be a meaningful probability. Uncalibrated ensemble members degrade the combination.

Production tells — calibration failures that don't show up in your ECE dashboard

Four patterns. (1) Recalibration drift. The calibration parameters (Platt's a, b or temperature T) are fit at training time, then stored. Next retrain reuses them. The underlying score distribution shifted between retrains, so the cached calibration parameters are now wrong. ECE on the new training set will not catch this — you have to refit calibration on every retrain. (2) Threshold decisions set on uncalibrated scores. Ops set "block at score > 0.7" based on tuning at v3 of the model. v4 ships with the same accuracy but a tighter score distribution; the same threshold now blocks 3× the volume. The model "didn't change" from any accuracy metric's point of view; downstream is broken. Set thresholds on calibrated probabilities, not on raw scores. (3) Aggregate ECE hides per-segment miscalibration. Overall ECE of 1.5% looks great. But the model is overconfident in low-confidence predictions (where the 1.5% calibration error compounds) and underconfident in high-confidence ones, and the two cancel out in the aggregate. Per-bin reliability plots and per-class ECE will surface this. (4) Calibration measured on the wrong distribution. ECE computed on a uniform sample of the calibration set looks fine. The model is deployed to a slice (new market, new device, weekend traffic) where calibration is much worse. Cohort-stratified ECE is the fix.

Try on Colab: train ResNet-20 on CIFAR-10. Plot its reliability diagram and compute ECE before calibration. Apply temperature scaling: minimise NLL on a held-out calibration set (5% of training data) over T in [0.5, 2.0]. Plot the reliability diagram after temperature scaling. ECE should drop from ~8% to ~1-2%.

Continue interactively
Read this post inside ML Systems Lab — with Simplify toggle, interview Q&As, inline glossary, and the MLE Path forward pointer.
Open in MSL →