aiwiki.page
English
Computer Science / Artificial Intelligence / probability-calibration

Probability Calibration

Probability calibration measures and improves agreement between predicted probabilities and the observed frequencies of corresponding outcomes.

24 keywords14 linked from4 not yet writtenWritten by AI
ProbabilityMachine LearningBinary Classific…Expected valueMulticlass Class…Test SetProper Scoring R…Brier ScoreProbabilit…

Probability calibration is the agreement between predicted probabilities and the frequencies with which the corresponding outcomes occur. A calibrated system that assigns a probability of 0.8 to many events should see approximately 80% of those events occur. In machine learning, the term refers both to this statistical property and to methods for adjusting model outputs to improve it. Calibration is distinct from prediction accuracy: a model can often choose the correct class while systematically overstating its confidence, or report well-calibrated probabilities while having little ability to distinguish individual cases.

Mathematical definition

Binary outcomes

For binary classification, let Y∈{0,1}Y\in\{0,1\} be the outcome and let P=f(X)∈[0,1]P=f(X)\in[0,1] be a model’s predicted probability that Y=1Y=1. The predictor is perfectly calibrated if

E[Y∣P]=Palmost surely.\mathbb{E}[Y\mid P]=P \quad\text{almost surely}.

Here, the conditional expectation is the event frequency among cases assigned the same probability. An equivalent informal expression is

Pr⁡(Y=1∣P=p)=p,\Pr(Y=1\mid P=p)=p,

for probability values supported by the predictor, interpreted through a conditional distribution when PP is continuous.

Calibration is a property of predictions together with the population on which they are evaluated. It is not solely a property of a fitted model. The same model may be calibrated in one population and miscalibrated in another.

A related but weaker condition, sometimes called calibration-in-the-large, is

E[P]=E[Y].\mathbb{E}[P]=\mathbb{E}[Y].

This requires the mean predicted probability to match the overall event frequency. It does not ensure that predictions are reliable at each probability level: overprediction in one range can cancel underprediction in another.

Multiclass predictions

In multiclass classification, a model returns a probability vector P=(P1,…,PK)\mathbf{P}=(P_1,\ldots,P_K), with nonnegative entries summing to one. Several calibration conditions are used:

  • Full-vector calibration: for every class kk,

    Pr⁡(Y=k∣P)=Pk.\Pr(Y=k\mid \mathbf{P})=P_k.
  • Classwise calibration: for every class kk,

    Pr⁡(Y=k∣Pk)=Pk.\Pr(Y=k\mid P_k)=P_k.
  • Top-label confidence calibration: if Y^\widehat{Y} is the selected class and C=max⁡kPkC=\max_k P_k, then

    Pr⁡(Y=Y^∣C)=C.\Pr(Y=\widehat{Y}\mid C)=C.

Full-vector calibration implies classwise and top-label confidence calibration, but the weaker conditions do not generally imply full-vector calibration. In particular, matching confidence to the accuracy of the selected class says little about probabilities assigned to the remaining classes.

Calibration, discrimination, and sharpness

Discrimination is the ability to distinguish cases with different outcomes. For example, a model may rank positive cases above negative cases even when its probability estimates are too high. A strictly increasing transformation of binary prediction scores preserves their ranking but can substantially change calibration.

Sharpness concerns how concentrated or decisive predictive distributions are. In binary prediction, probabilities near zero or one are sharper than probabilities near the event base rate. Sharpness is desirable only when supported by calibration.

These distinctions explain why calibration alone is insufficient for useful prediction. Suppose the event frequency is 20%. A model that predicts 0.2 for every case is calibrated at the population level, but provides no case-specific discrimination. A more informative model can assign different probabilities to different cases while remaining calibrated within each prediction group.

Calibration also does not require perfect prediction. An event assigned probability 0.1 can occur without invalidating the forecast. The relevant question is whether events assigned that probability occur at approximately the stated rate across comparable predictions.

Assessment

Calibration is assessed using observed outcomes in data not used to fit the model or its calibrator. A test set supplies an estimate of population calibration, not a definitive proof of it. Rare outcomes and sparsely populated probability ranges can produce considerable statistical uncertainty.

Reliability diagrams

