How do you calculate expected calibration error (ECE)?

Quick Overview

Explains how to compute expected calibration error by binning a classifier's predictions on confidence and comparing each bin's accuracy with its mean confidence. Tests understanding of calibration metrics, binning choices, and why ECE should be paired with a proper scoring rule.

How do you calculate expected calibration error (ECE)?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

How do you calculate expected calibration error (ECE)? Walk through the computation for a classifier that outputs probabilities, and say what the number does and does not tell you. ```hint Group the predictions Group predictions by how confident the model was, then ask what accuracy you would expect inside each group if the probabilities were honest. ``` ### What a Strong Answer Covers - Which confidence is used (top-class probability in multiclass, positive-class probability in binary) and how predictions are assigned to bins - Per-bin accuracy and mean confidence, and the sample-weighted average of their gaps - How binning choices (number of bins, equal-width versus equal-mass) change the estimate, and the noise from sparse bins - Why ECE is not a proper scoring rule and what to report next to it - The limit of top-label ECE for the non-top classes and the classwise alternative ### Follow-up Questions - Your model's confidences are almost all above 0.9. What goes wrong with 10 equal-width bins, and what would you change? - A model has an ECE close to zero. Why might it still be useless, and how would you show that? - ECE on the validation set is high. How would you fix the calibration without changing the model's ranking of examples? - How does classwise ECE differ from top-label ECE, and when does the difference matter?

Overview: Explains how to compute expected calibration error by binning a classifier's predictions on confidence and comparing each bin's accuracy with its mean confidence. Tests understanding of calibration metrics, binning choices, and why ECE should be paired with a proper scoring rule.

PracHub logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

How do you calculate expected calibration error (ECE)? Walk through the computation for a classifier that outputs probabilities, and say what the number does and does not tell you.

What a Strong Answer Covers Guidance

  • Which confidence is used (top-class probability in multiclass, positive-class probability in binary) and how predictions are assigned to bins
  • Per-bin accuracy and mean confidence, and the sample-weighted average of their gaps
  • How binning choices (number of bins, equal-width versus equal-mass) change the estimate, and the noise from sparse bins
  • Why ECE is not a proper scoring rule and what to report next to it
  • The limit of top-label ECE for the non-top classes and the classwise alternative

Follow-up Questions Guidance

  • Your model's confidences are almost all above 0.9. What goes wrong with 10 equal-width bins, and what would you change?
  • A model has an ECE close to zero. Why might it still be useless, and how would you show that?
  • ECE on the validation set is high. How would you fix the calibration without changing the model's ranking of examples?
  • How does classwise ECE differ from top-label ECE, and when does the difference matter?