{"id":1793,"date":"2025-02-12T07:02:29","date_gmt":"2025-02-12T07:02:29","guid":{"rendered":"https:\/\/mailitics.com\/index.php\/2025\/02\/12\/understanding-model-calibration-a-gentle-introduction-visual-exploration\/"},"modified":"2025-02-12T07:02:29","modified_gmt":"2025-02-12T07:02:29","slug":"understanding-model-calibration-a-gentle-introduction-visual-exploration","status":"publish","type":"post","link":"https:\/\/mailitics.com\/index.php\/2025\/02\/12\/understanding-model-calibration-a-gentle-introduction-visual-exploration\/","title":{"rendered":"Understanding Model Calibration: A Gentle Introduction &amp; Visual Exploration"},"content":{"rendered":"\n<div>Understanding Model Calibration: A Gentle Introduction &#038; Visual Exploration<\/div>\n<p> \t<BR><br \/>\n<BR><\/BR><br \/>\n    <!-- no image --><br \/>\n \t<BR><br \/>\n<BR><\/BR><\/p>\n<div>\n<h2 class=\"wp-block-heading\">\n<strong>How Reliable Are Your Predictions?<\/strong><strong><\/strong><br \/>\n<\/h2>\n<h3 class=\"wp-block-heading\">\n<strong>About<\/strong><strong><\/strong><br \/>\n<\/h3>\n<p class=\"wp-block-paragraph\">To be considered reliable, a model must be calibrated so that its confidence in each decision closely reflects its true outcome. In this blog post we\u2019ll take a look at the most commonly used definition for calibration and then dive into a frequently used evaluation measure for <a href=\"https:\/\/towardsdatascience.com\/tag\/model-calibration\/\" title=\"Model Calibration\">Model Calibration<\/a>. We\u2019ll then cover some of the drawbacks of this measure and how these surfaced the need for additional notions of calibration, which require their own new evaluation measures. This post is not intended to be an in-depth dissection of all works on calibration, nor does it focus on how to calibrate models. Instead, it is meant to provide a gentle introduction to the different notions and their evaluation measures as well as to re-highlight some issues with a measure that is still widely used to evaluate calibration.<\/p>\n<h3 class=\"wp-block-heading\"><strong>Table of Contents<\/strong><\/h3>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\"><strong><a href=\"https:\/\/towardsdatascience.com\/#calibration\">What is Calibration?<\/a><\/strong><\/li>\n<li class=\"wp-block-list-item\"><strong><a href=\"https:\/\/towardsdatascience.com\/#Evaluating\">Evaluating Calibration\u200a\u2014\u200aExpected Calibration Error (ECE)<\/a><\/strong><\/li>\n<li class=\"wp-block-list-item\"><strong><a href=\"https:\/\/towardsdatascience.com\/#Drawbacks\">Most frequently mentioned Drawbacks of ECE<\/a><\/strong><\/li>\n<li class=\"wp-block-list-item\"><strong><a href=\"https:\/\/towardsdatascience.com\/#Multiclass\">Other definitions of Calibration<\/a><\/strong><\/li>\n<li class=\"wp-block-list-item\"><strong><a href=\"https:\/\/towardsdatascience.com\/#summary\">Summary<\/a><\/strong><\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"Calibration\"><strong>What is Calibration?<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">Calibration makes sure that a model\u2019s estimated probabilities match real-world outcomes. <em>For example, if a weather forecasting model predicts a 70% chance of rain on several days, then roughly 70% of those days should actually be rainy for the model to be considered well calibrated.<\/em> This makes model predictions more <em>reliable<\/em> and <em>trustworthy<\/em>, which makes calibration relevant for many applications across various domains.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"f8f9f9\" data-has-transparency=\"false\" style=\"--dominant-color: #f8f9f9;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"474\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i1_reliability_diagram-1024x474.png?resize=1024%2C474&#038;ssl=1\" alt=\"\" class=\"wp-image-597698 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i1_reliability_diagram-1024x474.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i1_reliability_diagram-300x139.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i1_reliability_diagram-768x356.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i1_reliability_diagram-1536x711.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i1_reliability_diagram.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Reliability Diagram\u200a\u2014\u200a image by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Now, what <strong>calibration<\/strong> means more precisely depends on the specific definition being considered. We will have a look at the most common notion in machine learning (ML) formalised by Guo and termed <strong><em>confidence calibration<\/em><\/strong> by Kull. But first, let\u2019s define a bit of formal notation for this blog.\u00a0<\/p>\n<p class=\"wp-block-paragraph\">In this blog post we consider a classification task with <strong><em>K<\/em><\/strong> possible classes, with labels <strong><em>Y <\/em><\/strong>\u2208 {<strong>1<\/strong>, \u2026, <strong><em>K<\/em><\/strong>} and a classification model <strong><em>p\u0302<\/em> <\/strong>:<em>\ud835\udd4f<\/em> <strong>\u2192 \u0394\u1d37<\/strong>, that takes inputs in <em>\ud835\udd4f (e.g. an image or text)<\/em> and returns a probability vector as its output. <strong>\u0394\u1d37 <\/strong>refers to the <em>K<\/em>-simplex, which just means that the output vector must sum to 1 and that each estimated probability in the vector is between 0 &amp; 1. These individual probabilities<em> (or confidences)<\/em> indicate how likely an input belongs to each of the <strong><em>K<\/em><\/strong> classes.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"e4e8ef\" data-has-transparency=\"false\" style=\"--dominant-color: #e4e8ef;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"443\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i2_notation_updated-1024x443.png?resize=1024%2C443&#038;ssl=1\" alt=\"\" class=\"wp-image-597699 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i2_notation_updated-1024x443.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i2_notation_updated-300x130.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i2_notation_updated-768x332.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i2_notation_updated-1536x665.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i2_notation_updated.png 1786w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Notation\u200a\u2014\u200aimage by author\u200a\u2014\u200ainput example sourced from <a href=\"https:\/\/www.jair.org\/index.php\/jair\/article\/view\/12752\/26751\">Uma<\/a><\/figcaption><\/figure>\n<h3 class=\"wp-block-heading\">\n<strong>1.1 (Confidence) Calibration<\/strong><strong><\/strong><br \/>\n<\/h3>\n<p class=\"wp-block-paragraph\">A model is considered confidence-calibrated if, for all confidences <strong><em>c<\/em>,<\/strong> the model is correct <strong><em>c <\/em><\/strong>proportion of the time:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"eeeeee\" data-has-transparency=\"false\" style=\"--dominant-color: #eeeeee;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"39\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F1-1024x39.png?resize=1024%2C39&#038;ssl=1\" alt=\"\" class=\"wp-image-597701 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F1-1024x39.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F1-300x11.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F1-768x29.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F1.png 1153w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><\/figure>\n<p class=\"wp-block-paragraph\">where (X,Y) is a datapoint and p\u0302 : \ud835\udd4f \u2192 \u0394\u1d37 returns a probability vector as its output<\/p>\n<p class=\"wp-block-paragraph\">This definition of calibration, ensures that the model\u2019s final predictions align with their observed accuracy at that confidence level. The left chart below visualises the perfectly calibrated outcome <em>(green diagonal line)<\/em> for all confidences using a binned reliability diagram. On the right hand side it shows two examples for a specific confidence level across 10 samples.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"cfd8e3\" data-has-transparency=\"false\" style=\"--dominant-color: #cfd8e3;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"410\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i3_confidence_calibration-1024x410.png?resize=1024%2C410&#038;ssl=1\" alt=\"\" class=\"wp-image-597702 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i3_confidence_calibration-1024x410.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i3_confidence_calibration-300x120.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i3_confidence_calibration-768x308.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i3_confidence_calibration-1536x615.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i3_confidence_calibration.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Confidence Calibration \u200a\u2014\u200a image by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">For simplification, we assume that we only have 3 classes as in image 2 (Notation) and we zoom into confidence <strong><em>c=0.7<\/em><\/strong>, see image above. Let\u2019s assume we have 10 inputs here whose most confident prediction (<em>max<\/em>) equals<strong><em> 0.7<\/em><\/strong>. If the model correctly classifies 7 out of 10 predictions (<em>true<\/em>), it is considered calibrated at confidence level 0.7. For the model to be fully calibrated this has to hold across all confidence levels from 0 to 1. At the same level c=0.7, a model would be considered miscalibrated if it makes only 4 correct predictions.<\/p>\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dotted\">\n<h3 class=\"wp-block-heading\" id=\"Evaluating\">\n<strong>2 Evaluating Calibration\u200a\u2014\u200aExpected Calibration Error (ECE)<\/strong><strong><\/strong><br \/>\n<\/h3>\n<p class=\"wp-block-paragraph\">One widely used evaluation measure for confidence calibration is the Expected Calibration Error (ECE). ECE measures how well a model\u2019s estimated probabilities match the observed probabilities by taking a weighted average over the absolute difference between average accuracy <em>(acc)<\/em> and average confidence <em>(conf)<\/em>. The measure involves splitting all <strong><em>n<\/em><\/strong> datapoints into <em>M<\/em> equally spaced bins:<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" data-dominant-color=\"f6f6f6\" data-has-transparency=\"false\" style=\"--dominant-color: #f6f6f6;\" loading=\"lazy\" decoding=\"async\" width=\"858\" height=\"76\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F2.png?resize=858%2C76&#038;ssl=1\" alt=\"\" class=\"wp-image-597704 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F2.png 858w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F2-300x27.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F2-768x68.png 768w\" sizes=\"auto, (max-width: 858px) 100vw, 858px\"><\/figure>\n<p class=\"wp-block-paragraph\">where <strong><em>B<\/em><\/strong> is used for representing \u201cbins\u201d and <strong><em>m<\/em><\/strong> for the bin number, while <em>acc<\/em> and <em>conf<\/em> are:<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" data-dominant-color=\"f4f4f4\" data-has-transparency=\"false\" style=\"--dominant-color: #f4f4f4;\" loading=\"lazy\" decoding=\"async\" width=\"895\" height=\"67\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F3.png?resize=895%2C67&#038;ssl=1\" alt=\"\" class=\"wp-image-597705 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F3.png 895w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F3-300x22.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F3-768x57.png 768w\" sizes=\"auto, (max-width: 895px) 100vw, 895px\"><\/figure>\n<p class=\"wp-block-paragraph\"><strong><em>\u0177\u1d62 <\/em><\/strong>is the model\u2019s predicted class <em>(arg max)<\/em> for sample <strong><em>i <\/em><\/strong>and <strong><em>y\u1d62<\/em><\/strong> is the true label for sample <strong><em>i<\/em><\/strong>. <strong>1<\/strong> is an <em>indicator function<\/em>, meaning when the predicted label <strong><em>\u0177\u1d62 <\/em><\/strong>equals the true label<em> <strong>y\u1d62<\/strong> <\/em>it evaluates to 1, otherwise 0. Let\u2019s look at an example, which will clarify <em>acc, conf<\/em> and the whole binning approach in a visual step-by-step manner.<\/p>\n<h3 class=\"wp-block-heading\">\n<strong>2.1 ECE\u200a\u2014\u200aVisual Step by Step Example<\/strong><strong><\/strong><br \/>\n<\/h3>\n<p class=\"wp-block-paragraph\">In the image below, we can see that we have <em>9<\/em> samples indexed by <strong><em>i<\/em><\/strong> with estimated probabilities <strong><em>p\u0302(x\u1d62) <\/em>(<\/strong><em>simplified as <strong>p\u0302\u1d62<\/strong><\/em>) for class <strong>cat (C)<\/strong>,<strong> dog (D) <\/strong>or <strong>toad (T)<\/strong>. The final column shows the true class <strong><em>y\u1d62 <\/em><\/strong>and the penultimate column contains the predicted class <strong><em>\u0177\u1d62<\/em><\/strong>.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"dbe1e4\" data-has-transparency=\"false\" style=\"--dominant-color: #dbe1e4;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"415\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i4_ece_table1-1024x415.png?resize=1024%2C415&#038;ssl=1\" alt=\"\" class=\"wp-image-597706 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i4_ece_table1-1024x415.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i4_ece_table1-300x122.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i4_ece_table1-768x312.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i4_ece_table1.png 1151w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Table 1\u200a\u2014\u200aECE toy example\u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Only the maximum probabilities, which determine the predicted label are used in ECE. Therefore, we will only bin samples based on the maximum probability across classes <em>(see left table in below image)<\/em>. To keep the example simple we split the data into 5 <strong>equally spaced <\/strong>bins <strong><em>M=5<\/em><\/strong>. If we now look at each sample\u2019s maximum estimated probability, we can group it into one of the 5 bins <em>(see right side of image below)<\/em>.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"e3e7ea\" data-has-transparency=\"false\" style=\"--dominant-color: #e3e7ea;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"294\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i5_ece_table2-1024x294.png?resize=1024%2C294&#038;ssl=1\" alt=\"\" class=\"wp-image-597707 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i5_ece_table2-1024x294.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i5_ece_table2-300x86.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i5_ece_table2-768x220.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i5_ece_table2-1536x441.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i5_ece_table2-2048x588.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Table 2 &amp; Binning Diagram\u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">We still need to determine if the predicted class is correct or not to be able to determine the average accuracy per bin. If the model predicts the class correctly (i.e.\u00a0 <strong><em>y\u1d62<\/em><\/strong> = <strong><em>\u0177\u1d62<\/em><\/strong>), the prediction is highlighted in green; incorrect predictions are marked in red:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"e2e6e4\" data-has-transparency=\"false\" style=\"--dominant-color: #e2e6e4;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"267\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i6_ece_table3-2-1024x267.png?resize=1024%2C267&#038;ssl=1\" alt=\"\" class=\"wp-image-597710 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i6_ece_table3-2-1024x267.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i6_ece_table3-2-300x78.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i6_ece_table3-2-768x200.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i6_ece_table3-2-1536x400.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i6_ece_table3-2-2048x534.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Table 3 &amp; Binning Diagram\u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">We now have visualised all the information needed for ECE and will briefly run through how to<\/p>\n<p class=\"wp-block-paragraph\">calculate the values for bin 5 (<strong><em>B<\/em><\/strong><strong><em>\u2085<\/em><\/strong>). The other bins then simply follow the same process, see below.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"edefee\" data-has-transparency=\"false\" style=\"--dominant-color: #edefee;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"443\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i7_ece_table4-1024x443.png?resize=1024%2C443&#038;ssl=1\" alt=\"\" class=\"wp-image-597711 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i7_ece_table4-1024x443.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i7_ece_table4-300x130.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i7_ece_table4-768x332.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i7_ece_table4-1536x665.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i7_ece_table4-2048x886.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Table 4 &amp; Example for bin 5 \u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">We can get the empirical probability of a sample falling into <strong><em>B<\/em><\/strong><strong><em>\u2085<\/em><\/strong>, by assessing how many out of all <strong>9<\/strong> samples fall into <strong><em>B<\/em><\/strong><strong><em>\u2085<\/em><\/strong><strong><em>, <\/em><\/strong>see <strong>( 1 ).<\/strong> We then get the average accuracy for <strong><em>B<\/em><\/strong><strong><em>\u2085<\/em><\/strong>, see <strong>( 2 )<\/strong> and lastly the average estimated probability for <strong><em>B<\/em><\/strong><strong><em>\u2085<\/em><\/strong>, see <strong>( 3 )<em>. <\/em><\/strong>Repeat this for all bins and in our small example of 9 samples we end up with an ECE of <em>0.10445<\/em>. A perfectly calibrated model would have an ECE of 0.<\/p>\n<p class=\"wp-block-paragraph\"><em>For a more detailed, step-by-step explanation of the ECE, have a look at <\/em><a href=\"https:\/\/towardsdatascience.com\/expected-calibration-error-ece-a-step-by-step-visual-explanation-with-python-code-c3e9aa12937d\/\"><em>this blog post<\/em><\/a><em>.<\/em><\/p>\n<h3 class=\"wp-block-heading\"><strong>2.1.1\u00a0 EXPECTED CALIBRATION ERROR DRAWBACKS<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">The images of binning above provide a visual guide of how ECE could result in very different values if we used more bins or perhaps binned the same number of items instead of using equal bin widths. Such and more drawbacks of ECE have been highlighted by several works early on. <em>However, despite the known weaknesses ECE is still widely used to evaluate confidence calibration in ML.\u00a0<\/em><\/p>\n<h3 class=\"wp-block-heading\" id=\"Drawbacks\">\n<strong>3 Most frequently mentioned Drawbacks of ECE<\/strong><strong><\/strong><br \/>\n<\/h3>\n<h4 class=\"wp-block-heading\">\n<strong>3.1 Pathologies\u200a\u2014\u200aLow ECE \u2260 high accuracy<\/strong><strong><\/strong><br \/>\n<\/h4>\n<p class=\"wp-block-paragraph\">A model which minimises ECE, does not necessarily have a high accuracy. For instance, if a model always predicts the majority class with that class\u2019s average prevalence as the probability, it will have an ECE of 0. This is visualised in the image above, where we have a dataset with 10 samples, 7 of those are cat, 2 dog and only one is a toad. Now if the model always predicts cat with on average 0.7 confidence it would have an ECE of 0. There are more of such pathologies. To not only rely on ECE, some researchers use additional measures such as the Brier score or LogLoss alongside ECE.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"f7f5f3\" data-has-transparency=\"false\" style=\"--dominant-color: #f7f5f3;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"359\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i8_pathologies-1024x359.png?resize=1024%2C359&#038;ssl=1\" alt=\"\" class=\"wp-image-597712 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i8_pathologies-1024x359.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i8_pathologies-300x105.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i8_pathologies-768x269.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i8_pathologies-1536x539.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i8_pathologies.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Sample Pathology\u200a\u2014\u200a image by author<\/figcaption><\/figure>\n<h4 class=\"wp-block-heading\"><strong>3.2 Binning Approach<\/strong><\/h4>\n<p class=\"wp-block-paragraph\">One of the most frequently mentioned issues with ECE is its sensitivity to the change in binning. This is sometimes referred to as the <strong><em>Bias-Variance trade-off<\/em><\/strong>: Fewer bins reduce variance but increase bias, while more bins lead to sparsely populated bins increasing variance. If we look back to our ECE example with 9 samples and change the bins from 5 to 10 here too, we end up with the following:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"efefed\" data-has-transparency=\"false\" style=\"--dominant-color: #efefed;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"356\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i9_binning_1-1024x356.png?resize=1024%2C356&#038;ssl=1\" alt=\"\" class=\"wp-image-597713 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i9_binning_1-1024x356.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i9_binning_1-300x104.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i9_binning_1-768x267.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i9_binning_1-1536x534.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i9_binning_1.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">More Bins Example\u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">We can see that bin <em>8<\/em> and <em>9<\/em> each contain only a single sample and also that half the bins now contain no samples. The above is only a toy example, however since modern models tend to have higher confidence values samples often end up in the last few bins, which means they get all the weight in ECE, while the average error for the empty bins contributes 0 to ECE.<\/p>\n<p class=\"wp-block-paragraph\">To mitigate these issues of fixed bin widths some authors have proposed a more adaptive binning approach:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"f1f1ec\" data-has-transparency=\"false\" style=\"--dominant-color: #f1f1ec;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"364\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i10_binning_2-1024x364.png?resize=1024%2C364&#038;ssl=1\" alt=\"\" class=\"wp-image-597714 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i10_binning_2-1024x364.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i10_binning_2-300x107.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i10_binning_2-768x273.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i10_binning_2-1536x545.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i10_binning_2.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Adaptive Bins Example\u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Binning-based evaluation with bins containing an equal number of samples are shown to have lower bias than a fixed binning approach such as ECE. This leads Roelofs to urge against using equal width binning and they suggest the use of an alternative: <strong><em>ECEsweep<\/em><\/strong>, which <em>maximizes the number of equal-mass bins<\/em> while ensuring the calibration function remains monotonic. The<em> Adaptive Calibration Error (<strong>ACE<\/strong>)<\/em> and <em>Threshold Adaptive calibration Error (<strong>TACE<\/strong>) <\/em>are two other variations of ECE that use flexible binning. However, some find it sensitive to the choice of bins and thresholds, leading to inconsistencies in ranking different models. Two other approaches aim to eliminate binning altogether: <strong><em>MacroCE<\/em><\/strong> does this by averaging over instance-level calibration errors of correct and wrong predictions and the <strong><em>KDE-based ECE<\/em><\/strong> does so by replacing the bins with non-parametric density estimators, specifically kernel density estimation (KDE).<\/p>\n<h4 class=\"wp-block-heading\">\n<strong>3.3 Only maximum probabilities considered<\/strong><strong><\/strong><br \/>\n<\/h4>\n<p class=\"wp-block-paragraph\">Another frequently mentioned drawback of ECE is that it only considers the maximum estimated probabilities. The idea that more than just the maximum confidence should be calibrated, is best illustrated with a simple example:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"e6ebf0\" data-has-transparency=\"false\" style=\"--dominant-color: #e6ebf0;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"437\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i11_max_probs_only-1024x437.png?resize=1024%2C437&#038;ssl=1\" alt=\"\" class=\"wp-image-597717 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i11_max_probs_only-1024x437.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i11_max_probs_only-300x128.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i11_max_probs_only-768x328.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i11_max_probs_only.png 1493w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Only Max. Probabilities\u200a\u2014\u200aimage by author\u200a\u2014\u200ainput example sourced from<a href=\"https:\/\/arxiv.org\/abs\/2405.08794\"> Schwirten<\/a><\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">Let\u2019s say we trained two different models and now both need to determine if the same input image contains a <em>person<\/em>, an <em>animal<\/em> or <em>no creature<\/em>. The two models output vectors with slightly different estimated probabilities, but both have the same maximum confidence for \u201c<em>no creature<\/em>\u201d. Since ECE only looks at these top values it would consider these two outputs to be the same. Yet, when we think of real-world applications we might want our self-driving car to act differently in one situation over the other. This restriction to the maximum confidence prompted various authors to reconsider the definition of calibration, which gives us two additional interpretations of confidence: <strong>multi-class<\/strong> and <strong>class-wise calibration<\/strong>.<\/p>\n<h3 class=\"wp-block-heading\" id=\"Multiclass\"><strong>3.3.1 MULTI-CLASS CALIBRATION<\/strong><\/h3>\n<p class=\"wp-block-paragraph\">A model is considered multi-class calibrated if, for any prediction vector <strong><em>q=<\/em><\/strong>(<em>q<\/em>\u2081\u200b,\u2026,<em>q<\/em>\u2096) \u2208 <strong>\u0394\u1d37<\/strong>\u200b, the class proportions among all values of <strong><em>X <\/em><\/strong>for which a model outputs the same prediction <strong><em>p\u0302(X)=q<\/em><\/strong> match the values in the prediction vector <strong><em>q<\/em><\/strong>.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"eeeeee\" data-has-transparency=\"false\" style=\"--dominant-color: #eeeeee;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"40\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F4-1024x40.png?resize=1024%2C40&#038;ssl=1\" alt=\"\" class=\"wp-image-597719 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F4-1024x40.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F4-300x12.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F4-768x30.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F4-1536x60.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F4.png 1600w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><\/figure>\n<p class=\"wp-block-paragraph\">where (X,Y) is a datapoint and p\u0302 : \ud835\udd4f \u2192 \u0394\u1d37 returns a probability vector as its output<\/p>\n<p class=\"wp-block-paragraph\">What does this mean in simple terms? Instead of <strong><em>c<\/em><\/strong> we now calibrate against a vector <strong><em>q<\/em><\/strong>, with k classes. Let\u2019s look at an example below:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"cdd7e3\" data-has-transparency=\"false\" style=\"--dominant-color: #cdd7e3;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"371\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i12_multi-class-1024x371.png?resize=1024%2C371&#038;ssl=1\" alt=\"\" class=\"wp-image-597720 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i12_multi-class-1024x371.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i12_multi-class-300x109.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i12_multi-class-768x278.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i12_multi-class.png 1440w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Multi-Class Calibration\u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">On the left we have the space of all possible prediction vectors. Let\u2019s zoom into one such vector that our model predicted and say the model has 10 instances for which it predicted the vector <strong><em>q<\/em><\/strong>=<em>[0.1,0.2,0.7]<\/em>. Now in order for it to be multi-class calibrated, the distribution of the true (<em>actual<\/em>) class needs to match the prediction vector <strong><em>q<\/em><\/strong>. The image above shows a calibrated example with <em>[0.1,0.2,0.7] <\/em>and a not calibrated case with <em>[0.1,0.5,0.4]<\/em>.<\/p>\n<h3 class=\"wp-block-heading\">\n<strong>3.3.2 CLASS-WISE CALIBRATION<\/strong><strong><\/strong><br \/>\n<\/h3>\n<p class=\"wp-block-paragraph\">A model is considered class-wise calibrated if, for each class k, all inputs that share an estimated probability <strong><em>p\u0302<\/em><\/strong><strong>\u2096<\/strong><strong><em>(X)<\/em><\/strong> align with the true frequency of class k when considered on its own:<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" data-dominant-color=\"f3f3f3\" data-has-transparency=\"false\" style=\"--dominant-color: #f3f3f3;\" loading=\"lazy\" decoding=\"async\" width=\"878\" height=\"39\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F5.png?resize=878%2C39&#038;ssl=1\" alt=\"\" class=\"wp-image-597721 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F5.png 878w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F5-300x13.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F5-768x34.png 768w\" sizes=\"auto, (max-width: 878px) 100vw, 878px\"><\/figure>\n<p class=\"wp-block-paragraph\">where (X,Y) is a datapoint; q \u2208 \u0394\u1d37 and p\u0302 : \ud835\udd4f \u2192 \u0394\u1d37 returns a probability vector as its output<\/p>\n<p class=\"wp-block-paragraph\">Class-wise calibration is a <strong><em>weaker<\/em><\/strong> definition than <strong>multi-class<\/strong> calibration as it considers each class probability in <strong><em>isolation<\/em><\/strong> rather than needing the full vector to align. The image below illustrates this by zooming into a probability estimate for class 1 specifically: <strong><em>q<\/em><\/strong><strong><em>\u2081<\/em><\/strong><strong><em>=0.1<\/em><\/strong>. Yet again, we assume we have 10 instances for which the model predicted a probability estimate of 0.1 for class 1. We then look at the true class frequency amongst all classes with <strong><em>q<\/em><\/strong><strong><em>\u2081<\/em><\/strong><strong><em>=0.1<\/em><\/strong>. If the empirical frequency matches <strong><em>q<\/em><\/strong><strong><em>\u2081<\/em><\/strong> it is calibrated.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"cdd8e4\" data-has-transparency=\"false\" style=\"--dominant-color: #cdd8e4;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"376\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i13_class-wise-1024x376.png?resize=1024%2C376&#038;ssl=1\" alt=\"\" class=\"wp-image-597722 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i13_class-wise-1024x376.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i13_class-wise-300x110.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i13_class-wise-768x282.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i13_class-wise.png 1359w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Class-Wise Calibration\u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">To evaluate such different notions of calibration, some updates are made to ECE to calculate a class-wise error. One idea is to calculate the ECE for each class and then take the average. Others, introduce the use of the KS-test for class-wise calibration and also suggest using statistical hypothesis tests instead of ECE based approaches. And other researchers develop a hypothesis test framework (TCal) to detect whether a model is significantly mis-calibrated and build on this by developing confidence intervals for the L2 ECE.<\/p>\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dotted\">\n<p class=\"wp-block-paragraph\">All the approaches mentioned above <strong>share a key assumption: ground-truth labels are available<\/strong>. Within this gold-standard mindset a prediction is either true or false. However, annotators might unresolvably and justifiably disagree on the real label. Let\u2019s look at a simple example below:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"efefed\" data-has-transparency=\"false\" style=\"--dominant-color: #efefed;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"413\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i14_one_hot-1024x413.png?resize=1024%2C413&#038;ssl=1\" alt=\"\" class=\"wp-image-597723 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i14_one_hot-1024x413.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i14_one_hot-300x121.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i14_one_hot-768x310.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i14_one_hot.png 1375w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Gold-Standard Labelling | One-Hot-Vector\u200a\u2014\u200a image by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">We have the same image as in our entry example and can see that the chosen label differs between annotators. A common approach to resolving such issues in the labelling process is to use some form of aggregation. Let\u2019s say that in our example the majority vote is selected, so we end up evaluating how well our model is calibrated against such \u2018ground truth\u2019. One might think, the image is small and pixelated; of course humans will not be certain about their choice. However, rather than being an exception such disagreements are widespread. So, when there is a lot of human disagreement in a dataset it might not be a good idea to calibrate against an aggregated \u2018gold\u2019 label. Instead of gold labels more and more researchers are using soft or smooth labels which are more representative of the human uncertainty, see example below:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"eaeced\" data-has-transparency=\"false\" style=\"--dominant-color: #eaeced;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"384\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i15_soft_label-1024x384.png?resize=1024%2C384&#038;ssl=1\" alt=\"\" class=\"wp-image-597725 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i15_soft_label-1024x384.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i15_soft_label-300x112.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i15_soft_label-768x288.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i15_soft_label.png 1423w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Collective Opinion Labelling | Soft-label\u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">In the same example as above, instead of aggregating the annotator votes we could simply use their frequencies to create a distribution P\u1d65\u2092\u209c\u2091 over the labels instead, which is then our new <strong><em>y\u1d62<\/em><\/strong>. This shift towards training models on collective annotator views, rather than relying on a single source-of-truth motivates another definition of calibration: calibrating the model against human uncertainty.<\/p>\n<h3 class=\"wp-block-heading\">\n<strong>3.3.3 HUMAN UNCERTAINTY CALIBRATION<\/strong><strong><\/strong><br \/>\n<\/h3>\n<p class=\"wp-block-paragraph\">A model is considered human-uncertainty calibrated if, for each specific sample <strong><em>x<\/em><\/strong>, the predicted probability for each class k matches the \u2018<em>actual<\/em>\u2019 probability P\u1d65\u2092\u209c\u2091 of that class being correct.<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" data-dominant-color=\"f0f0f0\" data-has-transparency=\"false\" style=\"--dominant-color: #f0f0f0;\" loading=\"lazy\" decoding=\"async\" width=\"868\" height=\"32\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F6.png?resize=868%2C32&#038;ssl=1\" alt=\"\" class=\"wp-image-597726 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F6.png 868w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F6-300x11.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F6-768x28.png 768w\" sizes=\"auto, (max-width: 868px) 100vw, 868px\"><\/figure>\n<p class=\"wp-block-paragraph\">where (X,Y) is a datapoint and p\u0302 : \ud835\udd4f \u2192 \u0394\u1d37 returns a probability vector as its output.<\/p>\n<p class=\"wp-block-paragraph\">This interpretation of calibration aligns the model\u2019s prediction with human uncertainty, which means each prediction made by the model is individually reliable and matches human-level uncertainty for that instance. Let\u2019s have a look at an example below:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"bed2e8\" data-has-transparency=\"false\" style=\"--dominant-color: #bed2e8;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"448\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i16_human_uncertainty-1024x448.png?resize=1024%2C448&#038;ssl=1\" alt=\"\" class=\"wp-image-597727 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i16_human_uncertainty-1024x448.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i16_human_uncertainty-300x131.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i16_human_uncertainty-768x336.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i16_human_uncertainty-1536x673.png 1536w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i16_human_uncertainty.png 1683w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">Human Uncertainty Calibration\u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">We have our sample data (<em>left<\/em>) and zoom into a single sample <strong><em>x<\/em><\/strong> with index <strong><em>i=1<\/em><\/strong>. The model\u2019s predicted probability vector for this sample is <em>[0.1,0.2,0.7]<\/em>. If the human labelled distribution <strong><em>y\u1d62<\/em><\/strong> matches this predicted vector then this sample is considered calibrated.<\/p>\n<p class=\"wp-block-paragraph\">This definition of calibration is more granular and strict than the previous ones as it applies directly at the level of individual predictions rather than being averaged or assessed over a set of samples. It also relies heavily on having an accurate estimate of the human judgement distribution, which requires a large number of annotations per item. Datasets with such properties of annotations are gradually becoming more available.<\/p>\n<p class=\"wp-block-paragraph\">To evaluate human uncertainty calibration the researchers introduce three new measures: <strong>the Human Entropy Calibration Error <em>(EntCE)<\/em>, the Human Ranking Calibration Score <em>(RankCS)<\/em> and the Human Distribution Calibration Error <em>(DistCE)<\/em><\/strong>.<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" data-dominant-color=\"f1f1f1\" data-has-transparency=\"false\" style=\"--dominant-color: #f1f1f1;\" loading=\"lazy\" decoding=\"async\" width=\"848\" height=\"32\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F7.png?resize=848%2C32&#038;ssl=1\" alt=\"\" class=\"wp-image-597730 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F7.png 848w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F7-300x11.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F7-768x29.png 768w\" sizes=\"auto, (max-width: 848px) 100vw, 848px\"><\/figure>\n<p class=\"wp-block-paragraph\">where <strong><em>H(.)<\/em><\/strong> signifies entropy.<\/p>\n<p class=\"wp-block-paragraph\"><strong><em>EntCE<\/em><\/strong> aims to capture the agreement between the model\u2019s uncertainty <strong><em>H<\/em>(<em>p\u0302<\/em>\u1d62)<\/strong> and the human uncertainty <strong><em>H<\/em>(<em>y\u1d62<\/em>)<\/strong> for a sample <strong><em>i<\/em><\/strong>. However, entropy is invariant to the permutations of the probability values; in other words it doesn\u2019t change when you rearrange the probability values. This is visualised in the image below:<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"c5dbf1\" data-has-transparency=\"false\" style=\"--dominant-color: #c5dbf1;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"336\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i17_entce-1024x336.png?resize=1024%2C336&#038;ssl=1\" alt=\"\" class=\"wp-image-597731 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i17_entce-1024x336.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i17_entce-300x98.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i17_entce-768x252.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i17_entce.png 1400w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">EntCE drawbacks\u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<p class=\"wp-block-paragraph\">On the left, we can see the human label distribution <strong><em>y\u1d62<\/em><\/strong>, on the right are two different model predictions for that same sample. All three distributions would have the same entropy, so comparing them would result in 0 <em>EntCE<\/em>. While this is not ideal for comparing distributions, entropy is still helpful in assessing the noise level of label distributions.<\/p>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" data-dominant-color=\"ececec\" data-has-transparency=\"false\" style=\"--dominant-color: #ececec;\" loading=\"lazy\" decoding=\"async\" width=\"791\" height=\"41\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F8.png?resize=791%2C41&#038;ssl=1\" alt=\"\" class=\"wp-image-597732 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F8.png 791w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F8-300x16.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F8-768x40.png 768w\" sizes=\"auto, (max-width: 791px) 100vw, 791px\"><\/figure>\n<p class=\"wp-block-paragraph\">where argsort simply returns the indices that would sort an array.<\/p>\n<p class=\"wp-block-paragraph\">So, <strong><em>RankCS<\/em><\/strong> checks if the sorted order of estimated probabilities <strong><em>p\u0302\u1d62<\/em><\/strong> matches the sorted order of <strong><em>y\u1d62<\/em> <\/strong>for each sample. If they match for a particular sample <strong><em>i<\/em><\/strong> one can count it as 1; if not, it can be counted as 0, which is then used to average over all samples N.\u00b9<\/p>\n<p class=\"wp-block-paragraph\">Since this approach uses ranking it doesn\u2019t care about the actual size of the probability values. The two predictions below, while not the same in class probabilities would have the same ranking. This is helpful in assessing the overall ranking capability of models and looks beyond just the maximum confidence. At the same time though, it doesn\u2019t fully capture human uncertainty calibration as it ignores the actual probability values.<\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"cfe2f4\" data-has-transparency=\"false\" style=\"--dominant-color: #cfe2f4;\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"344\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i18_rankcs-1024x344.png?resize=1024%2C344&#038;ssl=1\" alt=\"\" class=\"wp-image-597733 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i18_rankcs-1024x344.png 1024w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i18_rankcs-300x101.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i18_rankcs-768x258.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i18_rankcs.png 1288w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><figcaption class=\"wp-element-caption\">RankCS drawbacks \u200a\u2014\u200aimage by author<\/figcaption><\/figure>\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" data-dominant-color=\"f1f1f2\" data-has-transparency=\"false\" style=\"--dominant-color: #f1f1f2;\" loading=\"lazy\" decoding=\"async\" width=\"846\" height=\"35\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F9.png?resize=846%2C35&#038;ssl=1\" alt=\"\" class=\"wp-image-597734 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F9.png 846w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F9-300x12.png 300w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/F9-768x32.png 768w\" sizes=\"auto, (max-width: 846px) 100vw, 846px\"><\/figure>\n<p class=\"wp-block-paragraph\"><strong><em>DistCE<\/em><\/strong> has been proposed as an additional evaluation for this notion of calibration. It simply uses the total variation distance (<strong><em>TVD<\/em><\/strong>) between the two distributions, which aims to reflect how much they diverge from one another. <em>DistCE<\/em> and <em>EntCE<\/em> capture instance level information. So to get a feeling for the full dataset one can simply take the average expected value over the absolute value of each measure: E[\u2223DistCE\u2223] and E[\u2223EntCE\u2223]. Perhaps future efforts will introduce further measures that combine the benefits of ranking and noise estimation for this notion of calibration.<\/p>\n<h2 class=\"wp-block-heading\" id=\"summary\">\n<strong>4 Final thoughts<\/strong><strong><\/strong><br \/>\n<\/h2>\n<p class=\"wp-block-paragraph\">We have run through the most common definition of calibration, the shortcomings of ECE and how several new notions of calibration exist. We also touched on some of the newly proposed evaluation measures and their shortcomings. Despite several works arguing against the use of ECE for evaluating calibration, it remains widely used. The aim of this blog post is to draw attention to these works and their alternative approaches. <em>Determining which notion of calibration best fits a specific context and how to evaluate it should avoid misleading results. Maybe, however, ECE is simply so easy, intuitive and just good enough for most applications that it is here to stay?<\/em><\/p>\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" data-dominant-color=\"d3dde9\" data-has-transparency=\"false\" style=\"--dominant-color: #d3dde9;\" loading=\"lazy\" decoding=\"async\" width=\"669\" height=\"1024\" src=\"https:\/\/i0.wp.com\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i19_calibration_overview-669x1024.png?resize=669%2C1024&#038;ssl=1\" alt=\"\" class=\"wp-image-597736 not-transparent\" srcset=\"https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i19_calibration_overview-669x1024.png 669w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i19_calibration_overview-196x300.png 196w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i19_calibration_overview-768x1175.png 768w, https:\/\/towardsdatascience.com\/wp-content\/uploads\/2025\/02\/i19_calibration_overview.png 942w\" sizes=\"auto, (max-width: 669px) 100vw, 669px\"><\/figure>\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/iclr-blogposts.github.io\/2025\/blog\/index.html\"><strong>This <\/strong><em>was accepted at the <\/em><strong>ICLR conference Blog Post Track <\/strong><em>&amp; is estimated to appear on the site ~ April<\/em><\/a><\/p>\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/arxiv.org\/abs\/2501.19047\"><em>In the meantime, you can cite\/reference the<strong> ArXiv <\/strong><\/em><\/a><strong><em><u>preprint.<\/u><\/em><\/strong><\/p>\n<p class=\"wp-block-paragraph\"><strong><em>Footnotes<\/em><\/strong><\/p>\n<p class=\"wp-block-paragraph\">\u00b9<em>In the paper it is stated more generally: If the argsorts match, it means the ranking is aligned, contributing to the overall RankCS score.<\/em><\/p>\n<p>The post <a href=\"https:\/\/towardsdatascience.com\/understanding-model-calibration-a-gentle-introduction-visual-exploration\/\">Understanding Model Calibration: A Gentle Introduction &amp; Visual Exploration<\/a> appeared first on <a href=\"https:\/\/towardsdatascience.com\/\">Towards Data Science<\/a>.<\/p>\n<\/div>\n<p> \t<BR><br \/>\n <BR><\/BR><br \/>\n    Maja Pavlovic<br \/>\n \t<BR><br \/>\n<BR><\/BR><br \/>\n<a href=\"https:\/\/towardsdatascience.com\/understanding-model-calibration-a-gentle-introduction-visual-exploration\/\">Go to original source<\/a><br \/>\n \t<BR><br \/>\n <BR><\/BR><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Understanding Model Calibration: A Gentle Introduction &#038; Visual Exploration How Reliable Are Your Predictions? About To be considered reliable, a model must be calibrated so that its confidence in each decision closely reflects its true outcome. In this blog post we\u2019ll take a look at the most commonly used definition for calibration and then dive [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62,70,1225,1500,1710,92,1691],"tags":[1227,1711,103],"class_list":["post-1793","post","type-post","status-publish","format-standard","hentry","category-aimldsaimlds","category-machine-learning","category-model-calibration","category-model-evaluation","category-statisitcs","category-thoughts-and-theory","category-uncertainity","tag-calibration","tag-gentle","tag-model"],"_links":{"self":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/posts\/1793"}],"collection":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/comments?post=1793"}],"version-history":[{"count":0,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/posts\/1793\/revisions"}],"wp:attachment":[{"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/media?parent=1793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/categories?post=1793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mailitics.com\/index.php\/wp-json\/wp\/v2\/tags?post=1793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}