Table of Contents
Fetching ...

Detecting and Correcting for Label Shift with Black Box Predictors

Zachary C. Lipton, Yu-Xiang Wang, Alex Smola

TL;DR

This work tackles label shift, where $q(y)$ changes between training and deployment while $p(x|y)$ stays fixed, by introducing Black Box Shift Estimation (BBSE). BBSE leverages a fixed black-box predictor with invertible confusion matrices to recover the label ratio $w(y)=q(y)/p(y)$ from unlabeled test data, enabling both shift detection (BBSD) and prediction correction (BBSC) via importance-weighted ERM. The authors prove consistency and finite-sample error bounds for BBSE, present a practical two-sample test for shift detection, and demonstrate improved performance on high-dimensional datasets (e.g., MNIST, CIFAR-10) compared to kernel-based domain adaptation methods. The framework provides a scalable, theoretically grounded approach for detecting and correcting label shift without test labels, with broad applicability to medical diagnosis and other real-world deployment settings.

Abstract

Faced with distribution shift between training and test set, we wish to detect and quantify the shift, and to correct our classifiers without test set labels. Motivated by medical diagnosis, where diseases (targets) cause symptoms (observations), we focus on label shift, where the label marginal $p(y)$ changes but the conditional $p(x| y)$ does not. We propose Black Box Shift Estimation (BBSE) to estimate the test distribution $p(y)$. BBSE exploits arbitrary black box predictors to reduce dimensionality prior to shift correction. While better predictors give tighter estimates, BBSE works even when predictors are biased, inaccurate, or uncalibrated, so long as their confusion matrices are invertible. We prove BBSE's consistency, bound its error, and introduce a statistical test that uses BBSE to detect shift. We also leverage BBSE to correct classifiers. Experiments demonstrate accurate estimates and improved prediction, even on high-dimensional datasets of natural images.

Detecting and Correcting for Label Shift with Black Box Predictors

TL;DR

This work tackles label shift, where changes between training and deployment while stays fixed, by introducing Black Box Shift Estimation (BBSE). BBSE leverages a fixed black-box predictor with invertible confusion matrices to recover the label ratio from unlabeled test data, enabling both shift detection (BBSD) and prediction correction (BBSC) via importance-weighted ERM. The authors prove consistency and finite-sample error bounds for BBSE, present a practical two-sample test for shift detection, and demonstrate improved performance on high-dimensional datasets (e.g., MNIST, CIFAR-10) compared to kernel-based domain adaptation methods. The framework provides a scalable, theoretically grounded approach for detecting and correcting label shift without test labels, with broad applicability to medical diagnosis and other real-world deployment settings.

Abstract

Faced with distribution shift between training and test set, we wish to detect and quantify the shift, and to correct our classifiers without test set labels. Motivated by medical diagnosis, where diseases (targets) cause symptoms (observations), we focus on label shift, where the label marginal changes but the conditional does not. We propose Black Box Shift Estimation (BBSE) to estimate the test distribution . BBSE exploits arbitrary black box predictors to reduce dimensionality prior to shift correction. While better predictors give tighter estimates, BBSE works even when predictors are biased, inaccurate, or uncalibrated, so long as their confusion matrices are invertible. We prove BBSE's consistency, bound its error, and introduce a statistical test that uses BBSE to detect shift. We also leverage BBSE to correct classifiers. Experiments demonstrate accurate estimates and improved prediction, even on high-dimensional datasets of natural images.

Paper Structure

This paper contains 15 sections, 7 theorems, 32 equations, 5 figures, 1 algorithm.

Key Result

Lemma 1

Denote by $\hat{y} = f(\boldsymbol x)$ the output of a fixed function $f: \mathcal{X} \rightarrow \mathcal{Y}$. If Assumption A.1 holds, then

Figures (5)

  • Figure 1: Label-shift detection on MNIST. Pane \ref{['fig:alpha_level_control']} illustrates that Type I error is correctly controlled absent label shift. Pane \ref{['fig:power_at_0.6']} illustrates high power under mild label-shift. Pane \ref{['fig:power_vs_oracle']} shows increased power for better classifiers. We compare to kernel two-sample tests zaremba2013b and an (infeasible) oracle two sample test that directly tests $p(y) = q(y)$ with samples from each. The proposed test beats directly testing in high-dimensions and nearly matches the oracle.
  • Figure 2: Estimation error (top row) and correction accuracy (bottom row) vs dataset size on MNIST data compared to KMM zhang2013domain under Dirichlet shift (left to right) with $\alpha = \{.1,1.0,10.0\}$ (smaller $\alpha$ means larger shift). BBSE confidence interval on $20$ runs, KMM on $5$ runs due to computation; $n=8000$ is largest feasible KMM experiment.
  • Figure 3: Label-shift estimation and correction on MNIST data with simulated tweak-one shift with parameter $\rho$.
  • Figure 4: Accuracy of BBSC on CIFAR 10 with (top) tweak-one shift and (bottom) Dirichlet shift.
  • Figure 5: The smallest singular value of the estimated confusion matrix: $\hat{C}_f$ under distribution $p$ as a function of the number of epochs we train the classifiers on.

Theorems & Definitions (11)

  • Lemma 1
  • Proposition 2: Consistency
  • Theorem 3: Error bounds
  • proof : Proof of Theorem \ref{['thm:estimating_ratios']}
  • Proposition 4: Detecting label-shift
  • proof
  • Proposition 5: Detecting general nonstationarity
  • proof : Proof of Lemma \ref{['lem:matching_confusion']}
  • proof : Proof of Proposition \ref{['prop:consistency']}
  • Lemma 6: Hoeffding's inequality
  • ...and 1 more