II · THE IDEA · ARTIFICIAL INTELLIGENCE
Calibration: When Confidence Matches Correctness
▶ Listen · narrated
A classifier can pick the right answer nine times in ten and still lie about how sure it is. The number printed beside each prediction is a separate claim, and it often fails.
At a glance
- What it is
- Alignment of a model’s stated confidence with its observed frequency of being correct
- Common metric
- Expected Calibration Error (ECE), from binned confidence versus accuracy
- Simple remedy
- Temperature scaling: divide logits by a single learned scalar before softmax
- Regression form
- Predicted intervals at level p should cover the true value with frequency p
- Visual check
- A reliability diagram; perfect calibration lies on the diagonal
A forecaster who says "90 per cent chance of rain" is making a claim you can check. Collect every day she said it. If rain came on only half of those days, her numbers are wrong — even if she often names the right weather. Deep networks behave like that forecaster. They pick the right answer often enough to look accurate, but the probability printed beside the answer is too large.
The check is simple. Group the predictions into buckets of similar stated confidence. In each bucket, count how often the model was actually right. Compare the two numbers. If the model says 90 per cent but is right only 70 per cent of the time, the confidence cannot be trusted.
When the numbers disagree, a small repair often works. A classifier ends in a set of raw scores, one per possible answer, which get squashed into probabilities. Training tends to spread those raw scores too far apart, and wide gaps come out as near-certainty. The fix, called temperature scaling, divides every raw score by one number, chosen using data the model has never trained on. Dividing pulls the scores closer together, so the probabilities come out gentler. The winning answer does not change, because every score is divided by the same amount. Only the confidence changes.
For models predicting a continuous quantity rather than a category, the same idea adjusts the width of the predicted range, so that a range labelled 90 per cent really does contain the true value about 9 times in 10. The aim in both cases is modest: make the numbers safe to read as frequencies, without rebuilding the model.
Calibration requires that predictive confidence equals empirical accuracy conditional on that confidence. For a classifier with prediction ŷ and confidence ĉ = max_k p̂(y = k | x), perfect calibration means P(y = ŷ | ĉ = p) = p for all p in [0, 1]. It is diagnosed with reliability diagrams — accuracy plotted against binned confidence — and summarised by Expected Calibration Error: partition [0, 1] into M bins and take the sample-weighted mean of |acc(b_m) − conf(b_m)|.
Guo et al. showed that modern deep classifiers are systematically miscalibrated, and over-confident rather than under-confident. Depth, width and batch normalisation correlate with higher ECE; weight decay reduces it. They also observed that negative log likelihood continues to fall after error rate has saturated. The mechanism is direct: NLL is minimised by driving the correct-class logit ever further above its competitors, softmax maps those widening margins onto probabilities approaching 1, and the predictive distribution grows sharper without growing more accurate.
Among post-hoc corrections, temperature scaling applies z ↦ z/T with a single T > 0, fitted by minimising NLL on validation data while the network stays frozen. Because T is shared across classes it is a monotone transform of the logit vector: argmax is preserved and accuracy is unchanged. On their benchmarks it matched or beat vector Platt scaling, histogram binning, isotonic regression and Bayesian binning, at 1 parameter.
For regression, Kuleshov et al. restate calibration through the predictive CDF: the fraction of held-out targets falling below the predicted p-quantile should equal p. They fit a recalibration map — typically isotonic regression — from predicted confidence levels to empirical coverage, then compose it with the base model to yield calibrated quantiles, intervals or densities, again without retraining.
The limits follow from the construction. Both families assume the validation set represents deployment conditions. Temperature scaling, having 1 shared parameter, cannot correct class-specific bias that a full parameter matrix might. ECE depends on the number and placement of bins. And neither method produces epistemic uncertainty about inputs unlike anything seen in training; they rescale the uncertainty already present in the outputs, and a confident error on an out-of-distribution input survives the rescaling intact.
Look closer
Confidence is not accuracy
After training, a network emits a probability for each class. Averaging those top-class probabilities in a confidence bin and comparing them with the actual fraction correct in that bin often shows a clear gap: modern networks tend to sit above the diagonal, meaning they are over-confident. The gap is not a curiosity of one architecture; it appears across image classifiers of increasing depth and width.
A single temperature
Temperature scaling leaves the predicted class unchanged. It only softens or sharpens the distribution by dividing the logits by a positive scalar T, chosen on a held-out validation set to minimise negative log likelihood. Despite its simplicity, on the classification tasks studied it matched or beat heavier post-hoc methods such as Platt scaling, histogram binning and isotonic regression, without adding parameters per class.
Regression needs its own map
In regression the target is continuous, so calibration is restated in terms of predictive distributions or intervals. A separate recalibration step — commonly an isotonic regressor fitted on held-out predicted quantiles versus empirical coverage — adjusts those distributions so that a 90 per cent interval really covers about 90 per cent of outcomes. The underlying network need not be retrained.
The story
Calibration is a promise about frequency. When a classifier reports 70 per cent confidence, it is not describing a feeling; it is making a prediction you can check. Collect every case where the model said 70 per cent. If the number is honest, about 70 in every 100 of those answers will be correct. A model whose stated confidence matches its actual rate of being right is called calibrated. This is not the same thing as accuracy. Accuracy asks whether the top answer is right. Calibration asks whether the number printed beside that answer can be believed.
The standard test is a reliability diagram. Sort the model's predictions into bins by stated confidence — everything near 60 per cent in one bin, everything near 90 per cent in another. In each bin, count the fraction of predictions that were actually correct, and plot it against the confidence the model claimed. An honest model traces the diagonal: 60 lands on 60, 90 on 90. Averaging the gaps across bins, weighted by how many predictions each bin holds, gives a single score called Expected Calibration Error.
Modern deep networks fail this test in a consistent direction. When Guo and colleagues ran it on image classifiers, the curves bowed above the diagonal: the models were over-confident, stating confidence well beyond their actual rate of being right. The pattern was not a quirk of one design. The very ingredients that had been raising accuracy — deeper stacks of layers, wider layers, and batch normalisation, a technique that stabilises training by rescaling the values flowing between layers — each went with worse calibration in the settings they examined. One ingredient pushed the other way: weight decay, a penalty that discourages large weights, tended to help.
The mechanism is worth walking through slowly, because it explains why the problem grew as models did. A classifier ends in a row of raw scores, one per class, called logits. A function called softmax converts those scores into probabilities that add up to 1. It favours the largest logit, and the wider the gap between the largest and the rest, the closer its probability gets to certainty. Training minimises a loss called negative log likelihood, which rewards the model for piling probability on the correct answer. Here is the trap. Even after the model has stopped getting more answers right, that loss can still be driven lower — by pushing the correct logit further above its rivals on the answers it already gets. Guo and colleagues observed exactly this: the loss kept falling after the error rate had flattened. Wider gaps between logits mean sharper probabilities out of softmax. So the model prints 0.99 where 0.85 would have been honest — not because it knows more, but because the training objective kept rewarding sharpness after correctness had run out of room to improve.
The repair can be a single number. Temperature scaling takes the finished, trained network and divides every logit by the same positive constant, T, before softmax. Dividing shrinks the gaps between the scores, and smaller gaps come out of softmax as gentler probabilities. Because every class is divided by the same T, their order cannot change: the winning answer stays the winning answer, and accuracy is untouched. Only the confidence moves. The value of T is chosen on a held-out validation set — data the model never trained on — by finding the T that makes the softened probabilities fit that data best. On the benchmarks Guo and colleagues studied, this one-parameter fix cut calibration error about as well as far heavier post-hoc methods — Platt scaling, histogram binning, isotonic regression and Bayesian binning — some of which fit many parameters per class.
Classification is only half the picture. When the target is a continuous quantity — a temperature, a price, a distance — the model's uncertainty takes the form of a range rather than a class probability, and calibration means that a range labelled 90 per cent should contain the true value about 90 per cent of the time. Kuleshov and colleagues showed that deep regression models often break this promise too, and that the fix follows the same shape. On held-out data, compare the coverage the model promised at each level with the coverage it actually delivered. Then fit a small correcting function through those pairs — usually isotonic regression, which finds the best-fitting curve that never decreases — and use it to widen or narrow every future interval. The network's weights are never retrained.
Both repairs share one honest limitation. They assume the validation data resembles the data the model will meet in deployment. Neither method creates new uncertainty; each reshapes the uncertainty the model already expresses so that its numbers can be read as frequencies. A model that meets an input unlike anything in its training data can still be confidently wrong, and the rescaling will preserve that confident error intact. Within those bounds, though, the payoff is large for the price. Every decision built on a confidence score — refusing to answer below a threshold, routing hard cases to a person, weighing one model's vote against another's — silently assumes the score means what it says. Making that assumption true costs a validation set and a few minutes of fitting, after the expensive training is already done.
Why it mattered then
Deep networks were moving into settings where a confident wrong answer costs something real, and accuracy alone had stopped being a sufficient report card. The calibration work landed once it became clear that the very recipes lifting benchmark scores — deeper networks, wider layers, harder optimisation of the likelihood objective — were pulling stated confidence away from actual correctness. A principled alternative already existed: Bayesian training, which treats every weight in the network as a distribution rather than a fixed number and accounts for uncertainty from the start. But it costs far more to run, and most practitioners would not pay. Temperature scaling and interval recalibration offered a bargain instead: keep the accuracy already won, fix only the numbers coming out, and pay with nothing more than a validation set and a few minutes of fitting.
Why it matters now
Any system that acts on a confidence score is assuming calibration, whether or not anyone wrote that assumption down. A pipeline that answers above 0.9 and defers below it, a cascade that passes hard cases to a larger model, an agent deciding whether to call a tool — each reads the printed number as a frequency. If the number is inflated, the threshold lets bad answers through. If it is deflated, good answers are thrown away. Post-hoc methods matter more now because the training of large models is rarely under the user's control. You cannot change the objective or the architecture, but you can hold out some of your own data, fit a single temperature or a small recalibrator for a regression head, and measurably improve the exact quantity your decision rule depends on.
The surprising detail
Temperature scaling is one number. It changes no label and adds no parameter per class, yet on the architectures tested it matched isotonic regression and Bayesian binning, which fit far more. The same study found something more awkward. Once accuracy has levelled off, further falls in the training loss are a symptom of miscalibration, not a sign of a better probability model. Driving the loss lower makes the probabilities sharper, and sharper is not the same as truer.
What is disputed
Reported gains for temperature scaling and for isotonic recalibration are tied to the architectures, datasets and binning choices in the cited studies. How far they transfer to very large language models, heavy class imbalance, or strong distribution shift is not settled by those results alone, and ECE itself is sensitive to the number and placement of bins.
Remember this
Read a model's confidence as a claim about frequency. Test the claim on held-out data. If it fails, reshape the outputs before you touch the network.
Test yourself
A classifier is accurate and its temperature-scaled probabilities are well calibrated on a validation set drawn from the same distribution as training. You deploy it on a shifted domain where accuracy drops. Why might the confidence scores still mislead a downstream threshold, and what does that imply about what temperature scaling actually fixed?
Temperature scaling only rescales the existing logits; it does not detect that the inputs have left the training distribution. On the new domain the network may still emit high maximum softmax values for wrong answers, and a T chosen under the old distribution need not restore the confidence–accuracy match. Calibration on one distribution is not a guarantee of calibration on another. The method fixed a systematic over- or under-sharpening of the original output layer — not the deeper problem of recognising unfamiliar inputs.
Go deeper
- [1706.04599] On Calibration of Modern Neural Networks · arxiv.org
- [1807.00263] Accurate Uncertainties for Deep Learning Using Calibrated Regression · arxiv.org
Image: Original diagram, The Daily Triptych. Licence: Original work. Source.