Tutorials › Statistical Learning (Graduate) › Identifiability Of Label Shift From Confusion Matrices

Robustness and Distribution Shift · Tutorial 974 of 989

Identifiability Of Label Shift From Confusion Matrices

Learn to express label-shift identification as a linear system and determine exactly when its confusion matrix uniquely identifies target class prevalences.

Advanced 9 min read

What You'll Learn

  • Define the source confusion matrix with predicted classes as rows and true classes as columns
  • Derive the target predicted-label frequency equation under class-conditional invariance
  • Prove the full-column-rank criterion for global identifiability over the probability simplex
  • Recognize how dependent confusion-matrix columns create indistinguishable prevalences
  • Distinguish exact identifiability from numerical stability

Why Confusion-Matrix Identifiability Matters

Under label shift, the distribution of features within each class is unchanged between source and target populations, while the class prevalences may change. This makes it possible, in principle, to use a fixed classifier’s predictions on target observations to learn about target class prevalences. But that is possible only if the classifier’s class-conditional prediction patterns distinguish the classes. The relevant question is therefore not merely whether the classifier makes errors; it is whether its confusion probabilities preserve enough information to separate the target class proportions.

We make that question precise using a finite number \(K\) of classes. The classifier is fixed throughout, and its predictions are evaluated under the source population to form a population confusion matrix. The key result is an exact criterion: target class prevalences are globally identifiable from target predicted-label frequencies if and only if that matrix has full column rank.

The Linear System Under Label Shift

Definition: Let \(Y\in\{1,\ldots,K\}\) be the true class and let \(h(X)\in\{1,\ldots,K\}\) be a fixed classifier’s predicted class. The source confusion matrix \(C\) has entries \(C_{ij}=P_s(h(X)=i\mid Y=j)\). Thus rows index predicted classes and columns index true classes. Write \(\pi_t\in\mathbb{R}^K\) for the target class-prevalence vector, with entries \((\pi_t)_j=P_t(Y=j)\), and \(q_t\in\mathbb{R}^K\) for the target predicted-label frequency vector, with entries \((q_t)_i=P_t(h(X)=i)\).

Each column of \(C\) is a probability distribution over predicted classes. In particular, its entries are nonnegative and sum to one: \(\sum_{i=1}^K C_{ij}=1\). The prevalence vector also lies in the probability simplex \(\Delta^{K-1}=\{u\in\mathbb{R}^K:u_j\geq 0,\ \sum_j u_j=1\}\).

Label shift means class-conditional invariance: \(P_t(X\mid Y=j)=P_s(X\mid Y=j)\) for each class \(j\) whose target prevalence is positive. Since the classifier \(h\) is the same in both populations, this implies \(P_t(h(X)=i\mid Y=j)=C_{ij}\). Applying the law of total probability gives the system linking predicted frequencies to prevalences.

$$ \begin{aligned} (q_t)_i &=P_t(h(X)=i)\\ &=\sum_{j=1}^K P_t(h(X)=i\mid Y=j)P_t(Y=j)\\ &=\sum_{j=1}^K C_{ij}(\pi_t)_j,\qquad i=1,\ldots,K. \end{aligned} \qquad\text{or, in vector form,}\qquad q_t=C\pi_t. $$

The equation is a population statement: it relates exact probabilities, not sample proportions. It uses class-conditional invariance and a common fixed classifier. If the classifier changes, or if its prediction probabilities within a class change across populations, the same source matrix need not link \(q_t\) and \(\pi_t\).

Worked Example: Recovering Two Target Prevalences

Suppose the source confusion matrix and target predicted-label frequencies are

$$ C= \begin{pmatrix} 0.9&0.2\\ 0.1&0.8 \end{pmatrix}, \qquad q_t= \begin{pmatrix} 0.62\\ 0.38 \end{pmatrix}. $$

