Year: 2019

Abstract:
We propose Regularized Learning under Label shifts (RLLS), a principled and a practical domain-adaptation algorithm to correct for shifts in the label distribution between a source and a target domain. We first estimate importance weights using labeled source data and unlabeled target data, and then train a classifier on the weighted source samples. We derive a generalization bound for the classifier on the target domain which is independent of the (ambient) data dimensions, and instead only depends on the complexity of the function class. To the best of our knowledge, this is the first generalization bound for the label-shift problem where the labels in the target domain are not available. Based on this bound, we propose a regularized estimator for the small-sample regime which accounts for the uncertainty in the estimated weights. Experiments on the CIFAR-10 and MNIST datasets show that RLLS improves classification accuracy, especially in the low sample and large-shift regimes, compared to previous methods.

heading: 1 INTRODUCTION
text: When machine learning models are employed “in the wild”, the distribution of the data of interest(target distribution) can be significantly shifted compared to the distribution of the data on which the model was trained (source distribution). In many cases, the publicly available large-scale datasets with which the models are trained do not represent and reflect the statistics of a particular dataset of interest. This is for example relevant in managed services on cloud providers used by clients in different domains and regions, or medical diagnostic tools trained on data collected in a small number of hospitals and deployed on previously unobserved populations and time frames.
Covariate Shift Label Shift
p(x) 6= q(x) p(y|x) = q(y|x) p(y) 6= q(y) p(x|y) = q(x|y) There are various ways to approach distribution shifts between a source data distribution P and a target data distribution Q. If we denote input variables as x and output variables as y, we consider the two following settings: (i) Covariate shift, which assumes that the conditional output distribution is invariant: p(y|x) = q(y|x) between source and target distributions, but the source distribution p(x) changes. (ii) Label shift, where the conditional input distribution is invariant: p(x|y) = q(x|y) and p(y) changes from source to target. In the following, we assume that both input and output variables are observed in the source distribution whereas only input variables are available from the target distribution.
While covariate shift has been the focus of the literature on distribution shifts to date, label-shift scenarios appear in a variety of practical machine learning problems and warrant a separate discussion as well. In one setting, suppliers of machine-learning models such as cloud providers have large resources of diverse data sets (source set) to train the models, while during deployment, they have no control over the proportion of label categories.
In another setting of e.g. medical diagnostics, the disease distribution changes over locations and time. Consider the task of diagnosing a disease in a country with bad infrastructure and little data,
based on reported symptoms. Can we use data from a different location with data abundance to diagnose the disease in the new target location in an efficient way? How many labeled source and unlabeled target data samples do we need to obtain good performance on the target data?
Apart from being relevant in practice, label shift is a computationally more tractable scenario than covariate shift which can be mitigated. The reason is that the outputs y typically have a much lower dimension than the inputs x. Labels are usually either categorical variables with a finite number of categories or have simple well-defined structures. Despite being an intuitively natural scenario in many real-world application, even this simplified model has only been scarcely studied in the literature. Zhang et al. (2013) proposed a kernel mean matching method for label shift which is not computationally feasible for large-scale data. The approach in Lipton et al. (2018) is based on importance weights that are estimated using the confusion matrix (also used in the procedures of Saerens et al. (2002); McLachlan (2004)) and demonstrate promising performance on large-scale data. Using a black-box classifier which can be biased, uncalibrated and inaccurate, they first estimate importance weights q(y)/p(y) for the source samples and train a classifier on the weighted data. In the following we refer to the procedure as black box shift learning (BBSL) which the authors proved to be effective for large enough sample sizes.
However, there are three relevant questions which remain unanswered by their work: How to estimate the importance weights in low sample setting, What are the generalization guarantees for the final predictor which uses the weighted samples? How do we deal with the uncertainty of the weight estimation when only few samples are available? This paper aims to fill the gap in terms of both theoretical understanding and practical methods for the label shift setting and thereby move a step closer towards having a more complete understanding on the general topic of supervised learning for distributionally shifted data. In particular, our goal is to find an efficient method which is applicable to large-scale data and to establish generalization guarantees.
Our contribution in this work is trifold. Firstly, we propose an efficient weight estimator for which we can obtain good statistical guarantees without a requirement on the problem-dependent minimum sample complexity as necessary for BBSL. In the BBSL case, the estimation error can become arbitrarily large for small sample sizes. Secondly, we propose a novel regularization method to compensate for the high estimation error of the importance weights in low target sample settings. It explicitly controls the influence of our weight estimates when the target sample size is low (in the following referred to as the low sample regime). Finally, we derive a dimension-independent generalization bound for the final Regularized Learning under Label Shift (RLLS) classifier based on our weight estimator. In particular, our method improves the weight estimation error and excess risk of the classifier on reweighted samples by a factor of k log(k), where k is the number of classes, i.e. the cardinality of Y . In order to demonstrate the benefit of the proposed method for practical situations, we empirically study the performance of RLLS and show weight estimation as well as prediction accuracy comparison for a variety of shifts, sample sizes and regularization parameters on the CIFAR-10 and MNIST datasets. For large target sample sizes and large shifts, when applying the regularized weights fully, we achieve an order of magnitude smaller weight estimation error than baseline methods and enjoy at most 20% higher accuracy and F-1 score in corresponding predictive tasks. For low target sample sizes, applying regularized weights partially also yields an accuracy improvement of at least 10% over fully weighted and unweighted methods.

