Calibration

Calibration measures whether predicted probabilities match observed frequencies — when a model says 80% confident, it should be right about 80% of the time. A model can be accurate yet badly calibrated, which misleads any downstream decision that uses its confidence.

Perfect calibration means:

More generally, for a predicted probability :

for all confidence levels where enough data exists.

Expected calibration error estimates the average gap between confidence and empirical accuracy:

Calibration complements probability metrics such as NLL and Brier score. NLL and Brier score summarize probability quality as scalar metrics; calibration diagnostics show where confidence and empirical frequency disagree.

Discrimination vs Calibration

PropertyQuestionExample Metric
discriminationcan the model rank positives above negatives?AUROC, PR-AUC, enrichment
calibrationdo predicted probabilities match frequencies?ECE, reliability diagram
sharpnessare probabilities confident when justified?entropy, Brier decomposition
decision qualitydo probabilities improve actions under a cost?expected utility, selective risk

A ranking model can have excellent AUROC and still be poorly calibrated. A calibrated model can still be useless if it cannot separate cases.

Binning Caveat

ECE depends on bins:

Small bins, class imbalance, and distribution shift can make ECE unstable. Use reliability diagrams and per-slice checks when decisions depend on confidence.

Practical Checks

  • Plot a reliability diagram; bin predictions and compare to empirical accuracy.
  • Report expected calibration error (ECE) alongside accuracy.
  • Calibrate on held-out data (temperature scaling, isotonic) — never on the test set.
  • Re-check calibration under distribution shift; it degrades faster than accuracy.
  • For ranking tasks, separate calibration from discrimination (AUC).
  • For abstention or human review, evaluate selective prediction instead of reporting confidence alone.
  • Check whether calibration is evaluated on the same population where decisions will be made.
  • For imbalanced datasets, inspect calibration by class, target, scaffold, subgroup, or score range.

Temperature Scaling

For classification logits , temperature scaling uses:

p_T(y=k\mid x) = \frac{\exp(z_k/T)} \sum_{\ell=1}^{K}\exp(z_\ell/T)}

where is fit on validation data. Larger softens overconfident probabilities; smaller sharpens them.

What Calibration Is Not

  • High accuracy does not imply calibration.
  • High AUC does not imply calibrated probabilities.
  • A model can be calibrated on IID data and miscalibrated under OOD shift.
  • Calibrating on the test set leaks evaluation information.