When Does Optimizing a Proper Loss Yield Calibration?

Jaroslaw Blasiok, Parikshit Gopalan, Lunjia Hu, Preetum Nakkiran

TL;DR

This paper bridges the gap between the theoretical ideal of "proper losses" and the messy reality of training neural networks. The authors prove that you don't need to reach a global minimum to get a calibrated model; instead, if your model is "locally optimal"—meaning its loss can't be significantly improved by simple post-processing—it is guaranteed to be well-calibrated.

What Problem Does This Paper Address?

In machine learning, we want our models to be both accurate and calibrated. A calibrated model is one where a "70% probability" prediction actually corresponds to a 70% success rate in the real world.

There is a long-standing "folklore" belief that minimizing a proper loss (like cross-entropy or squared error) automatically leads to calibration. Theoretically, this is true at the global optimum: the function that perfectly minimizes these losses is the ground-truth probability, which is perfectly calibrated.

However, we never reach the global optimum. We train models with restricted capacity (like a specific DNN architecture) using local search (like SGD). Under these constraints, does loss minimization still guarantee calibration? This paper provides the first rigorous theoretical framework to answer "yes," provided certain local conditions are met.

Methods

The authors introduce a novel local optimality condition based on the post-processing gap (pGap).

  1. The Post-processing Gap: Instead of looking at the global minimum, they ask: "Can we significantly reduce the model's loss by applying a simple, smooth (Lipschitz) function to its current predictions?" If the answer is no, the model has a small post-processing gap.
  2. Smooth Calibration (smCE): They use "smooth calibration" as their primary metric. Unlike the standard Expected Calibration Error (ECE), which can be jumpy and hard to analyze, smCE measures calibration by looking at the correlation between prediction errors and smooth functions of the predictions.
  3. Convex Duality: To handle complex losses like cross-entropy, the authors use the machinery of convex duality. They show that for any proper loss, there is a "dual" space (like the "logit" space for cross-entropy) where the relationship between loss and calibration becomes mathematically clear.
  4. Theoretical Proofs: They prove a quadratic relationship between the post-processing gap and calibration error. Specifically, for squared loss, they show that $smCE^2 \le pGap \le 2 \cdot smCE$.

Datasets

This is a theoretical paper and does not perform new experiments on empirical datasets. However, it provides a mathematical explanation for empirical phenomena observed in prior literature involving:

  • Modern DNNs: References to the high "out-of-the-box" calibration of models like GPT-4 and modern image classifiers.
  • Logistic Regression: Analysis of why simple models like logistic regression can fail to calibrate on certain distributions (illustrated with a 1D synthetic overlapping uniform distribution).

Key Insights and Ideas

  • Calibration is a Local Property: You don't need to find the "best possible" model to be calibrated. You just need a model that can't be easily improved by a simple "tweak" to its output probabilities.
  • The "Human-in-the-loop" Heuristic: The authors argue that if a practitioner could significantly improve a model's test loss just by adding a final sigmoid or scaling layer, they would have already done so. Therefore, state-of-the-art models that have been "fully trained" are likely to have a small post-processing gap and, by extension, good calibration.
  • Depth is a Calibration Tool: Deep neural networks are powerful because they can "internalize" these post-processing functions. A deep model has the capacity to perform its own internal re-calibration during training, whereas a shallow model (like logistic regression) might be "stuck" in a miscalibrated state because it lacks the functional complexity to reduce its loss further.
  • The Connection Goes Both Ways: Not only does local optimality imply calibration, but nearly calibrated predictors are also nearly locally optimal. This suggests that calibration is a fundamental signature of a model that has "extracted all the easy gains" from the data.

Key Results

  • The Quadratic Bound: For the squared loss, the authors prove that the smooth calibration error is bounded by the square root of the post-processing gap. This provides a formal "exchange rate" between loss and calibration.
  • Generalization to Cross-Entropy: They extend this result to the cross-entropy loss (the standard for classification), showing that minimizing loss in the logit space (dual space) effectively minimizes calibration error.
  • Structural Risk Minimization (SRM): They prove that a standard learning strategy—minimizing loss plus a complexity penalty—is guaranteed to produce a calibrated predictor, provided the model family is "flexible" enough to handle its own post-processing.

Limitations and Future Work

  • The SGD Gap: While the paper provides a strong link between local minima and calibration, it relies on the heuristic assumption that SGD actually finds these specific types of local minima on natural datasets. A formal proof connecting the dynamics of SGD to this local optimality condition remains an open challenge.
  • Binary Focus: The current theory is developed for binary labels ($y \in \{0, 1\}$). Extending these tight quadratic bounds to multi-class settings is a suggested direction for future research.
  • Complexity Measures: The results for Structural Risk Minimization depend on the complexity measure not growing too fast under post-processing. Defining which real-world complexity measures (like weight norms in DNNs) satisfy this is still being explored.

Summary updated

Abstract

Optimizing proper loss functions is popularly believed to yield predictors with good calibration properties; the intuition being that for such losses, the global optimum is to predict the ground-truth probabilities, which is indeed calibrated. However, typical machine learning models are trained to approximately minimize loss over restricted families of predictors, that are unlikely to contain the ground truth. Under what circumstances does optimizing proper loss over a restricted family yield calibrated models? What precise calibration guarantees does it give? In this work, we provide a rigorous answer to these questions. We replace the global optimality with a local optimality condition stipulating that the (proper) loss of the predictor cannot be reduced much by post-processing its predictions with a certain family of Lipschitz functions. We show that any predictor with this local optimality satisfies smooth calibration as defined in [Kakade and Foster, 2008, Błasiok et al., 2023]. Local optimality is plausibly satisfied by well-trained DNNs, which suggests an explanation for why they are calibrated from proper loss minimization alone. Finally, we show that the connection between local optimality and calibration error goes both ways: nearly calibrated predictors are also nearly locally optimal.
BibTeX
@inproceedings{blasiok2023when,
  author = {Jaroslaw Blasiok and Parikshit Gopalan and Lunjia Hu and Preetum Nakkiran},
  title = {{When Does Optimizing a Proper Loss Yield Calibration?}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=8kyIChWsAG},
}
Figure