Beyond Invariance: Test-Time Label-Shift Adaptation for Addressing "Spurious" Correlations

Qingyao Sun, Kevin Patrick Murphy, Sayna Ebrahimi, Alexander D'Amour

Introduction

Predictive models frequently latch onto spurious correlations—shortcuts in the training data that do not fundamentally relate to the target task. For example, a model might learn to identify "pneumonia" in chest X-rays by detecting patient demographics or hospital-specific equipment markers rather than actual lung pathology.

When these models are deployed in a new target domain (e.g., a different hospital) where those correlations shift, performance typically degrades. The standard research response has been to seek invariance: training models to ignore these nuisance factors entirely. However, this paper argues that "spurious" features actually contain valuable predictive information. If a specific demographic group has a higher prevalence of a disease, that correlation serves as a useful prior. Instead of discarding this information, the authors propose Test-Time Label-Shift Adaptation (TTLSA), a method that embraces these correlations by adapting to how they change in new environments at test time.

Methodology

The authors introduce a framework based on an expanded label shift assumption. They define a "meta-label" $m = (y, z)$, where $y$ is the actual class label and $z$ represents nuisance factors (such as group labels or demographics).

The core assumption is that while the generative relationship between the features and the meta-label, $p(x|y, z)$, remains invariant across different domains, the prior distribution of the meta-labels themselves, $p(y, z)$, shifts.

Causal modeling assumptions. $U$ is a hidden confounder that changes the relationship between labels $Y$ and nuisance factors $Z$, but the way features $X$ are generated from $(Y, Z)$ remains fixed.

TTLSA operates in two primary steps:

  1. Source Training: A standard discriminative model is trained on the source data to predict the joint meta-label $(y, z)$. Crucially, a calibration step (such as temperature scaling) is applied to ensure the model's confidence scores reflect reliable probabilities.
  2. Test-Time Adaptation: When the model encounters a batch of unlabeled data from a new target domain, it employs an Expectation-Maximization (EM) algorithm to estimate the new distribution of meta-labels $p_t(y, z)$. It then reweights its original predictions using this updated prior to make final classifications.

This approach is highly efficient because it avoids retraining the base model or fitting a complex generative model for every new environment; it simply adjusts the prior on the fly.

Datasets and Experimental Setup

The authors evaluated TTLSA on a mix of synthetic and real-world datasets:

  • Colored MNIST: A classic benchmark where digit color acts as a spurious correlate for the digit's identity.
  • CheXpert: A large-scale medical dataset of chest X-rays where patient sex is treated as a nuisance factor.
  • Robustness Benchmarks: CelebA (faces), Waterbirds (birds on backgrounds), MultiNLI (text entailment), and CivilComments (online forum toxicity).

Key Insights and Results

TTLSA consistently outperformed both standard Empirical Risk Minimization (ERM) and state-of-the-art invariant learning methods.

  • Spuriousness as a Feature: Invariant models discard information to maintain robustness. TTLSA demonstrates that if the nuisance factor $z$ can be predicted from the input $x$, it can be used to improve the prediction of $y$, provided the current correlation between $y$ and $z$ is known.
  • The "U-Shaped" Performance Curve: Invariant models (like SUBG or LA) exhibit flat performance across different distribution shifts. TTLSA, however, creates a distinct U-shape: it performs best when correlations are strong (even if they are the opposite of the training data) and matches invariant models when there is no correlation to exploit.
  • The Importance of Calibration: The method relies heavily on the accuracy of the model's predicted probabilities. Without proper calibration, the EM algorithm's estimates of the target distribution become unreliable.
Test set AUC performance. Note the "U-shape" for TTLSA (purple/brown lines), showing it exploits correlations in the target domain to beat invariant models (flat lines).

On datasets like Colored MNIST and CheXpert, TTLSA achieved significantly higher AUC than invariant baselines across almost all shift parameters, effectively matching the performance of an "Oracle" model that perfectly knows the target distribution. On benchmarks like Waterbirds and CelebA, TTLSA provided a unified approach that achieved competitive worst-group accuracy while maintaining or improving average accuracy compared to specialized methods like gDRO.

Limitations and Future Work

While powerful, TTLSA has notable limitations:

  • Requirement for $z$ labels: The method currently requires nuisance factors (like race or sex) to be labeled in the training data, which may not always be feasible or ethical.
  • Dimensionality: If the nuisance factor $z$ is highly dimensional, the EM algorithm may become computationally expensive or require significantly more unlabeled test data to converge.

Future directions suggested by the authors include exploring semi-supervised methods to relax the requirement for $z$ labels during training, and investigating fully unsupervised approaches to estimate confounding factors.

Summary updated

BibTeX
@inproceedings{sun2023beyond,
  author = {Qingyao Sun and Kevin Patrick Murphy and Sayna Ebrahimi and Alexander D'Amour},
  title = {{Beyond Invariance: Test-Time Label-Shift Adaptation for Addressing "Spurious" Correlations}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=9mJXDcr17V},
}
Figure