Expected Calibration Error (ECE) is a scalar summary statistic that computes the weighted average of the absolute difference between a model's accuracy and its confidence across M discrete, equal-width probability bins. It approximates the miscalibration of a model by partitioning predictions into bins (e.g., 0-10%, 10-20%) and comparing the average confidence within each bin to the fraction of correctly classified samples.
Glossary
Expected Calibration Error (ECE)

What is Expected Calibration Error (ECE)?
The primary empirical metric for quantifying the miscalibration of a probabilistic classifier by measuring the discrepancy between predicted confidence and observed accuracy.
A perfectly calibrated model yields an ECE of zero, meaning a prediction assigned 70% confidence is correct exactly 70% of the time. While ECE is widely used for evaluating modern neural networks, it is sensitive to the chosen binning scheme and does not distinguish between overconfidence and underconfidence, requiring complementary diagnostics like the Reliability Diagram for a complete calibration assessment.
Key Properties of ECE
Expected Calibration Error (ECE) decomposes the reliability of a model's probability estimates into a single, interpretable scalar. It measures the gap between what a model thinks it knows and what it actually knows.
The Binning Mechanism
ECE partitions the probability space into M equal-width bins (e.g., [0, 0.1), [0.1, 0.2), ..., [0.9, 1.0]). For each bin, it calculates the absolute difference between the average confidence of predictions in that bin and the empirical accuracy within that bin. The final ECE is the weighted average of these gaps, where the weight is the proportion of samples falling into each bin.
- Bin Count (M): A hyperparameter, typically set to 10, 15, or 20. Too few bins mask miscalibration; too many create noisy, empty bins.
- Weighting: Heavily influenced by the model's native confidence distribution. A model that pushes most predictions above 0.9 will have its ECE dominated by the highest bin.
ECE vs. Proper Scoring Rules
ECE is a non-proper scoring rule, meaning its minimum is not uniquely achieved by the true conditional probability distribution. A model that is perfectly calibrated (ECE=0) can still be useless if it never separates classes (e.g., always predicting the base rate). In contrast, Brier Score and Negative Log-Likelihood (NLL) are proper scoring rules that decompose into a calibration component and a refinement component.
- Refinement Loss: ECE ignores this; it only cares about the calibration gap, not the model's ability to discriminate between classes.
- Diagnostic Pairing: Always report ECE alongside a proper scoring rule like NLL or Brier Score to get a complete picture of model quality.
Static vs. Adaptive Binning
The standard ECE implementation uses static, equal-width bins, which can be problematic when a model concentrates predictions in a narrow confidence range (e.g., all predictions between 0.8 and 1.0). Adaptive ECE variants address this by defining bins that each contain an equal number of samples, ensuring no bin is empty and the metric is computed over a statistically meaningful population in every region.
- Equal-Width ECE: Simple, interpretable, but sensitive to the bin count M.
- Equal-Mass ECE: More robust to skewed confidence distributions, ensuring each bin contributes equally to the final metric.
- Debiased ECE: Applies a statistical correction to remove the systematic bias introduced by finite sample sizes within each bin.
Multiclass ECE Formulation
For multiclass problems, ECE is typically computed using the top-label or confidence-only paradigm. The prediction is considered correct if the top predicted class matches the true label, and the confidence is the associated softmax probability. This ignores the calibration of the non-maximal class probabilities.
- Top-Label ECE: Measures if the model's "I'm sure this is class A" statement is reliable.
- Classwise ECE: A stricter metric that computes the calibration error for each class independently and averages them. This catches miscalibration in minority classes that top-label ECE might miss.
- Threshold: A model with perfect top-label ECE can still be poorly calibrated for individual class probabilities.
Root Cause: Overconfidence
Modern neural networks trained with standard cross-entropy loss almost universally exhibit positive miscalibration as measured by ECE. They are systematically overconfident—their predicted probability (e.g., 0.99) is higher than their actual accuracy (e.g., 0.94). This is visualized on a Reliability Diagram as a curve lying below the identity diagonal.
- Culprits: Weight decay, batch normalization, and the inherent capacity of deep networks to memorize training labels all contribute to overconfidence.
- Remedy: Post-hoc methods like Temperature Scaling directly target this gap by softening the softmax distribution, often reducing ECE by an order of magnitude with a single scalar parameter.
Computational Definition
Formally, ECE is defined as: ECE = Σ (|B_m| / n) * |acc(B_m) - conf(B_m)|, where n is the total number of samples, B_m is the set of indices for samples whose predicted confidence falls into interval I_m, acc(B_m) is the fraction of correct predictions in that bin, and conf(B_m) is the average confidence in that bin.
- Range: ECE is bounded between 0 and 1, where 0 represents perfect calibration.
- Implementation: A concise implementation requires only a few lines of code using NumPy or PyTorch, making it a lightweight addition to any evaluation pipeline.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about Expected Calibration Error and its role in building trustworthy machine learning models.
Expected Calibration Error (ECE) is a primary scalar metric for measuring the calibration of a classification model, quantifying the discrepancy between a model's predicted confidence and its actual empirical accuracy. It is calculated by partitioning all predictions into M equally-spaced confidence bins (e.g., 0-0.1, 0.1-0.2, ..., 0.9-1.0). For each bin B_m, the absolute difference between the bin's average accuracy and average confidence is computed. The final ECE is the weighted average of these differences, where each bin's contribution is weighted by the proportion of total samples falling into that bin. Formally, ECE = Σ (|B_m|/n) * |acc(B_m) - conf(B_m)|. A perfectly calibrated model has an ECE of 0, meaning a prediction made with 70% confidence is correct exactly 70% of the time. Lower ECE values indicate better calibration, with the metric being particularly sensitive to overconfidence in high-probability bins.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Mastering ECE requires understanding the broader ecosystem of calibration metrics, visual diagnostics, and post-hoc correction techniques. These related concepts form the essential toolkit for building models that know what they know.
Reliability Diagram
The primary visual diagnostic for calibration that directly complements ECE. Predictions are partitioned into M equal-width bins (typically 10-15), and the mean predicted probability per bin is plotted against the observed fraction of positives. A perfectly calibrated model follows the identity diagonal (y=x). Deviations above the diagonal indicate underconfidence; deviations below indicate overconfidence. The gap between the curve and the diagonal at each bin is precisely what ECE quantifies as a weighted average.
Temperature Scaling
The simplest and most effective post-hoc calibration method for neural networks. A single scalar parameter T > 0 is learned on a held-out validation set to divide all logits before the softmax:
- T > 1: Softens probabilities, fixing overconfidence
- T < 1: Sharpens probabilities, fixing underconfidence
- T = 1: Original probabilities unchanged Because it's a monotonic transformation, it preserves accuracy and the rank order of predictions while dramatically reducing ECE. It is the default first-line treatment for miscalibrated deep networks.
Brier Score
A strictly proper scoring rule that decomposes into calibration and refinement components. Defined as the mean squared error between predicted probability and binary outcome:
- Range: 0 (perfect) to 1 (worst)
- Penalizes both calibration errors and discrimination failures
- Unlike ECE, which only measures calibration, the Brier Score rewards models that are both calibrated and confident in the right places
- A low ECE does not guarantee a low Brier Score if the model lacks discriminative power
Proper Scoring Rule
A loss function that is minimized only when the predicted distribution equals the true distribution, incentivizing honest probability estimates. Key properties:
- Negative Log-Likelihood (NLL) and Brier Score are strictly proper
- Accuracy and ECE are improper—they can be optimized by dishonest forecasts
- Training with a proper scoring rule naturally encourages calibration
- The theoretical foundation for why models should output true probabilities rather than just correct class labels
Classwise Calibration
A stricter multiclass calibration criterion that ECE's standard definition does not capture. Standard ECE only checks if the maximum predicted probability matches accuracy. Classwise calibration requires that for every class k, when the model predicts P(y=k) = p, the true frequency of class k is also p. A model can achieve near-zero ECE while being severely miscalibrated on minority classes. Classwise ECE (CW-ECE) extends the binning approach to each class independently.
Selective Classification
An inference paradigm that operationalizes calibration by allowing models to abstain on uncertain predictions. A confidence threshold is set, and predictions below it are rejected (handled by a human or fallback system). The Risk-Coverage Curve plots error rate against the fraction of accepted predictions. Key metrics:
- AURC (Area Under Risk-Coverage Curve): Summary statistic
- E-AURC: Excess AURC over the optimal classifier
- Directly connects ECE reduction to business value by controlling the accuracy-coverage trade-off

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us