Unsupervised Learning under Latent Label Shift
Abstract
What sorts of structure might enable a learner to discover classes from unlabeled data?
Traditional approaches rely on feature-space similarity and heroic assumptions on the data.
In this paper, we introduce unsupervised learning under
Latent Label Shift (LLS), where we have access to unlabeled data from multiple domains such that the label marginals p d p y q can shift across domains but the class conditionals p p x | y q do not.
This work instantiates a new principle for identifying classes: elements that shift together group together.
For finite input spaces, we establish an isomorphism between LLS and topic modeling: inputs correspond to words, domains to documents, and labels to topics.
Addressing continuous data, we prove that when each label’s support contains a separable region, analogous to an anchor word, oracle access to p p
d
| x q suffices to identify p d p y q and p d p y | x q up to permutation.
Thus motivated, we introduce a practical algorithm that leverages domain-discriminative models as follows: (i) push examples through domain discriminator p p
d | x q ; (ii) discretize the data by clustering examples in p p d | x q space; (iii) perform non-negative matrix factorization on the discrete data; (iv) combine the recovered p p y | d q with the discriminator outputs p p d | x q to compute p d p y | x q @ d .
With semi-synthetic experiments, we show that our algorithm can leverage domain information to improve upon competitive unsupervised classification methods.
We reveal a failure mode of standard unsupervised classification methods when dataspace similarity does not indicate true groupings, and show empirically that our method better handles this case.
Our results establish a deep connection between distribution shift and topic modeling, opening promising lines for future work
Introduction
Discovering systems of categories from unlabeled data is a fundamental but ill-posed challenge in machine learning.
Typical unsupervised learning methods group instances together based on featurespace similarity.
Accordingly, given a collection of photographs of animals, a practitioner might hope that, in some appropriate feature space, images of animals of the same species should be somehow similar to each other.
But why should we expect a clustering algorithm to recognize that dogs viewed in sunlight and dogs viewed at night belong to the same category?
Why should we expect that butterflies and caterpillars should lie close together in feature space?
In this paper, we offer an alternative principle according to which we might identify a set of classes: we exploit distribution shift across times and locations to reveal otherwise unrecognizable groupings among examples.
For example, if we noticed that whenever we found ourselves in a location where butterflies are abundant, caterpillars were similarly abundant, and that whenever butterflies were scarce, caterpillars had a similar drop in prevalence, we might conclude that the two were tied to the same underlying concept, no matter how different they appear in feature space.
In short, our principle suggests that latent classes might be uncovered whenever instances that shift together group together .
pairs
Domain Domain
Domain r
D o m a i n
D i sc r
i m i n a t
o r
Cluster
NMF
Formalizing this intuition, we introduce the problem of unsupervised learning under Latent Label
Shift (LLS).
Here, we assume access to a collection of domains d P t 1 , . . .
, r u , where the mixture proportions p d p y q vary across domains but the class conditional distribution p p x | y q is domaininvariant.
Our goals are to recover the underlying classes up to permutation, and thus to identify both the per-domain mixture proportions p d p y q and optimally adapted per-domain classifiers p d p y | x q .
The essential feature of our setup is that only the true y ’s, as characterized by their class-conditional distributions p p x | y q , could account for the observed shifts in p
d p x q .
We prove that under mild assumptions, knowledge of this underlying structure is sufficient for inducing the full set of categories.
First, we focus on the tabular setting , demonstrating that when the input space is discrete and finite, LLS is isomorphic to topic modeling [9].
Here, each distinct input x maps to a word each latent label y maps to a topic and each domain d maps to a document.
In this case, we can apply standard identification results for topic modeling [22, 5, 30, 38, 14] that rely only on the existence of anchor words within each topic (i.e., for each label y there is at least one x in the support of y , that is not in the support of any y 1 ‰ y ).
Here, standard methods based on Non-negative Matrix
Factorization (NMF) can recover each domain’s underlying mixture proportion p d p y q and optimal predictor p d p y | x q [22, 38, 30].
However, the restriction to discrete inputs, while appropriate for topic modeling, proves restrictive when our interests extend to high-dimensional continuous input spaces.
Then, to handle high-dimensional inputs, we propose Discriminate-Discretize-Factorize-Adjust (DDFA) , a general framework that proceeds in the following steps: (i) pool data from all domains to produce a mixture distribution q p x, d q ; (ii) train a domain discriminative model f to predict q p d | x q ; (iii) push all data through f , cluster examples in the pushforward distribution, and tabularize the data based on cluster membership; (iv) solve the resulting discrete topic modeling problem (e.g., via
NMF), estimating q p y, d q up to permutation of the latent labels; (v) combine the predicted q p d | x q and q p y, d q to estimate p d p y q and p d p y | x q .
In developing this approach, we draw inspiration from recent works on distribution shift and learning from positive and unlabeled data that (i) leverage black box predictors to perform dimensionality reduction [46, 25, 26]; and (ii) work with anchor sets , separable subsets of continuous input spaces that belong to only one class’s support [64, 49, 23, 7, 26].
Our key theoretical result shows that domain discrimination ( q p d | x q ) provides a sufficient representation for identifying all parameters of interest.
Given oracle access to q p d | x q (which is identified without labels), our procedure is consistent.
Our analysis reveals that the true q p d | x q maps all points in the same anchor set to a single point mass in the push-forward distribution.
This motivates our practical approach of discretizing data by hunting for tight clusters in q p d | x q space.
In semi-synthetic experiments, we adapt existing image classification benchmarks to the LLS setting, sampling without replacement to construct collections of label-shifted domains.
We note that training a domain discriminator classifier is a difficult task, and find that warm starting the initial layers of our model with pretrained weights from unsupervised approaches can significantly boost performance.
We show that warm-started
DDFA outperforms competitive unsupervised approaches on CIFAR10 and CIFAR-20 when domain marginals p d p y q are sufficiently sparse.
In particular, we observe improvements of as much as 30% accuracy over a recent high-performing unsupervised method on
CIFAR-20.
Further, on subsets of FieldGuide dataset, where similarity between species and diversity within a species leads to failure of unsupervised learning, we show that DDFA recovers the true distinctions.
To be clear, these are not apples-to-apples comparisons: our methods are specifically tailored to the LLS setting.
The takeaway is that the structure of the LLS setting can be exploited to outperform the best unsupervised learning heuristics.
Related Work
Unsupervised Learning Standard unsupervised learning approaches for discovering labels often rely on similarity in the original data space [50, 62].
While distances in feature space become meaningless for high-dimensional data, deep learning researchers have turned to similarity in a representation space learned via self-supervised contrastive tasks [53, 21, 29, 12], or similarity in a feature space learned end-to-end for a clustering task [10, 11, 57, 71].
Our problem setup closely resembles independent component analysis (ICA), where one seeks to identify statistically independent signal components from mixtures [39].
However, ICA’s assumption of statistical independence among the components does not generally hold in our setup.
In topic modeling [9, 5, 38, 14, 56], documents are modeled as mixtures of topics, and topics as categorical distributions over a finite vocabulary.
Early topic models include the well-known Latent Dirichlet Allocation (LDA) [9], which assumes that topic mixing coefficients are drawn from a Dirichlet distribution, along with papers with more relaxed assumptions on the distribution of topic mixing coefficients (e.g., pLSI)
The topic modeling literature often draws on Non-negative Matrix Factorization (NMF) methods [54, 65], which decompose a given matrix into a product of two matrices with non-negative elements [20, 18, 28, 31].
In both
Topic Modeling and NMF, a fundamental problem has been to characterize the precise conditions under which the system is uniquely identifiable [22, 5, 38, 14].
The anchor condition (also referred to as separability) is known to be instrumental for identifying topic models [5, 14, 38, 22].
In this work, we extend these ideas, leveraging separable subsets of each label’s support (the anchor sets) to produce anchor words in the discretized problem.
Existing methods have attempted to extend latent variable modeling to continuous input domains by making assumptions about the functional forms of the class-conditional densities, e.g., restricting to Gaussian mixtures [62, 60].
A second line of approach involves finding an appropriate discretization of the continuous space [70].
Distribution Shift under the Label Shift Assumption The label shift assumption, where p d p y q can vary but p p x | y q cannot, has been extensively studied in the domain adaptation literature [63, 67, 74, 46, 33, 25] and also features in the problem of learning from positive and unlabeled data [24, 8, 26].
For both problems, many classical approaches suffer from the curse of dimensionality, failing in the settings where deep learning prevails.
Our solution strategy draws inspiration from recent work on label shift [46, 1, 6, 25] and PU learning [8, 49, 64, 26, 27] that leverage black-box predictors to produce sufficient low-dimensional representations for identifying target distributions of interest (other works leverage black box predictors heuristically [41]).
Key differences: While PU learning requires identifying one new class for which we lack labeled examples provided that the positive class contains an anchor set [26], LLS can identify an arbitrary number of classes (up to permutation) from completely unlabeled data, provided a sufficient number of domains.
Domain Generalization
The related problem of Domain Generalization (DG) also addresses learning with data drawn from multiple distributions and where the domain identifiers play a key role [51, 3].
However in DG, we are given labeled data from multiple domains, and our goal is to learn a classifier that can generalize to new domains.
By contrast, in LLS, we work with unlabeled data only, leveraging the problem structure to identify the underlying labels.
Learning with Label Noise (LLN)
Another problem type that can be viewed under the LLS lens is
Learning with Label Noise (LLN) [58, 32, 45, 55, 61, 69, 47, 48]. This connection can be established as follows: Consider the observed noisy labels to act as domains (see 1). We then have (i) different distributions over the true labels conditioned on the noisy label; (ii) When conditioned on the true label, the distribution over the input space is independent of the noisy label. These observations indicate the satisfaction of LLS setup (see 1) in LLN, a key difference being the LLN literature typically assumes the distribution over the noisy label has the highest mass at p
y “ i when the true label y
“ i .
The connection between mixture proportion estimation and LLN has been identified in [64].
Many methods have been proposed to tackle the LLN problem: (i) loss correction and surrogate risk minimization [58, 32, 64, 52]; (ii) leveraging the predictions of Deep Networks to assign soft labels, as teacher-student models or in MixUp like augmentations [34, 13, 61, 69, 2]; (iii) tapping into the early learning of meaningful patterns by Deep Networks [45, 47, 66].
Of particular relevance is [58], which estimates the Noise Transition Matrix (NTM) and then uses this estimate to retrain
[Figure]
under a corrected loss function.
[58] shows that "perfect examples" allow for the identification of the NTM (similar to the anchor subdomain assumption which appears in this work).
However, [58] use the assumption that when the true label takes a certain value, the highest probability mass for the noisy label is also at the same value—an assumption not always satisfied in our setting.
Further, in the LLN problem, the number of domains and classes are always equal, rendering LLN methods such as [58] incapable of using the information provided by additional domains present in non-LLN settings.
Our method can leverage domain information to provide a domain calibrated classifier, but [58] does not exploit the possible availability of a noisy label at inference.
Latent Label Shift Setup
Notation For a vector v P R p , we use v j to denote its j th entry, and for an event E , we let I r E s denote the binary indicator of the event.
By | A | , we denote the cardinality of set A .
With r n s , we denote the set t 1 , 2 , . . . , n u .
We use r A
s i,j to access the element at p i, j q in A .
Let X be the input space and Y “ t 1 , 2 , . . .
, k u be the output space for multiclass classification.
We assume throughout this work that the number of true classes k is known.
Throughout this paper, we use capital letters to denote random variables and small case letters to denote the corresponding values they take.
For example, by X we denote the input random variable and by x , we denote a value that X may take.
We now formally introduce the problem of unsupervised learning under LLS.
In LLS, we assume that we observe unlabeled data from r domains.
Let R “ t 1 , 2 , . . .
, r u be the set of domains.
By p d , we denote the probability density (or mass) function for each domain d P R .
Definition 1 (Latent label shift) .
We observe data from r domains.
While the label distribution can differ across the domains, for all d, d 1 P R and for all p x, y q P X ˆ Y , we have p d p x | y q “ p d 1 p x | y q .
Simply put, Definition 1 states that the conditional distribution p d p x | y q remains invariant across domains, i.e., they satisfy the label shift assumption.
Thus, we can drop the subscript on this factor, denoting all p d p x | y q by p p x | y q .
Crucially, under LLS, p d p y q can vary across different domains.
Under LLS, we observe unlabeled data with domain label tp x 1 , d 1 q , p x 2 , d 2 q , . .
, p x n , d n qu .
Our goal breaks down into two tasks.
Up to permutation of labels, we aim to (i) estimate the label marginal in each domain
p d
p y q ; and (ii) estimate the optimal per-domain predictor p d p y | x q .
Mixing distribution Q A key step in our algorithm will be to train a domain discriminative model.
Towards this end we define Q , a distribution over X ˆ Y ˆ R , constructed by taking a uniform mixture over all domains.
By q , we denote the probability density (or mass) function of Q .
Define Q such that q p x, y | D “ d q “ p d p x, y q , i.e., when we condition on D “ d
we recover the joint distribution over X ˆ Y specific to that domain d .
For all d P R , we define γ d “ q p d q , i.e., the prevalence of each domain in our distribution Q .
Notice that q p x, y q is a mixture over the distributions t p d p x, y qu d P R , with t γ d u d P R as the corresponding mixture coefficients.
Under LLS (Definition 1), X does not depend on D when conditioned on Y (Fig. 2).
Additional notation for the discrete case To begin, we setup notation for discrete input spaces with |X| “ m .
Without loss of generality, we assume that X “ t 1 , 2 , . . .
, m u .
The label shift assumption allows us to formulate the label marginal estimation problem in matrix form.
Let Q X | D be an m ˆ r matrix such that r Q X | D s i,d “ p d p X “ i q , i.e., the d -th column of Q X | D is p d p x q .
Let Q X | Y be an m ˆ k matrix such that r Q X | Y s i,j “ p p X
“ i | Y “ j q , the j -th column is a distribution over X given
Y “ j .
Similarly, define Q Y | D as a k ˆ r matrix whose d -th column is the domain marginal p d p y q .
Now with Definition 1, we have p d p x q “ ř y p
d p x, y q “ ř y p
d p x | y q p d p y q “ ř y p p x | y q p d p y q .
Since this is true @
d P R , we can express this in a matrix form as Q X | D “ Q X | Y Q Y | D .
Additional assumptions Before we present identifiability results for the LLS problem, we introduce four additional assumptions required throughout the paper:
A.1 There are at least as many domains as classes, i.e., |R| ě |Y| .
A.
The matrix formed by label marginals (as columns) across different domains is full-rank, i.e., rank p Q Y | D q “ k . A.3 Equal representation of domains, i.e., for all d P R , γ d “ 1 { r .
A.4 Fix ϵ ą 0 .
For all y P Y , there exists a unique subdomain A y Ď X , such that q p A y q ě ϵ and x P A y if and only if the following conditions are satisfied: q p x | y q ą 0 and q p x | y 1 q “for all y 1 P Y zt y u .
We refer to this assumption as the ϵ -anchor sub-domain condition.
We now comment on the assumptions.
A.1–A.2 are benign, these assumptions just imply that the matrix Q Y | D is full row rank.
Without loss of generality, A.3 can be assumed when dealing with data from a collection of domains.
When this condition is not satisfied, one could just re-sample data points uniformly at random from each domain d .
Intuitively, A.4 states that for each label y P Y , we have some subset of inputs that only belong to that class y .
To avoid vanishing probability of this subset, we ensure at least ϵ probability mass in our mixing distribution Q .
The anchor word condition is related to the positive sub-domain in PU learning, which requires that there exists a subset of X in which all examples only belong to the positive class [64, 49, 23, 7].
Theoretical Analysis
In this section, we establish identifiability of LLS problem.
We begin by considering the case where the input space is discrete and formalize the isomorphism to topic modeling.
Then we establish the identifiability of the system in this discrete setting by appealing to existing results in topic modeling [38].
Finally, extending results from discrete case, we provide novel analysis to establish our identifiability result for the continuous setting.
Isomorphism to topic modeling Recall that for the discrete input setting, we have the matrix formulation: Q X | D “ Q X | Y Q Y | D .
Consider a corpus of r documents, consisting of terms from a vocabulary of size m .
Let D be an R m ˆ r matrix representing the underlying
We can state the topic modeling problem as: D “ CW , where C is an R m ˆ k matrix, r C s i,j represents the frequency of term i given topic j , and W is an R k ˆ r matrix, where r W s i,j represents the proportion of topic i in document j .
Note that all three matrices are column normalized.
The isomorphism is then between document and domain, topic and label, term and input sample, i.e.,
D “ CW ” Q X | D “ Q X | Y Q Y | D .
In both the cases, we are interested in decomposing a known matrix into two unknown matrices.
This formulation is examined as a non-negative matrix factorization problem with an added simplicial constraint on the columns (columns sum to 1) [4, 30].
Identifiability of the topic modeling problem is well-established [22, 5, 30, 38, 14].
We leverage the isomorphism to topic modeling to extend this identifiability condition to our LLS setting.
We formalize the adaptation here:
Theorem 1.
(adapted from Proposition 1 in Huang et al.
[38]) Assume A.1, A.2 and A.4 hold (A.4 in the discrete setting is referred to as the anchor word condition).
Then the solution to
Q X | D “ Q X | Y Q Y | D is uniquely identified up to permutation of class labels.
We refer readers to Huang et al.
[38] for a proof of this theorem.
Intuitively, Theorem 1 states that if each label y has at least one token in the input space that has support only in y , and A.1, A.2 hold, then the solution to Q X | Y , Q Y | D is unique.
Furthermore, under this condition, there exist algorithms that can recover Q X | Y , Q Y | D within some permutation of class labels [38, 30, 4, 5].
Extensions to the continuous case We will prove identifiability in the continuous setting, when
X “ R p for some p ě 1 .
In addition to A.1–A.4, we make an additional assumption that we have oracle access to q p d | x q , i.e., the true domain discriminator for mixture distribution Q .
This is implied by assuming access to the marginal q p x, d q from which we observe our samples.
Formally, we define a push forward function f such that r f p x qs d “ q p d | x q , then push the data forward through f to obtain outputs in ∆ r ´ 1 .
In the proof of Theorem 2, we will show that these outputs can be discretized in a fashion that maps anchor subdomains to anchor words in a tabular, discrete setting.
We separately remark that the anchor word outputs are in fact extreme corners of the convex polytope in ∆ r ´ 1 which encloses all f p x q mass; we discuss this geometry further in App.
F.
After constructing the anchor word discretization, we appeal to Theorem 1 to recover Q Y | D .
Given Q Y | D , we show that we can use Bayes’ rule and the LLS condition (Definition 1) to identify the distribution q p y | x, d q “ p d p y | x q over latent variable y .
We formalize this in the following theorem:
Theorem 2.
Let the distribution Q over random variables X, Y, D satisfy Assumptions A.1–A.4.
Assuming access to the joint distribution q p x, d q , and knowledge of the number of true classes k , we show that the following quantities are identifiable: (i) Q Y | D , (ii) q p y | X “ x q , for all x P X that lies in the support (i.e. q p x q ą 0 ); and (iii) q p y | X “ x, D “ d q , for all x P X and d P R such that q p x, d q ą 0 .
Before presenting a proof sketch for Theorem 2, we first present key lemmas (we include their proofs in App.
A).
Lemma 1.
Under the same assumptions as Theorem 2, the matrix Q Y | D and f p x q “ q p d | x q uniquely determine q p y | x q for all y P Y and x P X such that q p x q ą 0 .
Lemma 1 states that given matrix Q Y | D and oracle domain discriminator, we can uniquely identify q p y | x q .
In particular, we show that for any x P X , q p d | x q can be expressed as a convex combination of the k columns of Q D | Y (which is computed from Q Y | D and is column rank k ) and the coefficients of the combination are q p y | x q .
Combining this with the linear independence of the columns of Q D | Y , we show that these coefficients are unique.
In the following lemma, we show how the identified q p y | x q can then be used to identify q p y | x, d q :
Lemma 2.
Under the same assumptions as Theorem 2, for all y P Y , and x P X such that q p x, d q ą 0 .
the matrix Q Y | D and q p y | x q uniquely determine q p y | x, d q .
To prove Lemma 2, we show that we can combine the conditional distribution over the labels given a sample x P X with the prior distribution of the labels in each domain to determine the posterior distribution over labels given the sample x and the domain of interest.
Next, we introduce a key property of the domain discriminator classifier f :
Lemma 3.
Under the same assumptions as Theorem 2, for all x, x 1 in anchor sub-domain, i.e., x, x 1 P A y for a given label y P Y , we have f p x q “ f p x 1 q .
Further, for any y P Y , if x P A y , x 1 R A y , then f p x q ‰ f p x 1 q .
Lemma 3 implies that the oracle domain discriminator f maps all points in an anchor subdomain, and only those points in that anchor subdomain to the same point in f p x q “ q p d | x q space.
We can now present a proof sketch for Theorem 2 (full proof in App.
B):
Proof sketch of Theorem 2.
The key idea of the proof lies in proposing a discretization such that some subset of anchor subdomains for each label y in the continuous space map to distinct anchor words in discrete space.
In particular, if there exists a discretization of the continuous space X that for any y P Y , maps all
x P A y to the same point in the discrete space, but no x R A y maps to this point, then this point serves as an anchor word.
From Lemma 3, we know that all the x P A y and only the x P A y get mapped to specific points in the f p x q space.
Pushing all the x P X through f , we know from A. that there exists k point masses of size ϵ , one for each f p
A y q in the f p x q “ q p d | x q space.
We can now inspect this space for point masses of size at least ϵ to find at most O p 1 { ϵ q such point masses among which are contained the k point masses corresponding to the anchor subdomains.
Discretizing this space by assigning each point mass to a group (and non-point masses to a single additional group), we have k groups that have support only in one y each.
Thus, we have achieved a discretization with anchor words.
Further, since the discrete space arises from a pushforward of the continuous space through f , the discrete space also satisfies the latent label shift assumption A.1.
We now use
Theorem 1 to claim identifiability of Q Y | D .
We then use Lemmas 1 and 2 to prove parts (ii) and (iii).
DDFA Framework
Motivated by our identifiability analysis, in this section, we present an algorithm to estimate
Q Y | D , q p y | x q , and q p y | x, d q when X is continuous by exploiting domain structure and approximating the true domain discriminator f .
Intuitively, q p y | x, d q is the domain specific classifier p d
p y | x q and q p y | x q is the classifier for data from aggregated domains.
Q Y | D captures label marginal for individual domains.
A naive approach would be to aggregate data from different domains and exploit recent advancements in unsupervised learning [71, 57, 10, 11].
However, aggregating data from multiple domains loses the domain structure that we hope to leverage.
We highlight this failure mode of the traditional unsupervised clustering method in Sec.
We remark that DDFA draws heavy inspiration from the proof of Theorem 2, but we do not present a guarantee that the DDFA solution will converge to the identifiable solution.
This is primarily due to the K-means clustering heuristic we rely on, which empirically offers effective noise tolerance, but theoretically has no guarantee of correct convergence.
Discriminate We begin Algorithm 1 by creating a split of the unlabeled samples into the training and validation sets.
Using the unlabeled data samples and the domain that each sample originated from, we first train a domain discriminator p f .
The domain discriminator outputs a distribution over domains for a given input.
This classifier is trained with cross-entropy loss to predict the domain label of each sample on the training set.
With unlimited data, the minimizer of this loss is the true f , as we prove in App.
C. To avoid overfitting, we stop training p f
when the cross-entropy loss on the validation set stops decreasing.
Note that here the validation set also only contains domain indices (and no information about true class labels).
Discretize We now push forward all the samples from the training and validation sets through the domain discriminator to get vector p
f p x i q for each sample x i .
In the proof of Theorem 2, we argue that when working with true f , and the entire marginal q p x, d q , we can choose a discretization satisfying the anchor word assumption by identifying point masses in the distribution of f p x q and filtering to include those of at least ϵ mass.
In the practical setting, because we have only a finite set of data points and a noisy p f , we use clustering to approximately find point masses.
We choose m ě k and recover m clusters with any standard clustering procedure (e.g. K-means).
This clustering procedure is effectively a useful, but imperfect heuristic: if the noise in p f is sufficiently small and the clustering sufficiently granular, we hope that our m discovered clusters will include k pure clusters, each of which only contains data points from a different anchor subdomain which are tightly packed around the true f p A y q for the corresponding label y .
Clustering in this space is superior to a naive clustering on the input space because close proximity in this space indicates similarity in q p d | x q .
Let us denote the learned clustering function as c , where c p x q is the cluster assigned to a datapoint x .
We now leverage the cluster id c p x i q of each sample x i to discretize samples into a finite discrete space r m s .
Combining the cluster id with the domain source d i for each sample, we estimate p Q c p X q| D by simply computing, for each domain, the fraction of its samples assigned to each cluster.
Factorize We apply an NMF algorithm to p Q c p X q| D to obtain estimates of p Q c p X q| Y and p Q Y | D .
Adjust We begin Algorithm 2 by considering a test point p x 1 , d 1 q .
To make a prediction, if we had access to oracle f and true Q Y | D , we could precisely compute q p y | x 1 q (Lemma 1).
However, in place of these true quantities, we plug in the estimates p f and p Q Y | D .
Since our estimates contain noise, the estimate p q p y | x 1 q is found by left-multiplying p f p x 1 q with the pseudo-inverse of p Q D | Y , as opposed to solving a sufficient system of equations.
As our estimates p f and p Q D | Y approach the true values, the projection of p f p x 1 q into the column space of p Q D | Y tends to p f p x 1 q itself, so the pseudo-inverse approaches the true solution.
Now we can use the constructive procedure introduced in the proof of
Lemma 2 to compute the plug-in estimate p q p y | x 1 , d 1 q “ p p d 1 p y | x 1 q .
Experiments
Experiment code is available at https://github.com/acmi-lab/Latent-Label-Shift-DDFA .
Baselines We select the unsupervised classification method SCAN, as a high-performing competitive baseline [71].
SCAN pretrains a ResNet [35] backbone using SimCLR [12] and MoCo [36] setups (pretext tasks).
SCAN then trains a clustering head to minimize the SCAN loss (refer [71] for more details) 3 .
We do not use the SCAN self-labeling step.
We make sure to evaluate SCAN on the same potentially class-imbalanced test subset we create for each experiment.
Since SCAN is fit on a superset of the data DDFA sees, we believe this gives a slight data advantage to the SCAN baseline (although we acknowledge that the class balance for SCAN training is also potentially different from its evaluation class balance).
To evaluate SCAN, we use the public pretrained weights available for input k ě 1 , r ě k, tp x i , d i qu i Pr n s „ q p x, d q , A class of functions F from R p Ñ R r 1: Split into train and validation set V 2: Train f 4: [Table] [Table] „´
[Table]
output : p q p y | X “ x 1 , D “ d 1 q “ p p d 1 p y | x 1 q , p q p y | X “ x 1 q , y pred
CIFAR-10, CIFAR-20, and ImageNet-50.
We also train SCAN ourselves on the train and validation portions of the FieldGuide2 and FieldGuide28 datasets with a ResNet18 backbone and SimCLR pretext task.
We replicate the hyperparameters used for CIFAR training.
Datasets First we examine standard multiclass image datasets CIFAR-10, CIFAR-20 [43], and
ImageNet-50 [19] containing images from 10, 20, and 50 classes respectively.
Images in these datasets typically focus on a single large object which dominates the center of the frame, so unsupervised classification methods which respond strongly to similarity in visual space are well-suited to recover true classes up to permutation.
These datasets are often believed to be separable (i.e., single true label applies to each image), so every example falls in an anchor subdomain (satisfying A.4).
Motivated by the application of LLS problem, we consider the FieldGuide dataset 4 , which contains images of moths and butterflies.
The true classes in this dataset are species, but each class contains images taken in immature (caterpillar) and adult stages of life.
Based on the intuition that butterflies from a given species look more like butterflies from other species than caterpillars from their own species, we hypothesize that unsupervised classification will learn incorrect class boundaries which distinguish caterpillars from butterflies, as opposed to recovering the true class boundaries.
Due to high visual similarity between members of different classes, this dataset may indeed have slight overlap between classes.
However, we hypothesize that anchor subdomain still holds, i.e., there exist some images from each class that could only come from that class.
Additionally, if we have access to data from multiple domains, it is natural to assume that within each domain the relative distribution of caterpillar to adult stages of each species stay relatively constant as compared to prevalence of different species.
We create two subsets of this dataset: FieldGuide2, with two species, and FieldGuide28, with 28 species.
LLS Setup The full sampling procedure for semisynthetic experiments is described in App.
D.
Roughly, we sample p d p y q from a symmetric Dirichlet distribution with concentration α { k , where k is the number of classes and α is a generation parameter that adjusts the difficulty of the synthetic [Table] problem, and enforce maximum condition number κ on Q Y | D .
Small α and small κ encourages sparsity in Q Y | D , so each label tends to only appear in a few domains.
Larger parameters encourages p d p y q to tend toward uniform.
We draw from test, train, and valid datasets without replacement to match these distributions, but discard some examples due to class imbalance.
Training and Evaluation
The algorithm uses train and validation data consisting of pairs of images and domain indices.
We train ResNet50 [35] (with added dropout) on images x i with domain indices d i as the label, choose best iteration by valid loss, pass all training and validation data through p f , and cluster pushforward predictions p
f p x i q into m ě k clusters with Faiss K-Means [42].
We compute the p
Q c p X q| D matrix and run NMF to obtain p Q c p X q| Y , p Q Y | D .
To make columns sum to 1, we normalize columns of p Q c p X q| Y , multiply each column’s normalization coefficient over the corresponding row of p
Q Y | D (to preserve correctness of the decomposition), and then normalize columns of p Q Y | D .
Some
NMF algorithms only output solutions satisfying the anchor word property [4, 44, 30].
We found the strict requirement of an exact anchor word solution to lead to low noise tolerance.
We therefore use the Sklearn implementation of standard NMF [15, 68, 59].
We instantiate the domain discriminator as ResNet18, and preseed its backbone with SCAN [71] pre-trained weights or [71] contrastive pre-text weights.
We denote these models DDFA (SI) and
DDFA (SPI) respectively.
We predict class labels with Algorithm 2 .
With the Hungarian algorithm, implemented in [16, 72], we compute the highest true accuracy among any permutation of these labels (denoted “Test acc”).
With the same permutation, we reorder rows of p P Y | D , then compute the average absolute difference between corresponding entries of p Q Y | D and Q Y | D (denoted “ Q Y | D err”).
On CIFAR-10, we observe that DDFA alone is incapable of matching highly competitive baseline SCAN performance—however, in suitably sparse problem settings (small α ), it comes substantially close, indicating good recovery of true classes.
Due to space constraints, we include
CIFAR-10 results in App.
E. DDFA (SI) combines SCAN’s strong pretrain with domain discrimination fine-tuning to outperform SCAN in the easiest, sparsest setting and certain denser settings.
On
CIFAR-20, baseline SCAN is much less competitive, so our DDFA(SI) dominates baseline SCAN in all settings except the densest (Table 1).
These results demonstrate how adding domain information can dramatically boost unsupervised baselines.
On FieldGuide-2, DDFA (SPI) outperforms SCAN baselines in accuracy across nearly all problem settings and domain counts (Table 5); in sparser settings, the accuracy gap is 10-30%.
In this dataset,
SCAN performs only slightly above chance, reflecting perhaps a total misalignment of learned class distinctions with true species boundaries.
We do not believe that SCAN is too weak to effectively detect image groupings on this data; instead we acknowledge that the domain information available to DDFA (SPI) (and not to SCAN) is informative for ensuring recovery of the true class distinction between species as opposed to the visually striking distinction between adult and immature life stages.
Results from more domains are available in App.
E.
On FieldGuide-28 (Table 6), DDFA accuracy outperforms SCAN baseline accuracy in all evaluated sparsity levels, with the highest observed accuracy difference ranging above 30-40%.
Conclusion
Our theoretical results demonstrate that under LLS, we can leverage shifts among previously seen domains to recover labels in a purely unsupervised manner, and our practical instantiation of the
DDFA framework demonstrates both (i) the practical efficacy of our approach; and (ii) that generic unsupervised methods can play a key role both in clustering discriminator outputs, and providing weights for initializing the discriminator.
We believe our work is just the first step in a new direction for leveraging structural assumptions together with distribution shift to perform unsupervised learning.
7.1 Future Work and Limitations
Assumptions Our approach is limited by the set of assumptions needed (label shift, as many data domains as true latent classes, known true number of classes k , and other assumptions established in
A.1-A.4).
Future work should aim to relax these assumptions.
Theory The work does not include finite sample bounds for the DDFA algorithm.
In addition, we do not have a formal guarantee that the clustering heuristic in the Discretize step of DDFA will retrieve pure anchor sub-domain clusters under potentially noisy black-box prediction of q p d | x q .
This problem is complicated by the difficulty of reasoning about the noise that may be produced by a neural network or other complex non-linear model (acting as the black-box domain discriminator), and by the lack of concrete guarantees that K-means will recover the anchor subdomains among its recovered clusters—especially when classes overlap.
DDFA Framework Within the LLS setup, several components of the DDFA framework warrant further investigation: (i) the deep domain discriminator can be enhanced in myriad ways; (ii) for clustering discriminator outputs, we might develop methods specially tailored to our setting to replace the current generic clustering heuristic; (iii) clustering might be replaced altogether with geometrically informed methods that directly identify the corners of the polytope; (iv) the theory of LLS can be extended beyond identification to provide statistical results that might hold when q p d | x q can only be noisily estimated, and when only finite samples are available for the induced topic modeling problem; ( v) when the number of true classes k is unknown, we may develop approaches to estimate this k .
Semi-synthetic Experiments Semi-synthetic experiments present an ideal environment for evaluating under the precise label shift assumption.
Evaluating on datasets in which the separation into domains is organic, and the label shift is inherent is an interesting direction for future work.
Acknowledgements
SG acknowledges Amazon Graduate Fellowship and JP Morgan PhD Fellowship for their support.
ZL acknowledges Amazon AI, Salesforce Research, Facebook, UPMC, Abridge, the PwC Center, the Block Center, the Center for Machine Learning and Health, and the CMU Software Engineering
Institute (SEI) via Department of Defense contract FA8702-15-D-0002, for their generous support of
ACMI Lab’s research on machine learning under distribution shift.