Inferensys

Glossary

Expected Calibration Error (ECE)

Expected Calibration Error (ECE) is a primary metric for measuring model calibration by partitioning predictions into bins and computing the weighted average of the difference between accuracy and confidence in each bin.
Developer building agentic RAG system, retrieval pipeline diagram on laptop, technical workspace with notes.
CONFIDENCE CALIBRATION METRIC

What is Expected Calibration Error (ECE)?

Expected Calibration Error (ECE) is the primary empirical metric for quantifying a model's calibration by measuring the discrepancy between its stated confidence and its actual accuracy.

Expected Calibration Error (ECE) is a scalar summary statistic that measures the miscalibration of a probabilistic model. It is computed by partitioning all predictions into M equally spaced confidence bins, and then calculating the weighted average of the absolute difference between the model's accuracy and its average confidence within each bin. A perfectly calibrated model has an ECE of zero, meaning a prediction assigned a 70% confidence score is correct exactly 70% of the time.

The metric is formally defined as ECE = Σ (|B_m| / n) * |acc(B_m) - conf(B_m)|, where n is the total number of samples. While widely used for its intuitive simplicity, ECE is sensitive to the chosen binning scheme and can be biased by imbalanced datasets. It serves as a critical diagnostic for confidence calibration signals, directly informing whether a model's self-assessed certainty can be trusted in high-stakes, autonomous decision-making systems.

CALIBRATION METRICS

Key Characteristics of ECE

Expected Calibration Error (ECE) is the primary empirical metric for evaluating a model's calibration. It quantifies the discrepancy between a model's reported confidence and its actual accuracy by partitioning predictions into bins and computing a weighted average of the absolute difference within each bin.

01

The Binning Mechanism

ECE operates by sorting all predictions into M equally-spaced confidence bins (e.g., 0-10%, 10-20%). For each bin, it calculates the absolute difference between the average confidence and the observed accuracy. The final ECE is the weighted average of these gaps, where the weight is the proportion of samples in each bin. A perfectly calibrated model has an ECE of 0.

02

Reliability Diagrams

ECE is most often visualized through a reliability diagram, which plots accuracy against confidence. Key features:

  • Perfect calibration appears as a diagonal line (y=x)
  • Overconfidence manifests as points below the diagonal (high confidence, low accuracy)
  • Underconfidence shows points above the diagonal
  • The ECE value is the weighted area between the plotted curve and the diagonal
03

Mathematical Formulation

ECE is formally defined as: ECE = Σ (|B_m| / n) * |acc(B_m) - conf(B_m)|

Where:

  • B_m is the set of samples in bin m
  • n is the total number of samples
  • acc(B_m) is the empirical accuracy in bin m
  • conf(B_m) is the average predicted probability in bin m

This formulation ensures that bins with more samples contribute proportionally more to the final error score.

04

Limitations and Pathologies

Despite its widespread use, ECE has known weaknesses:

  • Fixed binning bias: The choice of bin count (typically 10 or 15) is arbitrary and affects the score
  • Class imbalance blindness: ECE can be misleadingly low on highly imbalanced datasets where a model predicts the majority class with high confidence
  • No sharpness measure: ECE only measures calibration, not the usefulness of the probability estimates (a model predicting the base rate for every sample has perfect ECE but zero utility)
  • Adaptive variants like AdaECE and Classwise ECE have been proposed to address these issues
05

Relationship to Proper Scoring Rules

ECE is a measure of calibration error, not a proper scoring rule. It should be used alongside metrics like:

  • Brier Score: Decomposes into calibration and refinement components
  • Negative Log-Likelihood (NLL): A strictly proper scoring rule that penalizes both poor calibration and poor discrimination
  • Expected Normalized Calibration Error (ENCE): A regression-specific adaptation

While ECE is intuitive and widely reported, proper scoring rules provide a more theoretically grounded evaluation of probabilistic predictions.

06

Modern Mitigation: Temperature Scaling

The most effective post-hoc calibration method for reducing ECE in neural networks is temperature scaling, a single-parameter variant of Platt scaling. It works by:

  • Dividing all logits by a scalar temperature T before the softmax
  • T > 1 softens probabilities, reducing overconfidence
  • T < 1 sharpens probabilities, reducing underconfidence
  • The optimal T is found by minimizing NLL on a held-out validation set

Crucially, temperature scaling does not affect the model's accuracy or rank-ordering of predictions—it only recalibrates the confidence scores.

CONFIDENCE CALIBRATION

Frequently Asked Questions

Explore the core concepts behind Expected Calibration Error (ECE), the primary metric for evaluating the reliability of probabilistic predictions in machine learning models.

Expected Calibration Error (ECE) is a primary metric for measuring model calibration by partitioning predictions into bins and computing the weighted average of the difference between accuracy and confidence in each bin. The calculation involves a discrete approximation: predictions are sorted and divided into M equal-width interval bins (e.g., 10 bins representing 0-10% confidence, 10-20%, etc.). For each bin B_m, the average confidence and the actual accuracy are calculated. The ECE is the weighted average of the absolute difference between these two values across all bins, where the weight is the proportion of samples in that bin. A perfectly calibrated model has an ECE of 0, meaning its confidence matches its accuracy exactly. A high ECE indicates overconfidence (confidence > accuracy) or underconfidence (accuracy > confidence). This metric is critical for risk-sensitive applications like medical diagnosis and autonomous driving, where a model's self-assessment of uncertainty must be trustworthy.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.