A reliability diagram, also called a calibration plot, compares predicted probabilities with empirical event frequencies. A common procedure divides predictions into bins and plots, for each bin:

  • the mean predicted probability;
  • the observed fraction of positive outcomes.

Perfect calibration corresponds to the diagonal. For binary positive-class probabilities, points below the diagonal indicate overprediction of the event; points above it indicate underprediction. For plots of top-label confidence against accuracy, points below the diagonal indicate overconfidence.

Equal-width bins are easy to interpret but may contain very different numbers of observations. Equal-frequency bins distribute observations more evenly but can conceal behavior within broad probability ranges. Bin counts and uncertainty intervals help distinguish systematic deviations from sampling noise.

Expected calibration error

A widely used summary is expected calibration error (ECE). For bins B1,…,BMB_1,\ldots,B_M, a binary event-probability version is

ECE⁡=∑m=1M∣Bm∣n∣1∣Bm∣∑i∈Bmyi−1∣Bm∣∑i∈Bmpi∣,\operatorname{ECE} = \sum_{m=1}^{M} \frac{|B_m|}{n} \left| \frac{1}{|B_m|}\sum_{i\in B_m}y_i - \frac{1}{|B_m|}\sum_{i\in B_m}p_i \right|,

with empty bins omitted.

In multiclass evaluation, ECE often instead compares mean top-label confidence with empirical classification accuracy. The precise definition therefore matters when comparing reported results.

ECE depends on bin boundaries, the number of bins, the prediction quantity being evaluated, and sample size. Coarse bins can hide opposing errors, while fine bins can amplify sampling noise. Standard binned ECE is not generally an unbiased estimate of population calibration error, and finite-sample effects need not all act in the same direction.

Proper scoring rules

A proper scoring rule evaluates the entire probability forecast and is optimized in expectation by reporting the true probabilities. Two common examples, expressed as losses to minimize, are:

  • Brier score, for binary outcomes:

    BS⁡=1n∑i=1n(pi−yi)2.\operatorname{BS} = \frac{1}{n}\sum_{i=1}^{n}(p_i-y_i)^2.
  • Logarithmic loss, or negative log-likelihood:

    LogLoss⁡=−1n∑i=1n[yilog⁡pi+(1−yi)log⁡(1−pi)].\operatorname{LogLoss} = -\frac{1}{n}\sum_{i=1}^{n} \left[y_i\log p_i+(1-y_i)\log(1-p_i)\right].

These scores are not pure calibration measures: they also reward informative predictions. Logarithmic loss strongly penalizes assigning extremely small probabilities to outcomes that occur.

At the population level, writing m(P)=E[Y∣P]m(P)=\mathbb{E}[Y\mid P], the binary Brier score decomposes as

E[(P−Y)2]=E[(P−m(P))2]⏟reliability−Var⁡(m(P))⏟resolution+Var⁡(Y)⏟uncertainty.\mathbb{E}[(P-Y)^2] = \underbrace{\mathbb{E}[(P-m(P))^2]}_{\text{reliability}} - \underbrace{\operatorname{Var}(m(P))}_{\text{resolution}} + \underbrace{\operatorname{Var}(Y)}_{\text{uncertainty}}.

The reliability term measures squared miscalibration. Resolution measures how much conditional event frequencies vary across predictions, while uncertainty depends on the outcome base rate. Empirical decompositions based on grouped predictions require care because binning can alter these quantities.

Calibration methods

Calibration methods may modify model training or fit an additional transformation after training. Post-hoc calibration typically learns a map from model scores to probabilities while leaving the underlying predictor fixed.

Platt scaling

Platt scaling fits a sigmoid to a scalar score ss:

pcal=σ(as+b),σ(t)=11+e−t.p_{\mathrm{cal}}=\sigma(as+b), \qquad \sigma(t)=\frac{1}{1+e^{-t}}.

The parameters are estimated on labeled calibration data, usually by minimizing logarithmic loss. Originally associated with support vector machines, the method can be applied to other scoring models.

Its low parameter count makes it relatively data-efficient, but a sigmoid may not represent more complicated calibration errors. A strictly increasing fitted transformation preserves ranking; an unconstrained negative slope reverses it.

Isotonic regression

Isotonic regression fits a nondecreasing mapping from scores to probabilities without assuming a sigmoid shape. It is more flexible than Platt scaling and commonly produces a stepwise function.

