Article sections
A confidence score is not always a probabilityHow do you read a reliability diagram?ECE and Brier scoreWhat does temperature scaling do?Epistemic and aleatoric uncertaintyWhat does conformal prediction provide?Selective prediction and abstentionThe calibration lifecycleField scenarioTesting calibration on a separate datasetFrequently asked questionsReferencesA confidence score is not always a probability
A classifier may output "defect: 95%"; there is no automatic guarantee that this value corresponds to a 95% rate of correct decisions in the field. Deep network scores may be overconfident or underconfident. Calibration means that, across many predictions at the same confidence level, the score agrees with the observed frequency of correctness.
For example, at 80% confidence, if 100 decisions yield about 80 correct outcomes, that region may be well calibrated. However, an 80% confidence statement for a single sample does not prove that individual prediction is correct. Class definitions, the data distribution, and aggregate evaluation matter.
How do you read a reliability diagram?
Predictions are divided into confidence bins; the mean score and observed accuracy are calculated within each bin. In an ideal diagram, the points lie close to the diagonal. Points below the diagonal indicate overconfidence, while points above it indicate underconfidence. The number of bins, empty bins, and sparsely populated regions affect the stability of the plot.
A model may have high overall accuracy but poor confidence calibration. This distinction is especially critical in systems that automatically accept cases or route them to human review.
ECE and Brier score
Expected Calibration Error (ECE) is a commonly used summary metric: the accuracy-confidence gap in each bin is weighted by the number of samples in that bin. However, it is sensitive to the number of bins and can hide certain forms of miscalibration. The Brier score is the mean squared difference between predicted probabilities and actual binary outcomes; it is affected by discrimination as well as calibration.
A single ECE or Brier score should therefore not be taken as evidence that all aspects of calibration are good. Reliability diagrams, class-level analysis, and independent testing should be used together.
What does temperature scaling do?
Temperature scaling changes the sharpness of the softmax distribution by dividing logits by a positive temperature parameter. The temperature is usually learned on separate calibration data. Standard multiclass temperature scaling preserves class rankings and, in most cases, adjusts confidence scores without changing the argmax class. Classification accuracy may therefore remain unchanged.
If the calibration data does not represent actual production conditions, the method may be less useful on another shift. Learning the temperature on the test set is methodologically incorrect.
Interactive example: confidence calibration and temperature scaling
Change the temperature applied to synthetic logits to explore how mean confidence and ECE change.
This small demonstration uses synthetic two-class samples. In a real application, the temperature scaling parameter must be selected only on a separate calibration set.
Epistemic and aleatoric uncertainty
Aleatoric uncertainty is associated with noise and ambiguity inherent in the observation; examples include motion blur or a tiny defect that is not visible in the image. Epistemic uncertainty is associated with the model's knowledge, such as a lack of training examples or out-of-distribution inputs. In practice, these two types cannot always be clearly separated.
Ensembles, Monte Carlo dropout, and Bayesian approaches can provide signals of uncertainty; however, their computational cost in production and whether they actually help with OOD detection must be tested separately.
What does conformal prediction provide?
Conformal methods can provide marginal coverage guarantees under certain exchangeability assumptions. A classifier can return a set of possible classes rather than a single class. However, an overall coverage guarantee does not automatically imply a guarantee for every subgroup. Distribution shift can invalidate the assumptions.
In production, conformal predictions can be used to route borderline samples to human review. They still need to be designed with decision costs and review capacity in mind.
Selective prediction and abstention
When a model chooses not to decide on uncertain samples, the error rate among the remaining automated decisions may decrease. Coverage is the proportion of samples handled automatically, while risk is the error rate on those samples. As coverage decreases, the manual review workload increases. A good system provides not only a low automated error rate but also a manageable review workload.
Thresholding uncertainty is not a substitute for calibration. The same score may have different levels of reliability across product groups.
The calibration lifecycle
The relationship between the score distribution and accuracy should be reassessed whenever the model version, camera, defect rate, or production batch changes. The calibration parameter should be versioned together with the model. In critical situations, the live system should retain a safe review path instead of relying on automated decisions.
Reliability is earned not through the model's own score, but through how well that score is validated on independent data.
Practical field scenario: an overconfident classifier
Suppose a defect classifier reports high confidence, but among validation samples in the 90% confidence band, only 76% are correct. A reliability diagram reveals this overconfidence. Temperature scaling is tuned on a separate calibration set; however, lasting reliability must not be assumed without checking it again on a new production batch.
How should calibration data be sampled?
The calibration dataset should be independent of the training data and, where possible, reflect the product and defect proportions in the field. When the dataset is very small, confidence bins may be empty or sparsely populated, making the shape of the reliability diagram unstable. Examining the same model's calibration separately across shifts may reveal that overconfidence occurs in only one subgroup.
Selecting temperature scaling on the test set compromises the evaluation. In the standard case, a single positive temperature parameter changes the logit scale without changing the argmax class. However, if decision thresholds depend on the score, the number of operational acceptance and rejection decisions may change. The threshold should therefore be reconsidered after calibration.
Limitations of ECE
A low ECE alone does not imply good calibration in every sample group. Different confidence ranges can offset one another, and errors can be large in sparsely populated bins. The Brier score is also affected by discrimination and uncertainty in the data. Reliability diagrams, class-level evaluation, the risk-coverage relationship, and sample counts should be reported together.
Making decisions under uncertainty
For example, if two models predict the same class but the ensemble members' scores differ substantially, this may indicate epistemic uncertainty. Decisions can take into account disagreement among members as well as mean confidence. However, an ensemble adds computational cost. On real-time production lines, secondary verification with a smaller model or human review may sometimes be more practical.
Field deployment checklist
- Data source: Clearly specify the product, batch, camera, shift, and sampling method.
- Decision unit: Do not conflate measurements at the image, defect, product, and production-line levels.
- Success criteria: Document the metric target together with latency, throughput, cost, and tolerance for critical errors.
- Alternatives: Assess whether simpler methods and improvements to the physical setup can meet the same need.
- Validation: Use a test protocol that is independent of the training data and representative of production conditions.
- Change log: Whenever the model, threshold, optical settings, or label definition changes, archive the rationale for the decision and its consequences.
Testing calibration on a separate dataset
Suppose a classifier is correct on only 76 of 100 examples where its average confidence in the selected class is 90%. That group has a 14-percentage-point confidence–accuracy gap. One group does not establish calibration across the model: examine lower-confidence regions, classes and products. Small bins have high uncertainty; changing bin counts to make a plot look better is not evidence of improvement.
Fit the temperature on a calibration set excluded from model-weight training, then evaluate it on another independent test set. Dividing all multiclass logits by a positive temperature preserves their ordering while changing probability sharpness. Calibration therefore does not automatically turn a wrong predicted class into the correct one. A production policy using fixed score thresholds still needs retesting when the probabilities change.
For a binary Brier-score example, take positive-class probabilities 0.9, 0.8, 0.6 and 0.1 with labels 1, 0, 1 and 0. The mean squared error is (0.01+0.64+0.16+0.01)/4=0.205. This is not a pure calibration-error measure; it also reflects discrimination. Report reliability diagrams, sample counts, appropriate scores and subgroup results together, and check whether calibration remains valid on a new batch.
Frequently asked questions
What does a softmax score of 99 percent mean?
It is the model's score; whether it corresponds to the observed accuracy rate must be verified separately through calibration.
Does calibration improve accuracy?
Standard temperature scaling usually does not change class rankings; its primary goal is the reliability of confidence scores.
References and further reading
The primary sources below explain the methods and evaluation protocols. Numerical scenarios in this article are educational examples, not measured results from a facility or model.