Calibrating multi-class models

Ulf Johansson, Tuwe Löfström, Henrik BoströmCOPA 2021

Abstract

Predictive models communicating algorithmic confidence are very informative, but only if well-calibrated and sharp, i.e., providing accurate probability estimates adjusted for each instance. While almost all machine learning algorithms are able to produce probability estimates, these are often poorly calibrated, thus requiring external calibration. For multiclass problems, external calibration has typically been done using one-vs-all or all-vs-all schemes, thus adding to the computational complexity, but also making it impossible to analyze and inspect the predictive models. In this paper, we suggest a novel approach for calibrating inherently multi-class models. Instead of providing a probability distribution over all labels, the estimation is of the probability that the class label predicted by the underlying model is correct. In an extensive empirical study, it is shown that the suggested approach, when applied to both Platt scaling and Venn-Abers, is able to improve the probability estimates from decision trees, random forests and extreme gradient boosting.

Introduction

Most machine learning classifiers—from decision trees to neural networks—output "confidence scores" or "probabilities." However, these numbers are rarely well-calibrated. If a model says it is 90% sure of a prediction, we expect it to be right 90% of the time. In reality, models are often wildly overconfident (common in decision trees) or underconfident (common in random forests).

For binary classification, standard tools exist to fix this. However, for multi-class problems (e.g., classifying an image as a cat, dog, or bird), the standard approach is to train a separate calibrator for every single class (one-vs-all). This is computationally expensive and, more importantly, it destroys the interpretability of the model. You no longer have one model making a decision; you have a committee of models, making it nearly impossible to inspect the logic behind a specific prediction. This paper introduces a streamlined approach to calibrating multi-class machine learning models by focusing solely on the probability that the model's top prediction is correct.

Methodology: The Predicted-vs-Rest Approach

The authors propose a "predicted-vs-rest" approach. Instead of trying to calibrate the entire probability distribution across all possible labels, they focus on a single question: What is the probability that the label the model just chose is actually correct?

The process follows three main steps:

  1. The Setup: An underlying multi-class model (like a Random Forest) makes a prediction.
  2. The Simplification: The predicted label is treated as the "positive" class, and all other labels are lumped into the "negative" class.
  3. The Calibration: Two well-known binary calibration techniques are applied to this simplified setup:
  4. Platt Scaling: Fits a logistic regression (sigmoid) function to the model's scores.
  5. Venn-Abers Predictors (VA): A more sophisticated approach based on isotonic regression that provides a probability interval $[p_0, p_1]$ rather than a single number, offering theoretical "validity" guarantees.

Crucially, the calibration process is not allowed to change the predicted label; it only adjusts the confidence score associated with that label, preserving the original model's decision logic.

Experimental Setup

The researchers evaluated their approach using 20 publicly available multi-class datasets from the UCI Machine Learning Repository. These datasets varied significantly in size, class count, and feature complexity.

Summary of the 20 multi-class datasets used in the empirical study.

The variety of datasets, ranging from the simple Iris set to the more complex Vowel and Steel datasets, ensured the method was tested against different class balances and feature complexities.

Results and Discussion

The study measured success using Expected Calibration Error (ECE)—the difference between predicted confidence and actual accuracy—and Log Loss.

Model "Personalities" and Calibration Impact

The paper highlights distinct calibration behaviors across algorithms. Decision trees are "extremely overconfident," often reporting 100% confidence for incorrect guesses. Random forests, conversely, tend to be "underconfident," especially for high-probability estimates. XGBoost models were also found to be generally overconfident.

Calibration led to significant improvements:

  • Decision Trees: Uncalibrated trees had an average ECE of 0.140, which dropped to 0.027 using Venn-Abers.
  • Random Forests: ECE dropped from 0.071 to 0.027 (Platt) and 0.030 (VA).
  • XGBoost: Calibration reduced ECE from 0.084 to 0.038.

Preserving Interpretability

By avoiding one-vs-all schemes, the researchers maintain the interpretability of the underlying model. For instance, in a single decision tree, one can still trace the path to a leaf node, but that leaf now provides a statistically sound probability of being correct.

A calibrated decision tree showing Venn-Abers probability intervals at the leaf nodes.

As shown in the figure above, the Venn-Abers approach provides probability intervals that almost always cover the empirical accuracy, giving users an "honesty" metric for how much they should trust a specific prediction.

Conclusion

The primary limitation of this approach is the "data tax": calibration requires a separate calibration set, which can reduce the data available for initial training. This often leads to a slight decrease in overall accuracy and AUC. Future work could investigate "out-of-bag" calibration for ensembles to mitigate this. While the "predicted-vs-rest" logic is sufficient for many decision-support systems, future research could explore extending this logic to the second or third most likely classes without re-introducing the complexity of traditional multi-class calibration schemes.

Summary updated

BibTeX
@inproceedings{johansson2021calibrating,
  author = {Ulf Johansson and Tuwe Löfström and Henrik Boström},
  title = {{Calibrating multi-class models}},
  booktitle = {COPA},
  year = {2021},
  url = {https://openreview.net/forum?id=QuwswPF5l0},
}
Figure