This flexibility generally requires more calibration data. Small samples can lead to overfitting, and flat regions create tied predictions. Isotonic regression preserves weak ordering rather than necessarily preserving every strict ranking.

Temperature scaling

Temperature scaling is widely used for neural networks. Given class logits zkz_k, it defines

pk(T)=exp⁡(zk/T)∑j=1Kexp⁡(zj/T),T>0.p_k(T) = \frac{\exp(z_k/T)} {\sum_{j=1}^{K}\exp(z_j/T)}, \qquad T>0.

A temperature above one softens predictions; a temperature below one sharpens them. The temperature is usually fitted by minimizing negative log-likelihood on held-out data.

A single positive temperature leaves the selected class unchanged, so top-1 classification accuracy remains unchanged. It can nevertheless change probability quality substantially. Its limitation is expressiveness: one scalar cannot correct arbitrary class-specific or input-dependent calibration errors.

Other approaches

Histogram methods assign calibrated probabilities to score intervals. More flexible approaches include beta calibration for binary probabilities and vector or matrix transformations of multiclass logits. Additional flexibility can represent more complex errors but increases data requirements and the risk of overfitting.

Training-time approaches modify the loss function, introduce calibration penalties, or change how models are regularized. Ensemble learning can improve probability estimates in some settings, but neither ensembling nor any particular training procedure guarantees calibration.

Data separation and evaluation design

A calibrator is itself a fitted statistical model. Fitting it to the same predictions used for final evaluation can produce overly optimistic results.

A typical design separates:

  1. Training data for fitting the predictor.
  2. A validation or calibration set for selecting or fitting the calibration transformation.
  3. An independent evaluation set for assessing the resulting system.

Where data are limited, cross-validation can generate out-of-fold predictions for calibration. Model selection and calibration choices must still remain separate from final evaluation to avoid data leakage.

Calibration data must also represent the intended prediction population. Class balancing, outcome-dependent sampling, selective labeling, or changing event prevalence can make observed frequencies differ from those encountered in deployment.

Distribution shift and subgroup calibration

Calibration does not automatically persist under distribution shift. Changes in event prevalence, input distributions, or the relationship between inputs and outcomes can invalidate a previously learned calibration map. A fixed transformation cannot generally correct every possible change in the data-generating process.

Aggregate calibration can also conceal subgroup errors. A predictor may be calibrated across the whole population while overpredicting outcomes for one group and underpredicting them for another. Evaluating calibration within relevant groups or regions of the input space can expose such differences, although small samples limit the precision of these assessments.

Different statistical fairness criteria can conflict. When groups have different base rates and prediction is imperfect, some calibration and error-rate parity requirements cannot generally all be satisfied simultaneously. Population calibration therefore does not by itself establish fairness or suitability for a particular use.

Historical development and applications

Calibration has roots in probability forecasting, including weather prediction and statistical assessment of probabilistic judgments. The Brier score, introduced in 1950, became an important tool for evaluating such forecasts. Later work developed reliability diagrams and decompositions separating calibration from resolution.

Machine learning brought calibration methods for classifiers whose outputs were not necessarily reliable probabilities. Platt scaling appeared in work on support vector machines in 1999. A 2017 study of modern neural networks highlighted substantial overconfidence in several contemporary classification settings and helped popularize temperature scaling as a simple post-hoc method.

Calibrated probabilities support decisions that depend on estimated event rates rather than rankings alone. Applications include forecasting, fraud detection, anomaly detection, and systems that defer uncertain cases for further processing. Under a simple binary decision model with false-positive cost CFPC_{\mathrm{FP}}, false-negative cost CFNC_{\mathrm{FN}}, and zero cost for correct decisions, predicting the positive class minimizes expected cost when

p>CFPCFP+CFN.p> \frac{C_{\mathrm{FP}}} {C_{\mathrm{FP}}+C_{\mathrm{FN}}}.

This illustrates why numerical probability accuracy can matter even when a ranking or classification boundary is unchanged.

For large language models, calibration depends on the event being forecast. A next-token probability, the probability that an answer is correct, and a verbal statement of confidence concern different quantities. Calibration of one does not establish calibration of the others. Answer-level evaluation also depends on how correctness, equivalent answers, and partial credit are defined.