Let \(\pi_t=(p,1-p)^\mathsf{T}\). The first predicted-label frequency gives \(0.9p+0.2(1-p)=0.62\). Simplifying, \(0.7p+0.2=0.62\), so \(p=0.42/0.7=0.6\). Therefore \(\pi_t=(0.6,0.4)^\mathsf{T}\).

The second row checks the answer: \(0.1(0.6)+0.8(0.4)=0.06+0.32=0.38\), as required. The columns of \(C\) are linearly independent because its determinant is \(0.9(0.8)-0.2(0.1)=0.70\), which is nonzero. Here the system has a unique solution.

Identifiability and the Rank Criterion

Definition: For a fixed confusion matrix \(C\), target prevalences are globally identifiable from target predicted-label frequencies over the simplex if the map \(u\mapsto Cu\) is one-to-one on \(\Delta^{K-1}\). Equivalently, no two distinct prevalence vectors in the simplex produce the same predicted-label frequency vector.

This definition is about uniqueness, not about how to compute an estimate from finite data. The set of feasible predicted-frequency vectors is \(\{Cu:u\in\Delta^{K-1}\}\), the convex hull of the columns of \(C\). If two columns or combinations of columns overlap in a way that gives distinct simplex vectors the same image, the observed predicted frequencies cannot distinguish those prevalences.

Theorem: Suppose \(C\) is a \(K\times K\) column-stochastic confusion matrix. The map \(u\mapsto Cu\) is one-to-one on \(\Delta^{K-1}\) if and only if \(C\) has full column rank.

Proof. First suppose \(C\) has full column rank. Then its null space contains only the zero vector. If \(u,v\in\Delta^{K-1}\) satisfy \(Cu=Cv\), then \(C(u-v)=0\). Full column rank implies \(u-v=0\), so \(u=v\). Thus the map is one-to-one on the simplex.

Conversely, suppose \(C\) does not have full column rank. There is a nonzero vector \(a\in\mathbb{R}^K\) such that \(Ca=0\). Let \(\mathbf{1}\) denote the vector of \(K\) ones. Column-stochasticity gives \(\mathbf{1}^\mathsf{T}C=\mathbf{1}^\mathsf{T}\), and hence \(\mathbf{1}^\mathsf{T}a=\mathbf{1}^\mathsf{T}Ca=0\). Thus the entries of \(a\) sum to zero.

Consider the interior simplex point \(u_0=(1/K,\ldots,1/K)^\mathsf{T}\). Because \(a\neq 0\), we can choose \(\epsilon>0\) small enough that every entry of both \(u_0+\epsilon a\) and \(u_0-\epsilon a\) is nonnegative. Both vectors sum to one because \(\mathbf{1}^\mathsf{T}a=0\), so both belong to the simplex. They are distinct, and \(C(u_0+\epsilon a)=Cu_0=C(u_0-\epsilon a)\). The map is therefore not one-to-one. This proves both directions. \(\square\)

The result is global over the full simplex. At a particular boundary prevalence vector, a rank-deficient matrix can still yield a unique feasible solution; the theorem does not claim otherwise. It says that without restricting the possible prevalences in advance, rank deficiency prevents global identification.

Worked Example: A Full-Rank Three-Class Matrix

Consider a classifier with the following confusion matrix and target predicted-label frequencies:

$$ C= \begin{pmatrix} 0.8&0.1&0.1\\ 0.1&0.8&0.1\\ 0.1&0.1&0.8 \end{pmatrix}, \qquad q_t= \begin{pmatrix} 0.5\\ 0.3\\ 0.2 \end{pmatrix}. $$

This matrix can be written \(C=0.7I+0.1\mathbf{1}\mathbf{1}^\mathsf{T}\). It has eigenvalue \(1\) in the direction \(\mathbf{1}\), and eigenvalue \(0.7\) on vectors whose entries sum to zero. These eigenvalues are nonzero, so \(C\) has full rank and the theorem guarantees unique identification.