heading: 2 REGULARIZED LEARNING OF LABEL SHIFTS (RLLS)
text: Formally let us the short hand for the marginal probability mass functions of Y on finite Y with respect to P,Q as p, q : [k] → [0, 1] with p(i) = P(Y = i), and q(i) = Q(Y = i) for all i ∈ [k], representable by vectors in Rk+ which sum to one. In the label shift setting, we define the importance weight vector w ∈ Rk between these two domains as w(i) = q(i)p(i) . We quantify the shift using the exponent of the infinite and second order Renyi divergence as follows
d∞(q||p) := sup i
q(i) p(i) , and d(q||p) := EY∼Q
[ w(Y )2 ] = k∑ i q(i) q(i) p(i) .
Given a hypothesis classH and a loss function ` : Y × Y → [0, 1], our aim is to find the hypothesis h ∈ H which minimizes
L(h) = EX,Y∼Q [`(Y, h(X))] = EX,Y∼P [w(Y )`(Y, h(X))]
In the usual finite sample setting however, L unknown and we observe samples {(xj , yj)}nj=1 from P instead. If we are given the vector of importance weights w we could then minimize the empirical loss with importance weighted samples defined as
Ln(h) = 1
n n∑ j=1 w(yj)`(yj , h(xj))
where n is the number of available observations drawn from P used to learn the classifier h. As w is unknown in practice, we have to find the minimizer of the empirical loss with estimated importance weights
Ln(h; ŵ) = 1
n n∑ j=1 ŵ(yj)`(yj , h(xj)) (1)
where ŵ are estimates of w. Given a set Dp of np samples from the source distribution P, we first divide it into two sets where we use (1 − β)np samples in set Dweightp to compute the estimate ŵ and the remaining n = βnp in the set Dclassp to find the classifier which minimizes the loss (1), i.e. ĥŵ = arg min h∈H Ln(h; ŵ). In the following, we describe how to estimate the weights ŵ and provide guarantees for the resulting estimator ĥŵ.
Plug-in weight estimation The following simple correlation between the label distributions p, q was noted in Lipton et al. (2018): for a fixed hypothesis h, if for all y ∈ Y it holds that q(y) ≥ 0 =⇒ p(y) ≥ 0, we have
qh(i) := Q(h(X) = i) = k∑ j=1 Q(h(X) = i|Y = j)q(j) = k∑ j=1 P(h(X) = i|Y = j)q(j)
= k∑ j=1 P(h(X) = i, Y = j) q(j) p(j) = k∑ j=1 P(h(X) = i, Y = j)wj
for all i, j ∈ Y . This can equivalently be written in matrix vector notation as
qh = Chw, (2)
where Ch is the confusion matrix with [Ch]i,j = P(h(X) = i, Y = j) and qh is the vector which represents the probability mass function of h(X) under distribution Q. The requirement q(y) ≥ 0 =⇒ p(y) ≥ 0 is a reasonable condition since without any prior knowledge, there is no way to properly reason about a class in the target domain that is not represented in the source domain.
In reality, both qh and Ch can only be estimated by the corresponding finite sample averages q̂h, Ĉh. Lipton et al. (2018) simply compute the inverse of the estimated confusion matrix Ĉh in order to estimate the importance weight, i.e. ŵ = Ĉ−1h q̂h. While C −1 h q̂h is a statistically efficient estimator, ŵ with estimated Ĉ−1h can be arbitrarily bad since Ĉ −1 h can be arbitrary close to a singular matrix especially for small sample sizes and small minimum singular value of the confusion matrix. Intuitively, when there are very few samples, the weight estimation will have high variance in which case it might be better to avoid importance weighting altogether. Furthermore, even when the sample complexity in Lipton et al. (2018), unknown in practice, is met, the resulting error of this estimator is linear in k which is problematic for large k.
We therefore aim to address these shortcomings by proposing the following two-step procedure to compute importance weights. In the case of no shift we have w = 1 so that we define the amount of weight shift as θ = w − 1. Given a “decent” black box estimator which we denote by h0, we make the final classifier less sensitive to the estimation performance of C (i.e. regularize the weight estimate) by
1. calculating the measurement error adjusted θ̂ (described in Section 2.1 for h0) and
2. computing the regularized weight ŵ = 1+λθ̂ where λ depends on the sample size (1−β)np.
By "decent" we refer to a classifier h0 which yields a full rank confusion matrix Ch0 . A trivial example for a non-”decent” classifier h0 is one that always outputs a fixed class. As it does not capture any characteristics of the data, there is no hope to gain any statistical information without any prior information.

heading: 2.1 ESTIMATOR CORRECTING FOR FINITE SAMPLE ERRORS
text: Both the confusion matrix Ch0 and the label distribution qh0 on the target for the black box hypothesis h0 are unknown and we are instead only given access to finite sample estimates Ĉh0 , q̂h0 . In what follows all empirical and population confusion matrices, as well as label distributions, are defined with respect to the hypothesis h = h0. For notation simplicity, we thus drop the subscript h0 in what follows. The reparameterized linear model (2) with respect to θ then reads
b := q − C1 = Cθ
with corresponding finite sample quantity b̂ = q̂ − Ĉ1. When Ĉ is near singular, the estimation of θ becomes unstable. Furthermore, large values in the true shift θ result in large variances. We address this problem by adding a regularizing `2 penalty term to the usual loss and thus push the amount of shift towards 0, a method that has been proposed in (Pires & Szepesvári, 2012). In particular, we compute
θ̂ = arg min θ
‖Ĉθ − b̂‖2 + ∆C‖θ‖2 (3)
Here, ∆C is a parameter which will eventually be high probability upper bounds for ‖Ĉ − C‖2. Let ∆b also denote the high probability upper bounds for ‖b̂− b‖2. Lemma 1 For θ̂ as defined in equation (3), we have with probability at least 1− δ that1
‖θ̂ − θ‖2 ≤ θ(np, nq, ‖θ‖2, δ) where
θ(np, nq, ‖θ‖2, δ) := O
( 1
σmin
( ‖θ‖2
√ log(k/δ)
(1− β)np +
√ log(1/δ)
(1− β)np +
√ log(1/δ)
nq
)) .
The proof of this lemma can be found in Appendix B.1. A couple of remarks are in order at this point. First of all, notice that the weight estimation procedure (3) does not require a minimum sample complexity which is in the order of σ−2min to obtain the guarantees for BBSL. This is due to the fact that errors in the covariates are accounted for. In order to directly see the improvements in the upper bound of Lemma 1 compared to Theorem 3 in Lipton et al. (2018), first observe that in order to obtain their upper bound with a probability of at least 1 − δ, it is necessary that 3kn−10p + 2kn −10 q ≤ δ. As a consequence, the upper bound in Theorem 3 of Lipton et al. (2018)
is bigger than 13σmin ( ‖θ‖2 √ log(3k/δ) np + √ k log(2k/δ) nq ) . Thus Lemma 1 improves upon the previous upper bound by a factor of k.
Furthermore, as in Lipton et al. (2018), this result holds for any black box estimator h0 which enters the bound via σmin(Ch0). We can directly see how a good choice of h0 helps to decrease the upper bound in Lemma 1. In particular, if h0 is an ideal estimator, and the source set is balanced, C is the unit matrix with σmin = 1/k. In contrast, when the model h0 is uncertain, the singular value σmin is close to zero.
Moreover, for least square problems with Gaussian measurement errors in both input and target variables, it is standard to use regularized total least squares approaches which requires a singular value decomposition. Finally, our choice for the alternative estimator in Eq. 3 with norm instead of norm squared regularization is motivated by the cases with large shifts θ, where using the squared norm may shrink the estimate θ̂ too much and away from the true θ.
1Throughout the paper, O hides universal constant factors. Furthermore, we use O (·+ ·) for short to denote O (·) +O (·).
Algorithm 1 Regularized Learning of Label Shift (RLLS) 1: Input: source set Dp, Dq , θmax, estimate of σmin, black box estimator h0, model classH 2: Determine optimal split ratio β? and regularizer λ? by minimizing the RHS of Eq. (6) using an
estimate of σmin 3: Randomly partition source set Dp into Dclassp , D weight p such that |Dclassp | = β?np =: n 4: Compute θ̂ using Eq. (3) and ŵ := 1 + λ?θ̂ 5: Minimize the importance weighted empirical loss to obtain the weighted estimator
ĥŵ = arg min h∈H Ln(h; ŵ), where Ln(h; ŵ) =
1
n ∑ (x,y)∈Dclassp ŵ(y)`(y, h(x))
6: Deploy ĥŵ if the risk is acceptable

heading: 2.2 REGULARIZED ESTIMATOR AND GENERALIZATION BOUND
text: When a few samples from the target set are available or the label shift is mild, the estimated weights might be too uncertain to be applied. We therefore propose a regularized estimator defined as follows
ŵ = 1 + λθ̂. (4)
Note that ŵ implicitly depends on λ, and β. By rewriting ŵ = (1 − λ)1 + λ(1 + θ̂), we see that intuitively λ closer to 1 the more reason there is to believe that 1 + θ̂ is in fact the true weight.
Define the set G(`,H) = {gh(x, y) = w(y)`(h(x), y) : h ∈ H} and its Rademacher complexity measure
Rn(G) := E(Xi,Yi)∼P:i∈[n] [ Eξi:i∈[n] 1
n [ sup h∈H n∑ i=1 ξigh(Xi, h(Yi)) ]] with ξi, ∀i as the Rademacher random variables (see e.g. Bartlett & Mendelson (2002)). We can now state a generalization bound for the classifier ĥŵ in a general hypothesis classH, which is trained on source data with the estimated weights defined in equation (4).
Theorem 1 (Generalization bound for ĥŵ) Given np samples from the source data set and nq samples from the target set, a hypothesis classH and loss function `, the following generalization bound holds with probability at least 1− 2δ
L(ĥŵ)− L(h∗) ≤ G(np, δ, β) + (1− λ) ‖θ‖2 + λ θ(np, nq, ‖θ‖2, δ, β). (5)
where
G(np, δ) := 2Rn(G) + min { d∞(q||p) √ log(2/δ)
βnp , 2d∞(q||p) log(2/δ) n +
√ 2 d(q||p) log(2/δ)
n
} .
The proof can be found in Appendix B.4. Additionally, we derive the analysis also for finite hypothesis classes in Appendix B.6 to provide more insight into the proof of general hypothesis classes. The size ofRn(G) is determined by the structure of the function classH and the loss `. For example for the 0/1 loss, the VC dimension ofH can be deployed to upper bound the Rademacher complexity. The bound (5) in Theorem 1 holds for all choices of λ. In order to exploit the possibility of choosing λ and β to have an improved accuracy depending on the sample sizes, we first let the user define a set of shifts θ against which we want to be robust against, i.e. all shifts with ‖θ‖2 ≤ θmax. For these shifts, we obtain the following upper bound
L(ĥŵ)− L(h∗) ≤ G(np, δ) + (1− λ) θmax + λ θ(np, nq, θmax, δ) (6)
The bound in equation (6) suggests using Algorithm 1 as our ultimate label shift correction procedure. where for step 2 of the algorithm, we choose λ? = 1 whenever nq ≥ 1θ2max(σmin− 1√np )2 (hereby neglecting the log factors and thus dependencies on k) and 0 else. When using this rule, we
obtain L(ĥŵ) − L(h∗) ≤ G(np, δ) + min{θmax, θ(np, nq, θmax, δ)} which is smaller than the unregularized bound for small nq, np. Notice that in practice, we do not know σmin in advance so that in Algorithm 1 we need to use an estimate of σmin, which could e.g. be the minimum eigenvalue of the empirical confusion matrix Ĉ with an additional computational complexity of at most O(k3).
Figure 1 shows how the oracle thresholds vary with nq and σmin when np is kept fix. When the parameters are above the curves for fixed np, λ should be chosen as 1 otherwise the samples should be unweighted, i.e. λ = 0. This figure illustrates that when the confusion matrix has small singular values, the estimated weights should only be trusted for rather high nq and high believed shifts θmax. Although the overall statistical rate of the excess risk of the classifier does not change as a function of the sample sizes, θmax could be significantly smaller than θ when σmin is very small and thus the accuracy in this regime could improve. Indeed we observe this to be the case empirically in Section 3.3.
In the case of slight deviation from the label shift setting, we expect the Alg. 1 to perform reasonably. For de(q||p) := E(X,Y )∼Q [∣∣∣1− p(X|Y )q(X|Y ) ∣∣∣] as the deviation form label shift constraint, i.e., zero under label shift assumption, we have
Theorem 2 (Drift in Label shift assumption) In the presence of de(q||p) deviation from label shift assumption, the true importance weights ω(x, y) := q(x,y)p(x,y) , the RLLS generalizes as;
L(ĥŵ, ω)− L(h∗;ω) ≤ G(np, δ) + (1− λ) ‖θ‖2 + λ θ(np, nq, ‖θ‖2, δ) + 4 (1− λ) de(q||p)
with high probability. Proof in Appendix B.7.

heading: 3 EXPERIMENTS
text: In this section we illustrate the theoretical analysis by running RLLS on a variety of artificially generated shifts on the MNIST (LeCun & Cortes, 2010) and CIFAR10 (Krizhevsky & Hinton, 2009) datasets. We first randomly separate the entire dataset into two sets (source and target pool) of the same size. Then we sample, unless specified otherwise, the same number of data points from each pool to form the source and target set respectively. We chose to have equal sample sizes to allow for fair comparisons across shifts.
There are various kinds of shifts which we consider in our experiments. In general we assume one of the source or target datasets to have uniform distribution over the labels. Within the non-uniform set, we consider three types of sampling strategies in the main text: the Tweak-One shift refers to the case where we set a class to have probability p > 0.1, while the distribution over the rest of the classes is uniform. The Minority-Class Shift is a more general version of Tweak-One shift, where a fixed number of classes m to have probability p < 0.1, while the distribution over the rest of the classes is uniform. For the Dirichlet shift, we draw a probability vector p from the Dirichlet distribution with concentration parameter set to α for all classes, before including sample points which correspond to the multinomial label variable according to p. Results for the tweak-one shift strategy as in Lipton et al. (2018) can be found in Section A.0.1.
After artificially shifting the label distribution in one of the source and target sets, we then follow algorithm 1, where we choose the black box predictor h0 to be a two-layer fully connected neural network trained on (shifted) source dataset. Note that any black box predictor could be employed here, though the higher the accuracy, the more likely weight estimation will be precise. Therefore, we use different shifted source data to get (corrupted) black box predictor across experiments. If not noted, h0 is trained using uniform data.
In order to compute ω̂ = 1+ θ̂ in Eq. (3), we call a built-in solver to directly solve the low dimensional problem minθ ‖Ĉθ − b̂‖2 + ∆C‖θ‖2 where we empirically observer that 0.01 times of the true ∆C yields in a better estimator on various levels of label shift pre-computed beforehand. It is worth noting that 0.001 makes the theoretical bound in Lemma. 1 O(1/0.01) times bigger. We thus treat it as a hyperparameter that can be chosen using standard cross validation methods. Finally, we train
a classifier on the source samples weighted by ω̂, where we use a two-layer fully connected neural network for MNIST and a ResNet-18 (He et al., 2016) for CIFAR10.
We sample 20 datasets with the label distributions for each shift parameter. to evaluate the empirical mean square estimation error (MSE) and variance of the estimated weights E‖ŵ − w‖22 and the predictive accuracy on the target set. We use these measures to compare our procedure with the black box shift learning method (BBSL) in Lipton et al. (2018). Notice that although KMM methods (Zhang et al., 2013) would be another standard baseline to compare with, it is not scalable to large sample size regimes for np, nq above n = 8000 as mentioned by Lipton et al. (2018).

heading: 3.1 WEIGHT ESTIMATION AND PREDICTIVE PERFORMANCE FOR SOURCE SHIFT
text: In this set of experiments on the CIFAR10 dataset, we illustrate our weight estimation and prediction performance for Tweak-One source shifts and compare it with BBSL. For this set of experiments, we set the number of data points in both source and target set to 10000 and sample from the two pools without replacement.
Figure 2 illustrates the weight estimation alongside final classification performance for Minority-Class source shift of CIFAR10. We created shifts with ρ > 0.5. We use a fixed black-box classifier that is trained on biased source data, with tweak-one ρ = 0.5. Observe that the MSE in weight estimation is relatively large and RLLS outperforms BBSL as the number of minority classes increases. As the shift increases the performance for all methods deteriorates. Furthermore, Figure 2 (b) illustrates how the advantage of RLLS over the unweighted classifier increases as the shift increases. Across all shifts, the RLLS based classifier yields higher accuracy than the one based on BBSL. Results for MNIST can be found in Section A.1.

heading: 3.2 WEIGHT ESTIMATION AND PREDICTIVE PERFORMANCE FOR TARGET SHIFT
text: In this section, we compare the predictive performances between a classifier trained on unweighted source data and the classifiers trained on weighted loss obtained by the RLLS and BBSL procedure on CIFAR10. The target set is shifted using the Dirichlet shift with parameters α = [0.01, 0.1, 1, 10]. The number of data points in both source and target set is 10000.
In the case of target shifts, larger shifts actually make the predictive task easier, such that even a constant majority class vote would give high accuracy. However it would have zero accuracy on all but one class. Therefore, in order to allow for a more comprehensive performance between the methods, we also compute the macro-averaged F-1 score by averaging the per-class quantity 2(precision · recall)/(precision + recall) over all classes. For a class i, precision is the percentage of correct predictions among all samples predicted to have label i, while recall is the proportion of correctly predicted labels over the number of samples with true label i. This measure gives higher weight to the accuracies of minority classes which have no effect on the total accuracy.
Figure 3 depicts the MSE of the weight estimation (a), the corresponding performance comparison on accuracy (b) and F-1 score (c). Recall that the accuracy performance for low shifts is not comparable with standard CIFAR10 benchmark results because of the overall lower sample size chosen for the comparability between shifts. We can see that in the large target shift case for α = 0.01, the F-1
score for BBSL and the unweighted classifier is rather low compared to RLLS while the accuracy is high. As mentioned before, the reason for this observation and why in Figure 3 (b) the accuracy is higher when the shift is larger, is that the predictive task actually becomes easier with higher shift.

heading: 3.3 REGULARIZED WEIGHTS IN THE LOW SAMPLE REGIME FOR SOURCE SHIFT
text: In the following, we present the average accuracy of RLLS in Figure 4 as a function of the number of target samples nq for different values of λ for small nq . Here we fix the sample size in the source set to np = 1000 and investigate a Minority-Class source shift with fixed p = 0.01 and five minority classes.
A motivation to use intermediate λ is discussed in Section 2.2, as λ in equation (4) may be chosen according to θmax, σmin. In practice, since θmax is just an upper bound on the true amount of shift ‖θ‖2, in some cases λ should in fact ideally be 0 when 1θ2max(σmin− 1√nq )2 ≤ nq ≤ 1‖θ‖2(σmin− 1√nq )2 . Thus for target sample sizes nq that are a little bit above the threshold (depending on the certainty of the belief how close to θmax the norm of the shift is believed to be), it could be sensible to use an intermediate value λ ∈ (0, 1).
Figure 4 suggests that unweighted samples (red) yield the best classifier for very few samples nq, while for 10 ≤ nq ≤ 500 an intermediate λ ∈ (0, 1) (purple) has the highest accuracy and for nq > 1000, the weight estimation is certain enough for the fully weighted classifier (yellow) to have the best performance (see also the corresponding data points in Figure 2). The unweighted BBSL classifier is also shown for completeness. We can conclude that regularizing the influence of the estimated weights allows us to adjust to the uncertainty on importance weights and generalize well for a wide range of target sample sizes.
Furthermore, the different plots in Figure 4 correspond to black-box predictors h0 for weight estimation which are trained on more or less corrupted data, i.e. have a better or worse conditioned
confusion matrix. The fully weighted methods with λ = 1 achieve the best performance faster with a better trained black-box classifier (a), while it takes longer for it to improve with a corrupted one (c). Furthermore, this reflects the relation between eigenvalue of confusion matrix σmin and target sample size nq in Theorem 1. In other words, we need more samples from the target data to compensate a bad predictor in weight estimation. So the generalization error decreases faster with an increasing number of samples for good predictors.
In summary, our RLLS method outperforms BBSL in all settings for the common image datasets MNIST and CIFAR10 to varying degrees. In general, significant improvements compared to BBSL can be observed for large shifts and the low sample regime. A note of caution is in order: comparison between the two methods alone might not always be meaningful. In particular, there are cases when the estimator trained on unweighted samples outperforms both RLLS and BBSL. Our extensive experiments for many different shifts, black box classifiers and sample sizes do not allow for a final conclusive statement about how weighting samples using our estimator affects predictive results for real-world data in general, as it usually does not fulfill the label-shift assumptions.

heading: 4 RELATED WORK
text: The covariate and label shift assumptions follow naturally when viewing the data generating process as a causal or anti-causal model (Schölkopf et al., 2012): With label shift, the label Y causes the input X (that is, X is not a causal parent of Y , hence "anti-causal") and the causal mechanism that generates X from Y is independent of the distribution of Y . A long line of work has addressed the reverse causal setting where X causes Y and the conditional distribution of Y given X is assumed to be constant. This assumption is sensible when there is reason to believe that there is a true optimal mapping from X to Y which does not change if the distribution of X changes. Mathematically this scenario corresponds to the covariate shift assumption.
Among the various methods to correct for covariate shift, the majority uses the concept of importance weights q(x)/p(x) (Zadrozny, 2004; Cortes et al., 2010; Cortes & Mohri, 2014; Shimodaira, 2000), which are unknown but can be estimated for example via kernel embeddings (Huang et al., 2007; Gretton et al., 2009; 2012; Zhang et al., 2013; Zaremba et al., 2013) or by learning a binary discriminative classifier between source and target (Lopez-Paz & Oquab, 2016; Liu et al., 2017). A minimax approach that aims to be robust to the worst-case shared conditional label distribution between source and target has also been investigated (Liu & Ziebart, 2014; Chen et al., 2016). Sanderson & Scott (2014); Ramaswamy et al. (2016) formulate the label shift problem as a mixture of the class conditional covariate distributions with unknown mixture weights. Under the pairwise mutual irreducibility (Scott et al., 2013) assumption on the class conditional covariate distributions, they deploy the Neyman-Pearson criterion (Blanchard et al., 2010) to estimate the class distribution q(y) which also investigated in the maximum mean discrepancy framework (Iyer et al., 2014).
Common issues shared by these methods is that they either result in a massive computational burden for large sample size problems or cannot be deployed for neural networks. Furthermore, importance weighting methods such as (Shimodaira, 2000) estimate the density (ratio) beforehand, which is a difficult task on its own when the data is high-dimensional. The resulting generalization bounds based on importance weighting methods require the second order moments of the density ratio (q(x)/p(x))2 to be bounded, which means the bounds are extremely loose in most cases (Cortes et al., 2010).
Despite the wide applicability of label shift, approaches with global guarantees in high dimensional data regimes remain under-explored. The correction of label shift mainly requires to estimate the importance weights q(y)/p(y) over the labels which typically live in a very low-dimensional space. Bayesian and probabilistic approaches are studied when a prior over the marginal label distribution is assumed (Storkey, 2009; Chan & Ng, 2005). These methods often need to explicitly compute the posterior distribution of y and suffer from the curse of dimensionality. Recent advances as in Lipton et al. (2018) have proposed solutions applicable large scale data. This approach is related to Buck et al. (1966); Forman (2008); Saerens et al. (2002) in the low dimensional setting but lacks guarantees for the excess risk.
Existing generalization bounds have historically been mainly developed for the case when P = Q (see e.g. Vapnik (1999); Bartlett & Mendelson (2002); Kakade et al. (2009); Wainwright (2019)).
Ben-David et al. (2010) provides theoretical analysis and generalization guarantees for distribution shifts when the H-divergence between joint distributions is considered, whereas Crammer et al. (2008) proves generalization bounds for learning from multiple sources. For the covariate shift setting, Cortes et al. (2010) provides a generalization bound when q(x)/p(x) is known which however does not apply in practice. To the best of our knowledge our work is the first to give generalization bounds for the label shift scenario.

heading: 5 DISCUSSION
text: In this work, we establish the first generalization guarantee for the label shift setting and propose an importance weighting procedure for which no prior knowledge of q(y)/p(y) is required. Although RLLS is inspired by BBSL, it leads to a more robust importance weight estimator as well as generalization guarantees in particular for the small sample regime, which BBSL does not allow for. RLLS is also equipped with a sample-size-dependent regularization technique and further improves the classifier in both regimes.
We consider this work a necessary step in the direction of solving shifts of this type, although the label shift assumption itself might be too simplified in the real world. In future work, we plan to also study the setting when it is slightly violated. For instance, x in practice cannot be solely explained by the wanted label y, but may also depend on attributes z which might not be observable. In the disease prediction task for example, the symptoms might not only depend on the disease but also on the city and living conditions of its population. In such a case, the label shift assumption only holds in a slightly modified sense, i.e. P(X|Y = y, Z = z) = Q(X|Y = y, Z = z). If the attributes Z are observed, then our framework can readily be used to perform importance weighting.
Furthermore, it is not clear whether the final predictor is in fact “better” or more robust to shifts just because it achieves a better target accuracy than a vanilla unweighted estimator. In fact, there is a reason to believe that under certain shift scenarios, the predictor might learn to use spurious correlations to boost accuracy. Finding a procedure which can both learn a robust model and achieve high accuracies on new target sets remains to be an ongoing challenge. Moreover, the current choice of regularization depends on the number of samples rather than data-driven regularization which is more desirable.
An important direction towards active learning for the same disease-symptoms scenario is when we also have an expert for diagnosing a limited number of patients in the target location. Now the question is which patients would be most "useful" to diagnose to obtain a high accuracy on the entire target set? Furthermore, in the case of high risk, we might be able to choose some of the patients for further medical diagnosis or treatment, up to some varying cost. We plan to extend the current framework to the active learning setting where we actively query the label of certain x’s (Beygelzimer et al., 2009) as well as the cost-sensitive setting where we also consider the cost of querying labels (Krishnamurthy et al., 2017).
Consider a realizable and over-parameterized setting, where there exists a deterministic mapping from x to y, and also suppose a perfect interpolation of the source data with a minimum proper norm is desired. In this case, weighting the samples in the empirical loss might not alter the trained classifier (Belkin et al., 2018). Therefore, our results might not directly help the design of better classifiers in this particular regime. However, for the general overparameterized settings, it remains an open problem of how the importance weighting can improve the generalization. We leave this study for future work.

heading: 6 ACKNOWLEDGEMENT
text: K. Azizzadenesheli is supported in part by NSF Career Award CCF-1254106. This research has been conducted when the first author was a visiting researcher at Caltech. Anqi Liu is supported in part by DOLCIT Postdoctoral Fellowship at Caltech and Caltech’s Center for Autonomous Systems and Technologies. Fan Yang is supported by the Institute for Theoretical Studies ETH Zurich and the Dr. Max Rössler and the Walter Haefner Foundation. A. Anandkumar is supported in part by Microsoft Faculty Fellowship, Google faculty award, Adobe grant, NSF Career Award CCF- 1254106, and AFOSR YIP FA9550-15-1-0221.

heading: A MORE EXPERIMENTAL RESULTS
text: This section contains more experiments that provide more insights about in which settings the advantage of using RLLS vs. BBSL are more or less pronounced.

heading: A.0.1 CIFAR10 EXPERIMENTS UNDER TWEAK-ONE SHIFT AND DIRICHLET SHIFT
text: Here we compare weight estimation performance between RLLS and BBSL for different types of shifts including the Tweak-one Shift, for which we randomly choose one class, e.g. i and set p(i) = ρ while all other classes are distributed evenly. Figure 5 depicts the the weight estimation performance of RLLS compared to BBSL for a variety of values of ρ and α. Note that larger shifts correspond to smaller α and larger ρ. In general, one observes that our RLLS estimator has smaller MSE and that as the shift increases, the error of both methods increases. For tweak-one shift we can additionally see that as the shift increases, RLLS outperforms BBSL more and more as both in terms of bias and variance.

heading: A.1 MNIST EXPERIMENTS UNDER MINORITY-CLASS SOURCE SHIFTS FOR DIFFERENT
text: VALUES OF p
In order to show weight estimation and classification performance under different level of label shifts, we include several additional sets of experiments here in the appendix. Figure 6 shows the weight estimation error and accuracy comparison under a minority-class shift with p = 0.001. The training and testing sample size is 10000 examples in this case. We can see that whenever the weight estimation of RLLS is better, the accuracy is also better, except in the four classes case when both methods are bad in weight estimation.
Figure 7 demonstrates another case in minority-class shift when p = 0.01. The black-box classifier is the same two-layers neural network trained on a biased source data set with tweak-one ρ = 0.5. We observe that when the number of minority class is small like 1 or 2, the weight estimation is similar
between two methods, as well as in the classification accuracy. But when the shift get larger, the weights are worse and the performance in accuracy decreases, getting even worse than the unweighted classifier.
Figure 8 illustrates the weight estimation alongside final classification performance for Minority-Class source shift of MNIST. We use 1000 training and testing data. We created large shifts of three or more minority classes with p = 0.005. We use a fixed black-box classifier that is trained on biased source data, with tweak-one ρ = 0.5. Observe that the MSE in weight estimation is relatively large and RLLS outperforms BBSL as the number of minority classes increases. As the shift increases the performance for all methods deteriorates. Furthermore, Figure 8 (b) illustrates how the advantage of RLLS over the unweighted classifier increases as the shift increases. Across all shifts, the RLLS based classifier yields higher accuracy than the one based on BBSL.

heading: A.2 CIFAR10 EXPERIMENT UNDER DIRICHLET SOURCE SHIFTS
text: Figure 9 illustrates the weight estimation alongside final classification performance for Dirichlet source shift of CIFAR10 dataset. We use 10000 training and testing data in this experiment, following the way we generate shift on source data. We train h0 with tweak-one shifted source data with ρ = 0.5. The results show that importance weighting in general is not helping the classification in this relatively large shift case, because the weighted methods, including true weights and estimated weights, are similar in accuracy with the unweighted method.

heading: A.3 MNIST EXPERIMENT UNDER DIRICHLET SHIFT WITH LOW TARGET SAMPLE SIZE
text: We show the performance of classifier with different regularization λ under a Dirichlet shift with α = 0.5 in Figure 10. The training has 5000 examples in this case. We can see that in this low target sample case, λ = 1 only take over after several hundreds example, while some λ value between 0 and 1 outperforms it at the beginning. Similar as in the paper, we use different black-box classifier that is corrupted in different levels to show the relation between the quality of black-box predictor and the necessary target sample size. We use biased source data with tweak-one ρ = 0, 0.2, 0.6 to train the black-box classifier. We see that we need more target samples for the fully weighted version λ = 1 to take over for a more corrupted black-box classifier.

heading: B PROOFS

heading: B.1 PROOF OF LEMMA 1
text: From Thm. 3.4 in (Pires & Szepesvári, 2012) we know that for θ̂ as defined in equation (3), if with probability at least 1− δ, ‖Ĉ − C‖2 ≤ ∆C and ‖b̂− b‖2 ≤ ∆b hold simultaneously, then
Υ(θ̂) ≤ inf θ′∈Rk {Υ(θ′) + 2∆C‖θ′‖α}+ 2∆b. (7)
where we use the shorthand Υ(θ′) = ‖Cθ′ − b‖2. We can get an upper bound on the right hand side of (7) is the infimum by simply choosing a feasible θ′ = θ. We then have ‖Cθ − b‖2 = 0 and hence
inf θ′ {Υ(θ′) + 2∆C‖θ′‖2} ≤ 2∆C‖θ‖2
as a consequence, Υ(θ̂) = ‖Cθ̂ − b‖2 = ‖C ( θ̂ − θ ) ‖2 ≤ 2∆C‖θ‖2 + 2∆b Since ‖C ( θ̂ − θ ) ‖2 ≥ σmin(C)‖θ̂− θ‖2 by definition of the minimum singular value, we thus have
‖θ̂ − θ‖2 ≤ 1
σmin (2∆C‖θ‖2 + 2∆b)
Let us first notice that
bh = qh − C1 = qh − ph
The mathematical definition of the finite sample estimates Ĉh, b̂h (in matrix and vector representation) with respect to some hypothesis h are as follows
[Ĉh]ij = 1
(1− β)np ∑ (x,y)∈Dp Ih(x)=i,y=j
[̂bh](i) = 1
m ∑ (x,y)∈Dq Ih(x)=i − 1 (1− β)np ∑ (x,y)∈Dweightp Ih(x)=i
where m = |Dq| and I is the indicator function. Ch, bh can equivalently be expressed with the population over P for Ch and over Q for bh respectively. We now use the following concentration Lemmas to bound the estimation errors of Ĉ, b̂ where we drop the subscript h for ease of notation.
Lemma 2 (Concentration of measurement matrix Ĉ) For finite sample estimate Ĉ we have
‖Ĉ − C‖2 ≤ 2 log (2k/δ)
3(1− β)np +
√ 2 log (2k/δ)
(1− β)np with probability at least (1− δ).
Lemma 3 (Concentration of label measurements) For the finite sample estimate b̂ with respect to any hypothesis h it holds that
‖b̂h − bh‖2 ≤ 2√
log(2)
( √ log(1/δ)√
(1− β)np + √ log(1/δ) √ nq ) with probability at least 1− 2δ.
By Lemma. 2 for concentration of C and Lemma. 3 for concentration of b we now have with probability at least 1− δ
‖θ̂ − θ‖2 ≤ 1
σmin
( 2‖θ‖2 log (2k/δ)
(1− β)np + ‖θ‖2
√ 18 log (4k/δ)
(1− β)np
+
√ 36 log (2/δ)
nq +
√ 36 log (2/δ)
(1− β)np
) .
which, considering that O( 1√ n ) dominates O( 1n ), yields the statement of the Lemma 1.

heading: B.2 PROOF OF LEMMA 2
text: We prove this lemma using the theorem 1.4[Matrix Bernstein] and Dilations technique from Tropp (2012). We can rewrite Ch = E(x,y)∼P [ eh(x)e > y ] where e(i) is the one-hot-encoding of index i. Consider a finite sequence {Ψ(i)} of independent random matrices with dimension k. By dilations, lets construct another sequence of self-adjoint random matrices of {Ψ̃(i)} of dimension 2k, such that for all i
Ψ̃(i) =
[ 0 Ψ(i)
Ψ(i)> 0 ] therefore,
Ψ̃(i)2 =
[ Ψ(i)Ψ(i)> 0
0 Ψ(i)>Ψ(i)
] (8)
which results in ‖Ψ̃(i)‖2 = ‖Ψ(i)‖2. The dilation technique translates the initial sequence of random matrices to the sequence of random self-adjoint matrices where we can apply the Matrix Bernstein theorem which states that, for a finite sequence of i.i.d. self-adjoint matrices Ψ̃(i), such that, almost surely ∀i, E [ Ψ̃(i) ] = 0 and ‖Ψ̃(i)‖ ≤ R, then for all t ≥ 0,
‖1 t t∑ i=1 Ψ̃(i)‖ ≤ R log (2k/δ) 3t +
√ 2%2 log (2k/δ)
t
with probability at least 1− δ where %2 := ‖E [ Ψ̃2(i) ] ‖2, ∀i which is also %2 = ‖E [ Ψ2(i) ] ‖2, ∀i
due to Eq. 8. Therefore, thanks to the dilation trick and theorem 1.4[Matrix Bernstein] in Tropp (2012),
‖1 t t∑ i=1 Ψ(i)‖ ≤ R log (2k/δ) 3t +
√ 2%2 log (2k/δ)
t
with probability at least 1− δ. Now, by plugging in Ψ(i) = eh(x(i))e>y(i) −C, we have E [ Ψ̃(i) ] = 0. Together with ‖Ψ̃(i)‖ ≤ 2 as
well as %2 = ‖E [ Ψ2(i) ] ‖2 = 1 and setting t = n, we have
‖Ĉ − C‖2 ≤ 2 log (2k/δ)
3(1− β)n +
√ 2 log (2k/δ)
(1− β)n

heading: B.3 PROOF OF LEMMA 3
text: The proof of this lemma is mainly based on a special case of and appreared at proposition 6 in Azizzadenesheli et al. (2016), Lemma F.1 in Anandkumar et al. (2012) and Proposition 19 of Hsu et al. (2012).
Analogous to the previous section we can rewrite bh = E(x,y)∈Q[eh(x)]− E(x,y)∈P[eh(x)] where e(i) is the one-hot-encoding of index i. Note that (dropping the subscript h) we have
‖b̂h − bh‖2 ≤ ‖q̂h − qh‖2 + ‖p̂h − ph‖2 We now bound both estimates of probability vectors separately.
Consider a fixed multinomial distribution characterized with probability vector of ς ∈ ∆k−1 where ∆k−1 is a k − 1 dimensional simplex. Further, consider t realization of this multinomial distribution {ς(i)}ti=1 where ς(i) is the one-hot-encoding of the i’th sample. Consider the empirical estimate mean of this distribution through empirical average of the samples; ς̂ = 1t ∑ (i)tς(i), then
‖ς̂ − ς‖ ≤ 1√ t +
√ log (1/δ)
t
with probability at least 1− δ. By plugging in ς = qh, ς̂ = q̂h with t = nq and finally {ς(i)} nq i=1 = {eh(x(i))}(i)nq and equivalently for ph we obtain;
‖b̂h − bh‖2 ≤
( √ log(1/δ)√
(1− β)np + √ log(1/δ) √ nq ) + ( 1√ (1− β)np + 1 √ nq ) with probability at least 1− 2δ, therefore;
‖b̂h − bh‖2 ≤ 2√
log(2)
( √ log(1/δ)√
(1− β)np + √ log(1/δ) √ nq ) resulting in the statement in the Lemma 3.

heading: B.4 PROOF OF THEOREM 1
text: We want to ultimately bound |L(ĥŵ)− L(h?)|. By addition and subtraction we have L(ĥŵ)− L(h?) = L(ĥŵ)− Ln(ĥŵ)︸ ︷︷ ︸
(b)
+Ln(ĥŵ)− Ln(ĥŵ; ŵ)︸ ︷︷ ︸ (a)
+ Ln(ĥŵ; ŵ)− Ln(h?; ŵ)︸ ︷︷ ︸ ≤0 +Ln(h?; ŵ)− Ln(h?)︸ ︷︷ ︸ (a) +Ln(h?)− L(h?)︸ ︷︷ ︸ (b) (9)
where n = βnp and we used optimality of ĥŵ. Here (a) is the weight estimation error and (b) is the finite sample error.
Uniform law for bounding (b) We bound (b) using standard results for uniform laws for uniformly bounded functions which holds since ‖w‖∞ ≤ d∞(q||p) and ‖`‖∞ ≤ 1. Since |w(y)`(h(x), y)| ≤ d∞(q||p), ∀x, y ∈ X × Y , by deploying the McDiarmid’s inequality we then obtain that
sup h∈H |Ln(h)− L(h)| ≤ 2Rn(G(`,H)) + d∞(q||p) √ log 2δ n
where G(`,H) = {gh(x, y) = w(y)`(h(x), y) : h ∈ H} and the Rademacher complexity is defined asRn(G) := EX(i),Y (i)∼P:i∈[n] [ Eσi:i∈[n] 1 n [suph∈H ∑n i=1 σiw(yi)`(xi, h(yi))] ] .
of the hypothesis class H (see for example Percy Liang notes on Statistical Learning Theory and chapter 4 in Wainwright (2019))
Bounding term (a) Remember that k = |Y| is the cardinality of the finite domain of Y , or the number of classes. Let us define ˜̀∈ Rk with ˜̀j = ∑ni=1 Iy(i)=j`(y(i), h(x(i))). Notice that by definition ‖˜̀‖1 ≤ n and ‖˜̀‖∞ ≤ n from which it follows by Hoelder’s inequality that ‖˜̀‖2 ≤ n. Furthermore, we slightly abuse notation and usew to denote the k-dimensional vector withwi = w(i). Therefore, for all h we have via the Cauchy Schwarz inequality that
|Ln(h;w)− Ln(h; ŵ)| = | 1
n n∑ i=1 (w(y(i))− ŵ(y(i)))`(h(x(i)), y(i))|
≤ | 1 n k∑ j=1 (w(j)− ŵ(j))˜̀(j)| ≤ 1 n ‖ŵ − w‖2‖˜̀‖2 ≤ ‖ŵ − w‖2
≤ ‖λθ̂ − θ‖2 ≤ (1− λ)‖θ‖2 + λ‖θ̂ − θ‖2 (10)
It then follows by Lemma 1 that
sup h∈H |Ln(h;w)− Ln(h; ŵ)| ≤ (1− λ)‖θ‖2
O
( λ
σmin
( (‖θ‖2)
√ log(k/δ)
(1− β)np +
√ log(1/δ)
(1− β)np
√ log(1/δ)
nq )) Lemma 4 (McDiarmid-Doob-Freedman-Rademacher) For a given A hypothesis class H, a set G(`,H) = {gh(x, y) = w(y)`(h(x), y) : h ∈ H}, under n data points and loss function ` we have
sup h∈H |Ln(h)− L(h)| ≤ 2R(G(`,H)) + 2d∞(q||p) log(2/δ) n +
√ 2 d(q||p) log(2/δ)
n
with probability at least 1− δ
Plugging both bounds back into equation (9) concludes the proof of the theorem.

heading: B.5 PROOF OF LEMMA 4
text: With a bit abuse of notation let’s restate the empirical loss with known importance weights instead on the random variables {(Xi, Yi)}n1
Ln(h) = 1
n n∑ j=1 w(Yj)`(Yj , h(Xj))
We further define a ghost data set {(X ′i, Y ′i )}n1 and the corresponding ghost loss;
L′n(h) = 1
n n∑ j=1 w(Y ′j )`(Y ′ j , h(X ′ j))
Let’s define a random variable Gn := suph∈H Ln(h) − L(h). This random variable is the key to derive the tight generalization bound in Lemma 4.
This random variable has the following properties; E [Gn] = E [
sup h∈H Ln(h)− E [L′n(h)] ] Which we can rewrite as
E [Gn] = E [
sup h∈H
E [ Ln(h)− L′n(h) ∣∣∣{(Xi, Yi)}n1 ]] and swapping the sup with the expectation
E [Gn] ≤ E [ E [
sup h∈H Ln(h)− L′n(h) ∣∣∣{(Xi, Yi)}n1]] We can remove the condition with law of iterated conditional expectation and have expectation on both of the data sets;
E [Gn] ≤ E [
sup h∈H Ln(h)− L′n(h) ] we further open the expression up;
E [Gn] ≤ E [ sup h∈H 1 n n∑ i wi`(h(Xi), Yi)− w′i`′(h(X ′i), Y ′i ) ] In the following we use the usual symmetrizing technique through Rademacher variables {ξi}n1 . Each ξi is a uniform random variable either 1 or −1. Therefore since `(h(X ′), Y ′)− `′(h(X ′), Y ′) is a symmetric random variable we have
E [Gn] ≤ E [ sup h∈H 1 n n∑ i ξi [w(Yi)`(h(Xi), Yi)− w(Y ′i )`′(h(X ′i), Y ′i )] ] where the expectation is also over the Rademacher variables. After propagation sup
E [Gn] ≤ E [ sup h∈H 1 n n∑ i ξiw(Yi)`(h(Xi), Yi) + sup h∈H 1 n n∑ i −ξiw(Y ′i )`′(h(X ′i), Y ′i ) ] By propagating the expectation and again symmetry in the Rademacher variable we have
E [Gn] ≤ 2E [ sup h∈H 1 n n∑ i ξiw(Yi)`(h(Xi), Yi) ] = 2R(G(`,H))
where the right hand side is two times the Rademacher complexity of class G(`,H). Consider a sequence of Doob Martingale and filtration (Uj ,Fj) defined on some probability space (Ω,F , P r);
Uj := E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j1 ] and the corresponding Martingale difference;
Dj := Uj − Uj−1 In the following we show that each |Dj | is bounded above.
Dj =E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j1 ] − E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 ]
≤ max xj ,yj E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 , xj , yj ]
− min xj ,yj E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 , xj , yj ]
Let’s define xmaxj , y max j as the solution to the maximization and x min j , y min j the solution to the minimization, therefore,
Dj ≤ E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 , xmaxj , ymaxj ]
− E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 , xminj , yminj ]
= E [ sup h∈H ( 1 n n∑ i w(Yi)`(h(Xi), Yi) + w(y min j )`(h(x min j ), y min j )− w(yminj )`(h(xminj ), yminj ) )∣∣∣{(xi, yi)}j−11 , xmaxj , ymaxj ]
− E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 , xminj , yminj ]
= E [ sup h∈H ( 1 n n∑ i w(Yi)`(h(Xi), Yi) + w(y max j )`(h(x max j ), y max j )− w(yminj )`(h(xminj ), yminj ) )∣∣∣{(xi, yi)}j−11 , xminj , yminj ]
− E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 , xminj , yminj ]
≤ 1 n sup h∈H ∣∣∣w(ymaxj )`(h(xmaxj ), ymaxj )− w(yminj )`(h(xminj ), yminj )∣∣∣ ≤ d∞(q||p)n The same way we can bound −Dj . Therefore the absolute value each Dj is bounded by d∞(q||p)n . In the following we bound the conditional second moment, E [ D2j |Fj−1 ] ;
E  E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j1 ] ︸ ︷︷ ︸
(a′)
−E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 ] ︸ ︷︷ ︸
(b′)
 2 ∣∣∣{(Xi, Yi)}j−11 
