Skip to content
mlmentorship

Calibration: make probabilities match their event

Name the predicted event, check held-out frequencies, calculate temperature scaling, and separate calibration, ranking, accuracy, and probability-based actions.

Published · 12 min read ·Core ·Foundation

Visual quick review

Read a reliability diagram by comparing observed frequency with predicted confidence and use the diagonal to identify overconfidence or underconfidence.

Spatial intuition

Illustrative reliability diagram for positive-event probability

Illustrative reliability diagram for positive-event probability Horizontal values are mean predicted positive-event probabilities; vertical values are observed positive fractions. Five invented bins contain 100 cases each, with positive counts 12, 28, 43, 60, and 72 at probabilities 0.2, 0.4, 0.6, 0.8, and 0.9. All points lie below the diagonal: the event probability is overestimated. The 0.8 bin has a 20-percentage-point gap. These are illustrations, not measurements. perfect calibration EVENT UNDERESTIMATED EVENT OVERESTIMATED 20-point gap 80% vs 60% illustrative bins 0 0.5 1 0 0.5 1 mean predicted probability observed positive fraction
Read it this way: the diagonal marks probability-frequency agreement. Each invented bin has 100 cases, with positive counts 12, 28, 43, 60, and 72. All five points overestimate this event, not necessarily predicted-label correctness. At probability 0.8 versus positive frequency 0.6, the gap is 20 points.
Check: What observed count would make the 80% prediction bin calibrated?
Full explanation 12 min read
Reading depth

Summary

Calibration concerns a probability’s meaning, not which class ranks first. For binary event , calibration means in the evaluated population. This is different from calibrating predicted-label correctness, and weaker than calibrating every component of a multiclass distribution.

Task: ten untouched hypothetical binary cases all have positive-event probability ; six labels are one. Evaluate temperature , fitted on separate calibration data. Calculate the new probability, reliability gap, Brier score, and decisions at thresholds and .

Small sample frequencies have uncertainty; this fixture cannot establish population-wide improvement.

Measuring calibration

Use representative evaluation cases whose labels are mature and whose event definition is unchanged.

  1. Bin positive-event probabilities; report bin counts and mean probabilities.
  2. Count positive labels, not generic classification correctness, for each bin.
  3. Plot mean probability against positive fraction; the diagonal marks agreement.
  4. Report uncertainty and complementary proper scores such as Brier loss and log loss.

Event-frequency ECE averages absolute bin gaps using bin-frequency weights. It depends on binning and can conceal within-bin or subgroup errors; it does not measure discrimination by itself. For top-label calibration instead, define confidence as the selected class’s probability and outcomes as prediction correctness.

Spatial intuition

Calibration checks event frequencies; temperature can change actions without changing ranking

Calibration checks event frequencies; temperature can change actions without changing rankingFor this event, 80% forecasts should produce about 80 positives per hundred; here there are 60. Temperature scaling moves probabilities toward half without changing their order. In the separate example, case A crosses a 70% action threshold although ranking stays unchanged. Fit temperature on held-out data and recheck reliability; ranking or accuracy alone does not prove calibration.Every case received the same 80%forecastForecast expected count80 of 100Observed positive count60 of 10020 too high in thisaggregateExpected counts do not identifyindividual outcomesSeparate example: threepositive-event forecastsWarm the logits; move probabilitiestoward halfBlue: before. Green: after.Case ABefore 80%; after 66.67%Case BBefore 60%; after 55.05%Case CBefore 20%; after 33.33%0%100%A stays above B; B stays above CAt a 70% action threshold, A changessides70% thresholdCheck held-out reliability, notranking alone
Read it this way: For this event, 80% forecasts should produce about 80 positives per hundred; here there are 60. Temperature scaling moves probabilities toward half without changing their order. In the separate example, case A crosses a 70% action threshold although ranking stays unchanged. Fit temperature on held-out data and recheck reliability; ranking or accuracy alone does not prove calibration. Which case crosses the 70% action threshold?
Reference drawing

Spatial intuition

Calibration checks event frequencies; temperature can change actions without changing ranking

