Expected calibration error

Also known as: ECE

On this page 7

Expected calibration error (ECE) is a metric that measures the average gap between a model’s confidence and its actual accuracy, computed by grouping predictions into confidence bins and taking a weighted mean of the absolute differences. A perfectly calibrated classifier has an ECE of zero: among all predictions made with 80 percent confidence, exactly 80 percent are correct.

Model evaluation in artificial intelligence has traditionally focused on whether predictions are right. ECE answers a different question: whether the stated probabilities can be trusted. This matters wherever a score drives a decision, such as triage in medicine, abstention in language models or risk thresholds in finance, because an overconfident model looks equally sure when it is wrong.

How expected calibration error is computed

ECE is computed from a held-out set of predictions in four steps. The standard version uses the top-label confidence, which is the highest predicted class probability, and compares it with whether that predicted class was correct.

  1. For each of n examples, record the confidence of the predicted class and whether the prediction was correct.
  2. Split the interval from 0 to 1 into M bins, most often 15 equal-width bins.
  3. For each bin, compute the mean confidence and the accuracy of the examples that fall into it.
  4. Sum the absolute differences between accuracy and confidence, each weighted by the bin’s share of examples.

In formula form, ECE equals the sum over bins of (|B_m| / n) * |acc(B_m) - conf(B_m)|. The result is usually reported as a percentage between 0 and 100. Values below about 2 percent are generally considered well calibrated for image classifiers, while uncalibrated deep networks often show 5 to 15 percent, although these ranges depend on the task, the number of classes and the binning scheme.

The bins are the same ones drawn in a reliability diagram, which plots accuracy against confidence. ECE condenses that diagram into one number: it measures how far the bars deviate from the diagonal, weighted by how many predictions each bar contains.

Variants of the calibration metric

Because the basic estimator has known weaknesses, several variants of ECE are in common use. Reporting which variant was used is essential, since numbers from different variants are not comparable.

VariantWhat changesWhen it helps
Equal-width ECEFixed bins of equal widthStandard baseline in most papers
Adaptive ECEBins hold equal numbers of examplesConfidence clusters near 1.0
Maximum calibration errorWorst bin instead of weighted meanSafety-critical settings
Classwise ECEComputed per class and averagedRare classes matter
Smooth or kernel ECEKernel estimate replaces hard binsSmall evaluation sets
Common calibration error variants

Modern networks place most predictions above 0.9 confidence, so equal-width bins leave many bins nearly empty. Equal-mass binning spreads examples evenly and usually gives a more stable estimate with lower variance.

How ECE relates to other evaluation metrics

ECE measures calibration only, not overall predictive quality. It should be read together with accuracy and a proper scoring rule such as the Brier score or log loss, which reward both calibration and the ability to separate classes.

MetricWhat it measuresKey property
Expected calibration errorConfidence-accuracy gapNot a proper scoring rule
Brier scoreMean squared error of probabilitiesProper; mixes calibration and sharpness
Negative log-likelihoodLog loss on true labelsProper; punishes confident errors heavily
AccuracyShare of correct predictionsIgnores probability values
AUCRanking quality across thresholdsUnaffected by monotonic recalibration
ECE compared with related metrics

The most important caveat follows from the first row: a model that always predicts the base rate can reach an ECE near zero while being useless. A low ECE never proves a good model; it only shows that the confidence values mean what they say.

Reducing calibration error in practice

Calibration is usually improved after training with a small held-out calibration set, without retraining the model. The simplest and most widely used method is temperature scaling, which divides the logits by one learned scalar.

MethodHow it worksTrade-off
Temperature scalingDivides logits by one fitted valueKeeps accuracy; limited flexibility
Platt scalingFits a logistic curve to scoresSuited to binary tasks
Isotonic regressionFits a monotone step functionFlexible but needs more data
Histogram binningReplaces scores with bin accuracyCoarse probability output
Label smoothing in trainingSoftens training targetsCan hurt later recalibration
Calibration methods and their trade-offs

Temperature scaling does not change the ranking of classes, so accuracy stays the same while ECE often drops by a large margin. Calibration methods must be fitted on data separate from the test set; otherwise the reported ECE is optimistically biased.

Limitations and common mistakes

ECE is easy to compute but also easy to misread. Several pitfalls appear repeatedly in published evaluations.

  • Bin sensitivity: changing the number of bins from 10 to 20 can change the value noticeably and even reverse model rankings.
  • Small-sample bias: with few examples per bin, the estimator is biased upward, so small test sets overstate miscalibration.
  • Top-label blindness: standard ECE ignores the probabilities of non-predicted classes.
  • Distribution shift: a model calibrated on validation data can become overconfident on shifted inputs.
  • Undocumented settings: results without the bin count and binning scheme cannot be reproduced.

For language models, ECE can be computed on answer probabilities or on verbalized confidence, but the two often disagree. Instruction-tuned and preference-tuned models are frequently less calibrated than their base models, which makes calibration a standard check in LLM evaluation.

The simple explanation

Imagine a weather forecaster who says there is a 70 percent chance of rain. If it rains on about 70 of every 100 such days, the forecaster is well calibrated. If it rains on only 40 of them, the forecaster is too confident.

Expected calibration error checks the same thing for an AI model. It groups the answers by how sure the model claimed to be. Then it compares that with how often the model was right. The result is one number for the gap. Zero means the model’s confidence can be taken at face value.

How it is used in practice

A hospital team evaluates an image classifier that flags suspicious skin lesions for review. On a held-out set of 5,000 images, the model reaches 91 percent accuracy, but its 15-bin ECE is 8.4 percent: predictions made with 95 percent confidence are correct only about 84 percent of the time.

The team fits temperature scaling on a separate calibration set of 1,000 images. Accuracy stays at 91 percent, while ECE falls to 1.6 percent and the reliability diagram moves close to the diagonal. Clinicians can now rely on the scores to set a referral threshold, sending every case below 90 percent confidence to a dermatologist. The team also checks ECE on images from a second clinic to detect calibration loss under distribution shift before deployment.