Let’s construct an event Cj the event that a′ is bigger than b′, and also C′j its compliment. Therefore, for the E [ D2j |Fj−1 ] we have
E [( E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j1 ]
− E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 ])2∣∣∣{(Xi, Yi)}j−11 , Cj ] P(Cj |Fj−1)
+ E [( E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j1 ]
− E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 ])2∣∣∣{(Xi, Yi)}j−11 , C ′j ] P(C ′j |Fj−1)
(11)
For the firs term in Eq. 11 after again introducing ghost variables X ′, Y ′ we have the following upper bound
E [( E sup h∈H 1 n n∑ i 6=j w(Yi)`(h(Xi), Yi) + 1 n sup h∈H w(Yj)`(h(Xj), Yj) ∣∣∣{(Xi, Yi)}j1  − E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 ])2∣∣∣{(Xi, Yi)}j−11 , Cj ] P(Cj |Fj−1)
≤ E [( E sup h∈H 1 n n∑ i 6=j w(Yi)`(h(Xi), Yi) + 1 n w(Y ′j )`(h(X ′ j), Y ′ j ) + 1 n sup h∈H w(Yj)`(h(Xj), Yj) ∣∣∣{(Xi, Yi)}j1  − E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 ])2∣∣∣{(Xi, Yi)}j−11 , Cj ] P(Cj |Fj−1)
≤ E [( E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 ] + 1 n sup h∈H w(Yj)`(h(Xj), Yj)
− E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 ])2∣∣∣{(Xi, Yi)}j−11 , Cj ] P(Cj |Fj−1)
≤ E
[( 1
n sup h∈H w(Yj)`(h(Xj), Yj)
)2 ∣∣∣{(Xi, Yi)}j−11 , Cj ] P(Cj |Fj−1)
≤ E
[( 1
n sup h∈H w(Yj)`(h(Xj), Yj)
)2 ∣∣∣{(Xi, Yi)}j−11 ] P(Cj |Fj−1) ≤
d(q||p) n2 P(Cj |Fj−1)
So far we have that the first term in Eq. 11 is bounded by d(q||p)n2 . Now for the second term we have the following upper bound;
E [( E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 ]
− E [ sup h∈H 1 n n∑ i w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j1 ])2∣∣∣{(Xi, Yi)}j−11 , C ′j ] P(C ′j |Fj−1)
≤ E [( E sup h∈H 1 n n∑ i6=j w(Yi)`(h(Xi), Yi) + 1 n sup h∈H w(Yj)`(h(Xj), Yj) ∣∣∣{(Xi, Yi)}j−11  − E sup h∈H 1 n n∑ i 6=j w(Yi)`(h(Xi), Yi) ∣∣∣{(Xi, Yi)}j−11 )2∣∣∣{(Xi, Yi)}j−11 , C ′j ] P(C ′j |Fj−1)
≤ ( E [ 1
n sup h∈H
w(Yj)`(h(Xj), Yj) ∣∣∣{(Xi, Yi)}j−11 ])2
≤ ( E [ 1
n w(Yj) ∣∣∣{(Xi, Yi)}j−11 ])2 = 1n2P(C ′j |Fj−1) Therefore, since d(q||p) ≥ 1
E [ D2j |Fj−1 ] ≤ d(q||p)
n2 P(Cj |Fj−1) +
1
n2 P(C ′j |Fj−1) ≤ d(q||p) n2
For the first inequality, we used the fact that the loss is within [0, 1] and the second one is from Eq. 12. Since the first term in RHS is (b′), therefore, second moment of each Dj |Fj−1 is bounded by 2d(q||p)n .
Therefore for the Doob Martingale sequence of Dj we have |Dj | ≤ d∞(q||p)n as well as∑n j D 2 j |Fj−1 ≤ d(q||p) n . Using the Freedman’s inequality Freedman (1975), we have
P  n∑ j Dj = Gn − E [Gn] ≥ α  ≤ exp(− α2 2(d(q||p)n + α d∞(q||p) n ) )
Moreover, if we multiply each loss with −1, it results in hypothesis class of −H which has the same Rademacher complexity asH, due the symmetric Rademacher random variable. Let G̃n denote the same quantity as G̃n but on −H. We use this slack variable in order to bound the absolute value of Gn. Therefore
P (Gn ≥ E [Gn] + ) ≤ exp ( −
2
2(d(q||p)n + d∞(q||p) n )
)
≤ exp ( −
2
2(d(q||p)n + d∞(q||p) n )
) ≤ δ/2
and the same bound for G̃n. By solving it for and δ we have
|Gn| ≤ 2R(G(`,H)) + 2d∞(q||p) log(2/δ)
n +
√ 2 d(q||p) log(2/δ)
n
Note: A few days prior to the camera ready submission, we realized that a quite similar analysis and statement to Theorem 4 is also studied in Ying (2004).

heading: B.6 GENERALIZATION FOR FINITE HYPOTHESIS CLASSES
text: For finite hypothesis classes, one may bound (b) in (9) using Bernstein’s inequality.
We bound (b) by first noting thatw(Y )`(Y, h(X)) satisfies the Bernstein conditions so that Bernstein’s inequality holds
EP[w(Y )] = 1, EP[w(Y )2] = d(q||p), σ2P(w(Y )) = d(q||p)− 1 (12)
by definition. Because we assume ` ≤ 1, we directly have
EP [ w(Y )2l2(Y, h(X)) ] ≤ EP [ w(Y )2 ] = d(q||p) (13)
Since we have a bound on the second moment of weighted loss while its first moment is L(h) we can apply Bernstein’s inequality to obtain for any fixed h that
|Ln(h)− L(h)| ≤ 2d∞(q||p) log( 2δ )
3n +
√ 2 (d(q||p)− L(h)2) log(2δ )
n
For the uniform law for finite hypothesis classes make the union bound on all the hypotheses;
sup h∈H |Ln(h)− L(h)| ≤ 2d∞(q||p) log( 2|H|δ ) 3n +
√ 2 (d(q||p)) log(2|H|δ )
n
The second moment of the importance weighted loss EP [ ω(Y )2`2(h(X), Y ) ] , given a h ∈ H′ can be bounded for general α ≥ 0, potentially leading to smaller values than d(q||p):
EP [ ω2Y ` 2(Y, h(X)) ]
= k∑ i p(i) q2(i) p2(i) EX∼p(X|Y=i) [ `2(h(X), X) ] =
k∑ i q(i) 1 α q(i) p(i) q(i) α−1 α EX∼p(X|Y=i) [ `2(h(X), i) ]
≤ ( k∑ i q(i) q(i)α p(i)α ) 1 α ( k∑ i q(i)EX∼p(X|Y=i) [ `2(h(X), i) ] 2α α−1 )α−1 α
= ( k∑ i q(i) q(i)α p(i)α ) 1 α ( k∑ i q(i)EX∼p(X|Y=i) [ l2(h(X), i) ] EX∼p(X|Y=i) [ `2(h(X), i) ]α+1 α−1 )α−1 α
≤ ( k∑ i q(i) q(i)α p(i)α ) 1 α k∑ i q(i)EX∼p(X|Y=i) [ `2(h(X), i) ]1− 1α EX∼p(X|Y=i) [`2(h(X), i)]1+ 1α (14)
where the first inequality follows from Hölder’s inequality, the second one follows from Jensen’s inequality and the fact that the loss is in [0, 1] as well as the fact that the exponentiation function is convex in this region. Moreover, since 1 + 1α ≥ 1 and upper bound for the loss square, l(·, ·)
2 ≤ 1, then;
EP [ w(Y )2`2(h(X), Y ) ] ≤ ( k∑ i q(i) q(i)α p(i)α ) 1 α k∑ i q(i)EX∼P|Y=i [ `2(h(X), i) ]1− 1α which gives bound on the second moment of weighted loss.

heading: B.7 SLIGHT DRIFT FROM THE LABEL SHIFT
text: Drift in label shift assumption: If the label shift approximation is slightly violated, we expect the generalizing bound to deviate from the statement in the Theorem. 1. Define de(q||p) := E(X,Y )∼Q [∣∣∣1− p(X|Y )q(X|Y ) ∣∣∣] as the deviation form label shift constraint which is zero in label shift setting.
Remark 1 (Drift in Label shift assumption) If the label shift assumption slightly violates, for the true importance weights ω(x, y) := q(x,y)p(x,y) , the RLLS, with high probability generalizes as;
L(ĥŵ, ω)− L(h∗;ω) ≤ G(np, δ) + (1− λ) ‖θ‖2 + λ θ(np, nq, ‖θ‖2, δ) + 4 (1− λ) de(q||p)
Consider the case where the Label shift assumption is slightly violated, i.e., for each covariate and label, we have p(x|y) ' q(x|y), resulting importance weight ω(x, y) := q(x,y)p(x,y) for each covariate and label. Similar to decomposing in Eq. 9, we have
L(ĥŵ;ω)− L(h?;ω) = L(ĥŵ;ω)− L(ĥŵ)︸ ︷︷ ︸ (c) +L(ĥŵ)− Ln(ĥŵ)︸ ︷︷ ︸ (b) +Ln(ĥŵ)− Ln(ĥŵ; ŵ)︸ ︷︷ ︸ (a)
+ Ln(ĥŵ; ŵ)− Ln(h?; ŵ)︸ ︷︷ ︸ ≤0 +Ln(h?; ŵ)− Ln(h?)︸ ︷︷ ︸ (a) +Ln(h?)− L(h?)︸ ︷︷ ︸ (b) +L(h?)− L(h?;ω)︸ ︷︷ ︸ (c)
(15)
where the desired excess risk is defined with respect to ω. The differences between Eq. 15 and Eq. 9 are in a new term (c) as well as term (a). The term (b) remains untouched.
Bound on term (c) For any h, the two contributing components in (c), i.e., L(h;ω) and L(h) are as follows;
L(h) = E(X,Y )∼P [w(Y )`(Y, h(X))] , and L(h;ω) = E(X,Y )∼Q [`(Y, h(X))] = E(X,Y )∼P [ω(X,Y )`(Y, h(X))]
For their deviation we have
L(h;ω)− L(h) = E(X,Y )∼P [(ω(X,Y )− w(Y )) `(Y, h(X))] = E(X,Y )∼P [( q(X,Y )
p(X,Y ) − q(Y ) p(Y )
) `(Y, h(X)) ] = E(X,Y )∼Q [( 1− p(X|Y )
q(X|Y )
) `(Y, h(X)) ] ≤ de(q||p) := E(X,Y )∼Q [∣∣∣1− p(X|Y ) q(X|Y ) ∣∣∣] Where in the last inequality we deploy Cauchy Schwarz inequality as well as loss is in [0, 1] and hold for h ∈ H. It is worth noting that the expectation in de(q||p) is with respect to Q and does not blow up if the supports of P and Q do not match
Bound on term (a) For any h ∈ H, similar to the derivation in Eq. 10 we have
|Ln(h)− Ln(h; ŵ)| ≤ ‖ŵ − w‖2 ≤ ‖λθ̂ − θ‖2 ≤ (1− λ)‖θ‖2 + λ‖θ̂ − θ‖2 The previous weight estimation analysis does not directly hold for this case where the label shift is slightly violated, but with a few modification we provide an upper-bound on the error. Given a classifier h0
qh0(Y = i) = ∑ j q(h(X) = i|Y = j)q(j)
= ∑ j (q(h0(X) = i|Y = j)− p(h0(X) = i|Y = j)) q(j) + ∑ j p(h0(X) = i|Y = j)q(j)
= ∑ j (q(h0(X) = i|Y = j)− p(h0(X) = i|Y = j)) q(j) + ∑ j p(h0(X) = i, Y = j)wj
= E(X,Y )∼Q [ p(h0(X) = i) ( 1− p(X|Y )
q(X|Y ) )] + ∑ j p(h0(X) = i, Y = j)wj
where p(h0(X) = i) = q(h0(X) = i), resulting;
qh0 = be + Cw
where we drop the h0 in both be and C. Both the confusion matrix C and the label distribution qh0 on the target for the black box hypothesis h0 are unknown and we are instead only given access to finite sample estimates Ĉh0 , q̂h0 . Similar to previous analysis we have
b := q − C1 = Cθ
with corresponding finite sample quantity b̂ = q̂ − Ĉ1. Similarly to the analysis when there was no violation in label shift assumption, we have Υ(θ′) = ‖Cθ′ − b− be‖2 and the solution to Eq. 3 satisfies;
Υ(θ̂) ≤ inf θ′∈Rk {Υ(θ′) + 2∆C‖θ′‖α}+ 2∆b + 2‖be‖2. (16)
We can simplify the upper bound by setting θ′ = θ. We then have Υ(θ̂) = ‖Cθ̂ − b− be‖2 = ‖C ( θ̂ − θ ) ‖2 ≤ 2∆C‖θ‖2 + 2∆b + 2‖be‖2 ≤ 2∆C‖θ‖2 + 2∆b + 2de(q||p)
resulting in
‖θ̂ − θ‖2 ≤ 1
σmin (2∆C‖θ‖2 + 2∆b + 2de(q||p))

Review summaries:
- The authors consider the problem of learning under label shifts, where the label proportions p(y) and q(y) of the training and test distributions differ, while the conditionals p(x|y) and q(x|y) are equal. They build upon the work by Lipton et al. 18 on estimating label proportion weights q(y)/p(y) using the confusion matrix, by proposing an improved estimator with regularization. They show that their estimator provides better weight estimates compared to the unregularized version, and it also gives better prediction accuracies under large label shift scenarios. 

This paper presents a new contribution for a largely understudied problem of label shift (also called target shift), a situation occurring when the class proportions vary between the training and test sets. The proposed contribution builds upon a recent work on the subject by Lipton et al., 2018 and addresses several of its weaknesses. The paper also gives several improved generalisation bounds w.r.t. that of Lipton et al. that are further used as guidelines to tune the regularisation parameter based on the size of source and target samples. Finally, the empirical results show that the proposed algorithm outperforms that of Lipton et al. especially in cases where the shift in proportions becomes quite important.