Unsupervised Calibration under Covariate Shift

Anusri Pampari, Stefano Ermon

Abstract

In high-stakes applications like medical diagnosis and autonomous driving, the reliability of a model's confidence scores—known as calibration—is as critical as its predictive accuracy. However, calibration is highly sensitive to covariate shift, where the input distribution changes between training and deployment. This paper presents a novel, unsupervised importance-sampling framework to recalibrate models for a target domain without requiring ground-truth labels. By estimating density ratios over domain-invariant features, the proposed method effectively aligns confidence scores with empirical frequencies, significantly outperforming standard post-hoc calibration techniques in shifted environments.

Introduction

A well-calibrated model ensures that a predicted probability of 70% corresponds to a 70% empirical frequency of the event occurring. While modern neural networks are notoriously overconfident, techniques like Temperature Scaling can typically correct this using a labeled validation set. However, these methods rely on the assumption that validation and test data are independent and identically distributed (i.i.d.). In practice, this assumption is frequently violated by covariate shift: the conditional distribution of labels given inputs $P(Y|X)$ remains constant, but the marginal distribution of inputs $P(X)$ changes.

The Challenge of Covariate Shift

Existing Domain Adaptation (DA) techniques focus primarily on maintaining accuracy during distribution shifts. Research by Anusri Pampari and Stefano Ermon reveals that DA does little to preserve calibration. In fact, applying standard calibration on source-domain data can lead to even less reliable confidence scores on the target domain than using an uncalibrated model. This "miscalibration trap" occurs because the calibration parameters learned on the source distribution do not generalize to the regions of the feature space emphasized in the target distribution.

Visualization of covariate shift between source and target domains and its impact on calibration curves.

Proposed Method: Importance Weighted Calibration

To address this, the authors propose Importance Weighted Calibration. The framework estimates the calibration error on the unlabeled target domain by reweighting source-domain samples.

  1. Importance Sampling: The target calibration error is estimated using the identity $\mathbb{E}_{P_{target}}[L] = \mathbb{E}_{P_{source}}[\gamma(x)L]$, where $\gamma(x) = \frac{P_{target}(x)}{P_{source}(x)}$ is the density ratio.
  2. Density Ratio Estimation: A binary discriminator is trained to distinguish between source and target samples, providing an estimate for $\gamma(x)$.
  3. Domain-Invariant Features: To mitigate the high variance of density estimation in high-dimensional spaces, the weights are calculated using internal representations from DA models (e.g., CDAN) that are designed to be domain-invariant.
  4. Weighted Scaling: These weights are integrated into post-hoc methods like Platt or Temperature Scaling to find optimal calibration parameters for the target domain.

Experimental Results

The method was evaluated on several benchmarks, including CIFAR-10 (with synthetic shift), Digits (MNIST $\leftrightarrow$ USPS), and the Office-31 and Office-Home datasets.

Reliability diagram comparing uncalibrated models, standard t-scaling, and the proposed weighted t-scaling against the ideal perfect calibration.

The "Weighted" approach consistently moved models closer to perfect calibration. For instance:

  • Office-31 (D $\to$ A): Expected Calibration Error (ECE) was reduced from 14.7% (uncalibrated) to 6.0% using weighted scaling.
  • Digits (M $\to$ U): ECE dropped from 20.6% to 7.7%.

The results demonstrate that understanding the shift in input distribution is sufficient to recalibrate models, even in the absence of target-domain labels.

Conclusion

Unsupervised calibration under covariate shift is a vital step toward deploying reliable machine learning systems in dynamic environments. By accounting for distribution shifts through importance weighting, this work provides a robust mechanism to keep models "honest" when the world changes, ensuring that confidence scores remain a trustworthy guide for decision-making.

Summary updated

BibTeX
@misc{pampari2020unsupervised,
  author = {Anusri Pampari and Stefano Ermon},
  title = {{Unsupervised Calibration under Covariate Shift}},
  year = {2020},
  eprint = {2006.16405},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2006.16405},
}
Figure