Calibration checks event frequencies; temperature can change actions without changing rankingFor this event, 80% forecasts should produce about 80 positives per hundred; here there are 60. Temperature scaling moves probabilities toward half without changing their order. In the separate example, case A crosses a 70% action threshold although ranking stays unchanged. Fit temperature on held-out data and recheck reliability; ranking or accuracy alone does not prove calibration.Every case received the same 80%forecastForecast expected count80 of 100Observed positive count60 of 10020 too high in thisaggregateExpected counts do not identifyindividual outcomesSeparate example: threepositive-event forecastsWarm the logits; move probabilitiestoward halfBlue: before. Green: after.Case ABefore 80%; after 66.67%Case BBefore 60%; after 55.05%Case CBefore 20%; after 33.33%0%100%A stays above B; B stays above CAt a 70% action threshold, A changessides70% thresholdCheck held-out reliability, notranking alone
Derivation
Illustrative reliability diagram for positive-event probability Horizontal values are mean predicted positive-event probabilities; vertical values are observed positive fractions. Five invented bins contain 100 cases each, with positive counts 12, 28, 43, 60, and 72 at probabilities 0.2, 0.4, 0.6, 0.8, and 0.9. All points lie below the diagonal: the event probability is overestimated. The 0.8 bin has a 20-percentage-point gap. These are illustrations, not measurements. perfect calibration EVENT UNDERESTIMATED EVENT OVERESTIMATED 20-point gap 80% vs 60% illustrative bins 0 0.5 1 0 0.5 1 mean predicted probability observed positive fraction
Read it this way: the diagonal marks probability-frequency agreement. Each invented bin has 100 cases, with positive counts 12, 28, 43, 60, and 72. All five points overestimate this event, not necessarily predicted-label correctness. At probability 0.8 versus positive frequency 0.6, the gap is 20 points.
Check: What observed count would make the 80% prediction bin calibrated?
Read it this way: For this event, 80% forecasts should produce about 80 positives per hundred; here there are 60. Temperature scaling moves probabilities toward half without changing their order. In the separate example, case A crosses a 70% action threshold although ranking stays unchanged. Fit temperature on held-out data and recheck reliability; ranking or accuracy alone does not prove calibration. Which case crosses the 70% action threshold?

Why confidence can be wrong

Finite samples, model misspecification, fitting choices, and deployment shift can break probability-frequency agreement. Guo et al. studied particular neural classification settings, not a universal ordering of every model family.

Cross-entropy is a proper probability objective; minimizing empirical loss is not a guarantee of correct population probabilities.

How to fix calibration

Temperature scaling

Use for binary logits, or shared-scalar for multiclass scores, with . Fit the temperature on calibration data and evaluate the frozen map on independent cases.

Here . Dividing by two gives , hence . The observed positive fraction remains .

CheckOriginalAfter separate fit
Absolute reliability gap
Brier loss
Positive decisions at TenTen
Positive actions at TenZero

Argmax accuracy remains six of ten. Shared positive temperature preserves class ordering, not every probability-based action.

Platt scaling

Fit to binary calibration labels. Its slope and intercept can change a threshold; an unconstrained negative slope can reverse ordering.

Isotonic regression

New task: replace a one-parameter map when nonlinear distortion persists and calibration data support a more flexible map. In a separate calibration fixture, three equally sized groups have scores and event rates . Each group has 20 cases, with positive counts . An increasing least-squares isotonic fit pools the last two rates to , giving . Check: previously distinct scores tie; both now exceed a threshold. Use when: scalar temperature leaves systematic errors; independently evaluate the frozen map and its plateaus.

Change the population

New task: deployment prevalence changes while score ordering stays stable. Collect mature representative labels and retest the same event by relevant slice. Check: a probability- bucket with five positive labels among ten now has empirical gap . Use when: traffic, labeling, or policy changes; ordering stability alone does not establish calibration.

Failure: always predicting a population’s base rate can be calibrated while distinguishing no cases.

Reconstruct: does lowering generation temperature calibrate factual confidence?

Answer

No. Decoding changes token sampling. Calibration requires a defined event and held-out frequency evidence, not merely more deterministic output.

Label smoothing during training

For classes, use under a declared smoothing convention. This changes training targets, not a post-hoc calibration fit; evaluate probability quality rather than assuming improvement.

Ensembling

Averaging probabilities changes the predictive distribution and inference cost. Neither lower error nor better calibration is guaranteed for every ensemble.

Bayesian methods

Posterior prediction, variational approximations, and Monte Carlo dropout represent different uncertainty procedures. Model assumptions and approximations still need checking; Bayesian construction alone does not prove empirical calibration under shift.

Calibration for LLMs

Next-token probability describes a token event conditional on context, not directly the truth of an entire answer. Self-consistency measures sampled agreement; confidently repeated errors can agree. Verbalized confidence is another model output, requiring a task-specific event definition and representative labeled evaluation. Do not rank these signals universally or treat post-training methods as automatically destroying every notion of calibration.

What an interviewer expects you to say

State the event, evaluated population, fitting/evaluation split, sample counts, and downstream decision rule.

Common confusions

Accuracy, discrimination, calibration, and decision cost answer different questions. Predictive intervals also have coverage notions; proper distributional scores such as CRPS measure more than calibration alone. Top-label calibration does not certify every class probability or subgroup.

Why interviewers ask

For a frozen argmax-only action, shared positive temperature leaves that action unchanged. Abstention, thresholds, and expected-cost policies can depend on the changed probabilities.


Related: decision thresholds, asymmetric costs, and abstention, How would you evaluate an LLM application?, and How do you handle hallucinations in production?.