Calibration & Proper Scoring Rules
When a predicted 80% should mean 80%.
A forecaster who says "70% chance of rain" should see rain on about 70% of those days, and a classifier's 70% should mean the same. This lesson makes calibration precise, builds the scoring rules that reward honest probabilities out of simple decisions, splits every proper score into a calibration part and a refinement part, shows why the popular expected calibration error is a biased estimate, and compares the standard ways to recalibrate a model after training.
What you’ll learn
- Define calibration for binary and multiclass predictors, and explain why calibration alone says nothing about skill.
- Show that mixtures of cost-weighted misclassification losses are proper scoring rules, and recover the Brier score and log loss as two such mixtures.
- Prove the calibration–refinement decomposition of the Brier score, Murphy's three-term partition, and the analogue for log loss.
- Explain the biases of the binned ECE, and estimate its noise floor.
- Derive and compare Platt scaling, isotonic regression and temperature scaling, and summarize what is known about which models need them.
Calibration, precisely
Take any function of the input, however crude, and predict . Since is itself a function of , the tower property gives calibration at once:
With constant this is the base rate , a calibrated predictor that knows nothing. With it is the Bayes posterior , the most informative one. Everything between is calibrated too; what separates them is refinement, how finely the predictions sort cases with different outcomes.
Calibration is cheap even against an adversary: Foster & Vohra (1998) showed that a forecaster who randomizes its forecasts can be asymptotically calibrated on every sequence of binary outcomes, with no model of where the sequence comes from. So calibration is a constraint, not a goal. The goal is the most refined forecast that is still calibrated, and proper scoring rules measure exactly that combination.
A readmission model outputs 0.18 for every patient, and 18% of the patients are readmitted. Which statement is true?
- It is not calibrated, because it never predicts above 0.5
- It is calibrated, but it cannot tell patients apart: its AUC is 0.5
- It is miscalibrated, because calibration requires a spread of predictions
- Its Brier score is 0, because its predictions match the observed rate
Show the answer
B. It is calibrated, but it cannot tell patients apart: its AUC is 0.5
Among cases predicted 0.18, 18% are positive: that is calibration. But every patient gets the same number, so the model ranks no one above anyone else (AUC 0.5) and its Brier score is , the score of knowing nothing. Calibration without refinement is useless.
Proper scoring rules, built from decisions
A scoring rule charges a loss for reporting probability when the outcome is . It is proper if, whenever , reporting minimizes the expected loss, and strictly proper if is the unique minimizer (Gneiting & Raftery, 2007). Every proper rule can be built from the simplest probabilistic decisions.
Fix a threshold : act when , paying for a false positive and for a false negative. Under , acting costs and not acting costs ; reporting acts exactly when , which picks the cheaper option. So this loss is proper, though not strictly: any on the same side of does as well.
Average over thresholds with a weight . A mixture of proper rules is proper, and if everywhere it is strictly proper: reporting makes the wrong decision for every threshold between and .
Uniform weights, , give half the Brier score:
Weights , which pile up near 0 and 1, give the log loss:
Conversely, under mild regularity and continuity conditions, every proper scoring rule for a binary event has this form, up to a term that depends only on the outcome, once the weight may be any nonnegative measure; the rule is strictly proper exactly when that measure gives positive mass to every open interval (Schervish, 1989; Gneiting & Raftery, 2007, Theorem 3). The weight says which decisions a score cares about. The Brier score averages the decision losses uniformly over the threshold , the false positive's share of the two costs; log loss weighs extreme cost ratios so heavily that a confident mistake costs without bound, and it is the score that maximum likelihood minimizes. Accuracy is the single threshold : proper, but blind to everything except which side of a forecast falls on.
An improper example: charge , one minus the probability given to what happened. Its expected value is linear in , so when the best report is . A rule like this rewards overconfidence.
Calibration plus refinement
Condition on the forecast. Given , is Bernoulli with mean , so the Brier identity applies with and :
Average over to get the decomposition. For the refinement, use :
The same conditioning works for log loss, with entropy in place of and a Kullback–Leibler divergence as the calibration term. Bröcker (2009) showed that every strictly proper score splits this way, for outcomes with any finite number of values: a divergence that measures reliability, plus a generalized entropy of the recalibrated forecast (uncertainty minus resolution).
Three consequences. The best recalibration of is itself, which removes the calibration term and touches nothing else. A strictly increasing recalibration map carries exactly the same information as , so it leaves refinement unchanged and can move the score only through calibration. And only a better model, one that knows more about , improves refinement.
The widgets of the next two steps make this concrete: their calibrated and overconfident models rank every case identically, so they share their refinement. The gap between their test Brier scores, 0.192 against 0.174, estimates the overconfident model's calibration term (its population value is 0.020), and temperature scaling removes almost all of it.
The forecaster above recalibrates: it now says 30% on the first group of days and 70% on the second. What is its new Brier score?
Show the answer
0.21
Recalibration sets , so REL drops to 0 while RES and UNC, which depend only on how the days are grouped and on what happened, stay at 0.04 and 0.25: . Check directly: on the first 50 days , and the same on the second.
Measuring calibration: the ECE and its biases
The standard estimate, the expected calibration error, splits into bins and compares, in each bin holding of the test predictions, the mean prediction with the observed frequency (Naeini, Cooper & Hauskrecht, 2015):
It estimates the calibration error (with squares instead of absolute values, it estimates the Brier calibration term). Two biases pull in opposite directions.
- Averaging within bins hides error. In the population, binning can only lower the error: by Jensen's inequality , and gaps of opposite sign inside one bin cancel. Kumar, Liang & Ma (2019) found that Platt and temperature scaling are less calibrated than binned measurements reported. They proposed a scaling–binning calibrator, which fits a parametric map and then bins its outputs so that the result can be verified, and an estimator from meteorology whose sample requirement grows like rather than .
- Noise inflates it. Even a perfectly calibrated model has , because each is a binomial average around and the absolute value of noise has positive mean.
Think first A model scores ECE = 0.03 on 2,000 test examples with 20 bins. Is it miscalibrated?
Not necessarily: the bound above puts the noise floor of a calibrated model near , so 0.03 may be pure noise. Test it directly. Keep the model's predictions, redraw every label as , which is exactly what a calibrated model would see, recompute the ECE many times, and ask where 0.03 falls among those values. Report the reliability diagram with intervals per bin, and the number of examples in each bin, rather than a single number.
The ECE also behaves badly as a function: tiny changes in the predictions can move it a lot. Błasiok, Gopalan, Hu & Nakkiran (2023) proposed taking the distance to the nearest perfectly calibrated predictor as the ground truth, showed that the ECE is not even continuous in the predictor, and identified measures that approximate this distance consistently and can be estimated efficiently, such as the smooth calibration error.
Recalibration, and which models need it
Recalibration learns a map from a trained model's scores to probabilities, on a held-out calibration split. The model's own training data will not do: its predictions there are overfit, typically overconfident. The common maps differ in flexibility:
| Method | Map | Parameters | Good at | Weak at |
|---|---|---|---|---|
| Platt scaling (Platt, 1999) | on a score | 2 | sigmoid-shaped distortions; small calibration sets | distortions of other shapes |
| Temperature scaling (Guo et al., 2017) | on logits | 1 | keeps the argmax and each example's order of classes (with two classes, the ranking of examples too); works for many classes at once | any distortion that is not a pure temperature |
| Isotonic regression (Zadrozny & Elkan, 2002) | the best nondecreasing step function | as many as the data support | any monotone distortion, given enough data | overfits small calibration sets; ties ranks; can output exactly 0 or 1 |
| Histogram binning (Zadrozny & Elkan, 2001) | the observed frequency in fixed bins | simplicity | coarse; discards the ranking inside each bin |
Suppose the score is Gaussian within each class with a common variance, , and . Bayes' rule gives the true calibration map in log-odds form:
The terms cancel, leaving a linear function of . So exactly, with the sigmoid, and Platt's family contains the truth; with unequal variances an term survives and Platt scaling is misspecified.
ISOTONIC-FIT(scores s_1..s_n, labels y_1..y_n) # pool-adjacent-violators
sort the pairs by score
blocks = empty stack # each block: sum of labels, count
for each (s, y) in order:
push the block (y, 1)
while the stack has two blocks and mean(second from top) > mean(top):
pop both and push their merge # pool the violating pair
return the step function: each block's score range -> its mean labelPool-adjacent-violators finds the least-squares nondecreasing fit in after sorting. Each merge restores monotonicity locally, and the final blocks are the steps of the calibration map.
Which models need it? In a comparison of ten learning methods, Niculescu-Mizil & Caruana (2005) found that maximum-margin methods such as boosted trees, boosted stumps and SVMs push predictions away from 0 and 1, a sigmoid-shaped distortion that Platt scaling repairs; naive Bayes pushes them toward 0 and 1; neural networks and bagged trees were well calibrated as they were. Platt scaling beat isotonic regression when calibration data were scarce, and after calibration boosted trees, random forests and SVMs gave the best probabilities.
Twelve years later, Guo, Pleiss, Sun & Weinberger (2017) found that modern deep networks, unlike those of a decade earlier, are poorly calibrated, typically overconfident, with depth, width, weight decay and batch normalization all playing a role, and that temperature scaling was surprisingly effective. Minderer et al. (2021) then found the most recent image classifiers, notably those not using convolutions, to be among the best calibrated, with model size and the amount of pretraining not fully explaining the differences: architecture matters. And calibration measured on held-out data need not survive distribution shift. Ovadia et al. (2019) found that post-hoc calibration falls short under shift, while methods that average over models held up best (the benchmark is discussed in Uncertainty in Neural Networks; shift itself is the subject of Deployment & a Changing World).
Key takeaways
- Calibration means . It is cheap: every coarsening , including the base rate, is calibrated; skill is refinement.
- Proper scoring rules are mixtures of cost-weighted decision losses: uniform weights give the Brier score, gives log loss, and a single threshold gives accuracy, which is proper but not strictly.
- Brier = calibration + refinement, and refinement = uncertainty − resolution (Murphy); log loss splits into a KL term and an entropy term. Strictly increasing recalibration changes only the calibration term.
- The binned ECE has a positive noise floor of order and can also hide miscalibration inside bins; compare it with what a calibrated model would show on the same data.
- Platt scaling fits a sigmoid, temperature scaling a single divisor, isotonic regression any monotone map; fit them on held-out data, and prefer the least flexible map that fits the distortion.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
A scoring rule charges , one minus the probability the forecast gave to the outcome that occurred. A forecaster believes the event has probability 0.7. Which report minimizes its expected charge?
- 0.7
- 0.5
- 1
- 0.85
Show the answer
C. 1
The expected charge is , which decreases all the way to . The rule is improper: it rewards claiming certainty. Log loss and the Brier score, by contrast, are minimized exactly at .
You recalibrate a model with a strictly increasing map. Which terms of the Brier decomposition can change?
- Only the calibration term
- Only the resolution term
- The uncertainty term
- All three
Show the answer
A. Only the calibration term
A strictly increasing map keeps every distinction between cases, so the calibration function sees the same groups and is unchanged; the uncertainty depends only on the data. Only the gap between forecasts and observed frequencies moves. To improve resolution you need a more informative model.
A perfectly calibrated model is evaluated on 500 test examples. What happens to its binned ECE as you increase the number of bins from 10 to 30?
- It stays at exactly zero
- It becomes negative
- It decreases, because finer bins are more accurate
- It tends to increase, because each bin's frequency is noisier
Show the answer
D. It tends to increase, because each bin's frequency is noisier
Each bin's observed frequency deviates from its mean prediction by sampling noise of order , and the absolute value of noise has positive mean. More bins mean fewer examples per bin and a higher noise floor, roughly in proportion to , even though the model's true calibration error is zero.
Temperature scaling replaces a binary classifier's logit by , with , and predicts class 1 when . Which of these can it change?
- The predicted class of some examples
- The log loss and the ECE
- The AUC
- The accuracy
Show the answer
B. The log loss and the ECE
Dividing every logit by the same preserves their signs and their order, so the predicted classes (hence accuracy) and the ranking of examples (hence AUC) stay the same. The probabilities themselves change, softer for and sharper for , and with them the log loss, Brier score and ECE.
Further reading
- T. Gneiting & A. E. Raftery, "Strictly proper scoring rules, prediction, and estimation," Journal of the American Statistical Association 102(477), 359–378 (2007).
- A. H. Murphy, "A new vector partition of the probability score," Journal of Applied Meteorology 12(4), 595–600 (1973).
- A. Niculescu-Mizil & R. Caruana, "Predicting good probabilities with supervised learning," Proceedings of ICML (2005).
- C. Guo, G. Pleiss, Y. Sun & K. Q. Weinberger, "On calibration of modern neural networks," Proceedings of ICML, PMLR 70 (2017).
- A. Kumar, P. Liang & T. Ma, "Verified uncertainty calibration," Advances in Neural Information Processing Systems 32 (2019).