Class Probability Matching with Calibrated Networks for Label Shift Adaption

Hongwei Wen, Annika Betken, Hanyuan HangICLR 2024

In the real world, data distributions rarely stay still. A model trained to diagnose diseases in one hospital might struggle in another if the prevalence of those diseases—the "label distribution"—is different, even if the symptoms (the features) remain the same. This common challenge in machine learning is known as label shift.

A recent paper from ICLR 2024, Class Probability Matching with Calibrated Networks for Label Shift Adaptation, introduces a clever and computationally efficient way to tackle this problem. By shifting the focus from complex feature distributions to simple label probabilities, the authors provide a method that is both faster and more accurate than previous state-of-the-art approaches.

The Challenge of Label Shift

Label shift adaptation is a sub-field of domain adaptation. It assumes that while the probability of seeing a specific class changes between the source (training) and target (deployment) domains ($p(y) \neq q(y)$), the way features look given a class remains constant ($p(x|y) = q(x|y)$).

The goal is to estimate the target domain's conditional probability $q(y|x)$ so we can build an accurate classifier for the new environment. This usually involves estimating the class probability ratio $w^*_y = q(y)/p(y)$.

Existing solutions generally fall into two camps, both with significant drawbacks:

  1. Feature Matching: These methods try to match the marginal distribution of features $X$. Because $X$ is high-dimensional, this is computationally brutal (often scaling at $O(n^3)$) or requires training complex Generative Adversarial Networks (GANs).
  2. Prediction Matching: These match the distributions of predicted labels. While faster, they are hampered by the inherent errors and biases of the classifier used to make those predictions.

The authors identified a critical gap: the field needed a method with the theoretical rigor of feature matching, but the efficiency of working in a lower-dimensional space.

A New Framework: Class Probability Matching (CPM)

The authors introduce Class Probability Matching (CPM). Their key insight is a mathematical proof demonstrating that matching the $d$-dimensional feature distributions is theoretically equivalent to matching the 1-dimensional label distributions under the label shift assumption.

Instead of trying to align complex, high-dimensional feature clouds, CPM finds the weights $w$ that satisfy a set of $K$ equations (where $K$ is the number of classes). This massive reduction in dimensionality leads to much faster computation without sacrificing theoretical guarantees.

The CPMCN Algorithm

To make this framework work in practice, the researchers propose the Class Probability Matching with Calibrated Networks (CPMCN) algorithm:

  • Calibration is Key: Deep neural networks are notoriously overconfident. For CPM to work effectively, the estimated probabilities $p(y|x)$ must be accurate. The authors use Bias-Corrected Temperature Scaling (BCTS) to calibrate their networks, significantly reducing the "bias term" in the estimation error without inflating variance.
  • The Matching Step: The algorithm estimates the source class probabilities $p(y)$ and then uses the calibrated network to find weights that align these with the target domain's data.
  • Optimization: The resulting minimization problem is solved efficiently using standard optimizers like BFGS.

Experimental Results

The researchers evaluated their method on standard computer vision benchmarks (MNIST, CIFAR-10, and CIFAR-100). To simulate label shift, they used Dirichlet shift (varying class prevalence smoothly) and tweak-one shift (drastically changing the prevalence of a single class).

CPMCN consistently outperformed existing matching-based (LTF, BBSL, RLLS, ELSA) and EM-based algorithms across all datasets and shift types.

As shown in the performance table below for CIFAR-100 under Dirichlet shift, CPMCN achieves the highest classification accuracy (ACC) and the lowest error in estimating the class probability ratios (MSE_EVEN and MSE_PROP) across various shift intensities (denoted by $\alpha$).

Performance comparison on CIFAR-100 under Dirichlet shift. CPMCN (bottom row) shows superior accuracy and lower error metrics across various shift intensities (alpha).

Beyond accuracy, CPMCN shines in computational efficiency. Because it only deals with $K$ equations, CPMCN's complexity is $O(n_q K^2)$ per iteration. While traditional methods like Kernel Mean Matching (KMM) can take over 10,000 seconds on CIFAR-100 without finishing, CPMCN completes the task in a fraction of a second, proving its readiness for large-scale, real-world applications.

Limitations and Future Work

The primary limitation of this approach is its core assumption: pure label shift. In many real-world scenarios, practitioners might encounter "concept drift" or "covariate shift" simultaneously, where the conditional feature distribution $p(x|y)$ also changes.

The authors acknowledge this constraint and suggest that extending the CPM framework to handle concurrent shifts is a promising direction for future research. Additionally, the method relies on having a reasonably good (and calibratable) initial classifier trained on the source domain.

Summary updated

BibTeX
@inproceedings{wen2024class,
  author = {Hongwei Wen and Annika Betken and Hanyuan Hang},
  title = {{Class Probability Matching with Calibrated Networks for Label Shift Adaption}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=mliQ2huFrZ},
}
Figure