For any prevalence vector with entries summing to one, \(C\pi_t=0.7\pi_t+0.1\mathbf{1}\). Therefore \(0.7\pi_t=q_t-0.1\mathbf{1}=(0.4,0.2,0.1)^\mathsf{T}\). Dividing by \(0.7\) gives \(\pi_t=(4/7,2/7,1/7)^\mathsf{T}\). The entries sum to \(1\), and substitution gives predicted frequencies \((0.4+0.1,0.2+0.1,0.1+0.1)^\mathsf{T}=(0.5,0.3,0.2)^\mathsf{T}\).

Worked Example: Dependent Columns Hide Prevalence Differences

Suppose a three-class confusion matrix has columns \(c_1=(0.8,0.1,0.1)^\mathsf{T}\), \(c_2=(0.1,0.8,0.1)^\mathsf{T}\), and \(c_3=(0.45,0.45,0.1)^\mathsf{T}\). Each is a valid probability vector, and \(c_3=\tfrac12c_1+\tfrac12c_2\). Thus the columns are linearly dependent.

If the target prevalence is \(\pi_t=(0,0,1)^\mathsf{T}\), then \(q_t=c_3=(0.45,0.45,0.1)^\mathsf{T}\). But the different prevalence vector \((0.5,0.5,0)^\mathsf{T}\) gives \(\tfrac12c_1+\tfrac12c_2=(0.45,0.45,0.1)^\mathsf{T}\) as well. Both are valid simplex points, so the same target predicted-label frequencies correspond to two different target class compositions.

This example displays the geometry directly: the third column lies on the line segment between the first two. A mixture consisting entirely of class 3 is indistinguishable, through this classifier’s predicted-label frequencies, from an equal mixture of classes 1 and 2.

What Full Rank Does—and Does Not—Guarantee

Full column rank guarantees uniqueness in the exact population system when the model is compatible, meaning the observed \(q_t\) lies in the image of the simplex under \(C\). It does not guarantee that the unique prevalence vector can be recovered precisely from noisy estimates of predicted frequencies or an estimated confusion matrix. A matrix can be full rank but nearly rank deficient: its columns are technically independent but very close to lying in a lower-dimensional subspace.

For a square invertible \(C\), a perturbation \(\delta q\) in predicted frequencies leads to \(\delta\pi=C^{-1}\delta q\), and therefore

$$ \|\delta\pi\|\leq \|C^{-1}\|\,\|\delta q\|. $$

If \(\|C^{-1}\|\) is large, small frequency errors can produce large changes in the recovered prevalences. For a rectangular matrix with full column rank, the analogous statement uses a left inverse. Thus identifiability is a uniqueness property; stability concerns sensitivity to perturbations. Rank alone answers the first question, not the second.

Common Mistake

  • Wrong reasoning: “The classifier has nonzero accuracy for every class, so target prevalences are identifiable.” Nonzero diagonal entries do not rule out linear dependence among the columns.
  • Correction: Check whether the full columns of the population confusion matrix are linearly independent. Even a useful classifier can have identical or dependent class-conditional prediction distributions, in which case some distinct prevalences produce exactly the same predicted-label frequencies.
  • Another distinction: A unique solution to the population equation does not mean sample-based recovery is stable. Near-dependence can make an otherwise identifiable system highly sensitive to estimation error.
Key takeaway: Under label shift, target predicted-label frequencies satisfy \(q_t=C\pi_t\). Over the full class-prevalence simplex, the target prevalences are globally identifiable from those frequencies exactly when the source confusion matrix has full column rank.

Check Your Understanding

Use the column convention for \(C\) throughout.

  1. Why does each column of the population confusion matrix sum to one?
  2. State the label-shift condition that allows the source confusion matrix to appear in the target frequency equation.
  3. If two distinct simplex vectors \(u\) and \(v\) satisfy \(Cu=Cv\), what does that imply about global identifiability?
  4. Why does rank deficiency of a column-stochastic matrix imply that a nonzero null vector has entries summing to zero?
  5. Can a full-rank confusion matrix still lead to unstable recovery when predicted frequencies are estimated with error? Explain.
Clinical Biostats