What does it mean for a classifier to be calibrated? Compute the expected calibration error (ECE) for two confidence bins: 60 predictions with mean confidence 0.9 and accuracy 0.75, and 40 predictions with mean confidence 0.6 and accuracy 0.55. How does temperature scaling fix miscalibration?

ML systems and evaluation, Calibration
Level L2 Elementary. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you know that calibration is separate from accuracy, can compute ECE, and know the standard post-hoc fix.

Key idea

Calibrated means Pr⁡(Y=y^∣p^=p)=p for all p: among predictions made with confidence 0.8, about 80% are correct. Expected calibration error is ECE=∑bnbN∣acc(b)−conf(b)∣, where nb is the count in bin b, N is the total predictions, acc(b) is bin accuracy and conf(b) is bin mean confidence. Temperature scaling divides the logits z (the scores before softmax) by one number T>0 fitted on validation data: p^=softmax⁡(z/T).

Steps

  1. Define calibration and describe the reliability diagram: plot accuracy against confidence per bin, where the diagonal represents perfect calibration and points below it indicate overconfidence.
  2. Compute ECE: 60100∣0.75−0.9∣+40100∣0.55−0.6∣=0.6×0.15+0.4×0.05=0.09+0.02=0.11. The model is overconfident in both bins.
  3. Explain temperature scaling: fit T by minimising NLL (negative log-likelihood) on a held-out validation set; T>1 softens overconfident predictions. Dividing all logits by the same positive T keeps the top-scoring class (argmax) unchanged, so accuracy does not change.
  4. Other fixes exist, such as Platt scaling and isotonic regression, but they need more care and more validation data; they come at a later level.
  5. State why calibration matters: cost-based decision thresholds, risk scores and model averaging all assume predicted probabilities reflect true frequencies, and modern deep networks are often overconfident.

Common mistakes

How long your answer should be

3–4 minutes: the definition, the ECE arithmetic, and the temperature formula.

Read this

Previous in ML systems and evaluation: Why is ordinary shuffled k-fold cross-validation wrong for time-series data, and what should you do instead?
Next in ML systems and evaluation: A binary classifier outputs predicted probabilities [0.90,0.80,0.70,0.60,0.40,0.20] for six test examples with true labels [1,0,1,1,0,0]. What are the (FPR,TPR) points on the ROC curve, and what is the exact ROC-AUC?