Regularized Learning for Domain Adaptation under Label Shifts

Kamyar Azizzadenesheli, Anqi Liu, Fanny Yang, Animashree Anandkumar

Introduction

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.

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 yy typically have a much lower dimension than the inputs xx. 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)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 klog⁡(k)k\log(k), where kk is the number of classes, i.e. the cardinality of Y\mathcal{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.

Regularized learning of label shifts (RLLS)

The following simple correlation between the label distributions p,qp,q was noted in Lipton et al. (2018): for a fixed hypothesis hh, if for all y∈Yy\in\mathcal{Y} it holds that q(y)≥0  ⟹  p(y)≥0q(y)\geq 0\implies p(y)\geq 0, we have

for all i,j∈Yi,j\in\mathcal{Y}. This can equivalently be written in matrix vector notation as

In reality, both qhq_{h} and ChC_{h} can only be estimated by the corresponding finite sample averages q^h,C^h\widehat{q}_{h},\widehat{C}_{h}. Lipton et al. (2018) simply compute the inverse of the estimated confusion matrix C^h\widehat{C}_{h} in order to estimate the importance weight, i.e. w^=C^h−1q^h\widehat{w}=\widehat{C}_{h}^{-1}\widehat{q}_{h}. While Ch−1q^hC_{h}^{-1}\widehat{q}_{h} is a statistically efficient estimator, w^\widehat{w} with estimated C^h−1\widehat{C}_{h}^{-1} can be arbitrarily bad since C^h−1\widehat{C}_{h}^{-1} 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 kk which is problematic for large kk.

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=1w=\textbf{1} so that we define the amount of weight shift as θ=w−1\theta=w-\textbf{1}. Given a “decent” black box estimator which we denote by h0h_{0}, we make the final classifier less sensitive to the estimation performance of CC (i.e. regularize the weight estimate) by

calculating the measurement error adjusted θ^\widehat{\theta} (described in Section 2.1 for h0h_{0}) and

computing the regularized weight w^=1+λθ^\widehat{w}=\textbf{1}+\lambda\widehat{\theta} where λ\lambda depends on the sample size (1−β)np(1-\beta)n_{p}.

By "decent" we refer to a classifier h0h_{0} which yields a full rank confusion matrix Ch0C_{h_{0}}. A trivial example for a non-”decent” classifier h0h_{0} 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.

1 Estimator correcting for finite sample errors

Here, ΔC\Delta_{C} is a parameter which will eventually be high probability upper bounds for ∥C^−C∥2\|\widehat{C}-C\|_{2}. Let Δb\Delta_{b} also denote the high probability upper bounds for ∥b^−b∥2\|\widehat{b}-b\|_{2}.

For θ^\widehat{\theta} as defined in equation (3), we have with probability at least 1−δ1-\delta thatThroughout the paper, O\mathcal{O} hides universal constant factors. Furthermore, we use O(⋅+⋅)\mathcal{O}\left(\cdot+\cdot\right) for short to denote O(⋅)+O(⋅)\mathcal{O}\left(\cdot\right)+\mathcal{O}\left(\cdot\right).

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 σmin⁡−2\sigma_{\min}^{-2} 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−δ1-\delta, it is necessary that 3knp−10+2knq−10≤δ3kn_{p}^{-10}+2kn_{q}^{-10}\leq\delta. As a consequence, the upper bound in Theorem 3 of Lipton et al. (2018) is bigger than \frac{1}{3\sigma_{\min}}\big{(}\|\theta\|_{2}\sqrt{\frac{\log(3k/\delta)}{n_{p}}}+\sqrt{\frac{k\log(2k/\delta)}{n_{q}}}\big{)}. Thus Lemma 1 improves upon the previous upper bound by a factor of kk.

Furthermore, as in Lipton et al. (2018), this result holds for any black box estimator h0h_{0} which enters the bound via σmin⁡(Ch0)\sigma_{\min}(C_{h_{0}}). We can directly see how a good choice of h0h_{0} helps to decrease the upper bound in Lemma 1. In particular, if h0h_{0} is an ideal estimator, and the source set is balanced, CC is the unit matrix with σmin⁡=1/k\sigma_{\min}=1/k. In contrast, when the model h0h_{0} is uncertain, the singular value σmin⁡\sigma_{\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 θ\theta, where using the squared norm may shrink the estimate θ^\widehat{\theta} too much and away from the true θ\theta.

2 Regularized estimator and generalization bound

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

Note that w^\widehat{w} implicitly depends on λ\lambda, and β\beta. By rewriting w^=(1−λ)1+λ(1+θ^)\widehat{w}=(1-\lambda)\textbf{1}+\lambda(\textbf{1}+\widehat{\theta}), we see that intuitively λ\lambda closer to 11 the more reason there is to believe that 1+θ^\textbf{1}+\widehat{\theta} is in fact the true weight.

with ξi, ∀i\xi_{i},~{}\forall i as the Rademacher random variables (see e.g. Bartlett & Mendelson (2002)). We can now state a generalization bound for the classifier h^w^\widehat{h}_{\widehat{w}} in a general hypothesis class H\mathcal{H}, which is trained on source data with the estimated weights defined in equation (4).

The bound (5) in Theorem 1 holds for all choices of λ\lambda. In order to exploit the possibility of choosing λ\lambda and β\beta to have an improved accuracy depending on the sample sizes, we first let the user define a set of shifts θ\theta against which we want to be robust against, i.e. all shifts with ∥θ∥2≤θmax⁡\|\theta\|_{2}\leq\theta_{\max}. For these shifts, we obtain the following upper bound

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\lambda^{\star}=1 whenever nq≥1θmax⁡2(σmin⁡−1np)2n_{q}\geq\frac{1}{\theta_{\max}^{2}(\sigma_{\min}-\frac{1}{\sqrt{n_{p}}})^{2}} (hereby neglecting the log factors and thus dependencies on kk) and else. When using this rule, we obtain L(h^w^)−L(h∗)≤ϵG(np,δ)+min⁡{θmax⁡,ϵθ(np,nq,θmax⁡,δ)}\mathcal{L}(\widehat{h}_{\widehat{w}})-\mathcal{L}(h^{*})\leq\epsilon_{\mathcal{G}}(n_{p},\delta)+\min\{\theta_{\max},\epsilon_{\theta}(n_{p},n_{q},\theta_{\max},\delta)\} which is smaller than the unregularized bound for small nq,npn_{q},n_{p}. Notice that in practice, we do not know σmin⁡\sigma_{\min} in advance so that in Algorithm 1 we need to use an estimate of σmin⁡\sigma_{\min}, which could e.g. be the minimum eigenvalue of the empirical confusion matrix C^\widehat{C} with an additional computational complexity of at most O(k3)O(k^{3}).

Figure 1 shows how the oracle thresholds vary with nqn_{q} and σmin⁡\sigma_{\min} when npn_{p} is kept fix. When the parameters are above the curves for fixed npn_{p}, λ\lambda should be chosen as 11 otherwise the samples should be unweighted, i.e. λ=0\lambda=0. This figure illustrates that when the confusion matrix has small singular values, the estimated weights should only be trusted for rather high nqn_{q} and high believed shifts θmax⁡\theta_{\max}. Although the overall statistical rate of the excess risk of the classifier does not change as a function of the sample sizes, θmax⁡\theta_{\max} could be significantly smaller than ϵθ\epsilon_{\theta} when σmin⁡\sigma_{\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 presence of de(q∣∣p)d_{e}(q||p) deviation from label shift assumption, the true importance weights ω(x,y):=q(x,y)p(x,y)\omega(x,y):=\frac{q(x,y)}{p(x,y)}, the RLLS generalizes as;

with high probability. Proof in Appendix B.7.

EXPERIMENTS

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.1p>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 mm to have probability p<0.1p<0.1, while the distribution over the rest of the classes is uniform. For the Dirichlet shift, we draw a probability vector pp from the Dirichlet distribution with concentration parameter set to α\alpha for all classes, before including sample points which correspond to the multinomial label variable according to pp. 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 h0h_{0} 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, h0h_{0} is trained using uniform data.

In order to compute ω^=1+θ^\widehat{\omega}=\textbf{1}+\widehat{\theta} in Eq. (3), we call a built-in solver to directly solve the low dimensional problem min⁡θ∥C^θ−b^∥2+ΔC∥θ∥2\min_{\theta}\|\widehat{C}\theta-\widehat{b}\|_{2}+\Delta_{C}\|\theta\|_{2} where we empirically observer that 0.010.01 times of the true ΔC\Delta_{C} yields in a better estimator on various levels of label shift pre-computed beforehand. It is worth noting that 0.0010.001 makes the theoretical bound in Lemma. 1 O(1/0.01)\mathcal{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 ω^\widehat{\omega}, where we use a two-layer fully connected neural network for MNIST and a ResNet-18 (He et al., 2016) for CIFAR10.

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 1000010000 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\rho>0.5. We use a fixed black-box classifier that is trained on biased source data, with tweak-one ρ=0.5\rho=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.

2 Weight estimation and predictive performance for target shift

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]\alpha=[0.01,0.1,1,10]. The number of data points in both source and target set is 1000010000.

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)2(\text{precision}\cdot\text{recall})/(\text{precision}+\text{recall}) over all classes. For a class ii, precision is the percentage of correct predictions among all samples predicted to have label ii, while recall is the proportion of correctly predicted labels over the number of samples with true label ii. 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\alpha=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.

3 Regularized weights in the low sample regime for source shift

In the following, we present the average accuracy of RLLS in Figure 4 as a function of the number of target samples nqn_{q} for different values of λ\lambda for small nqn_{q}. Here we fix the sample size in the source set to np=1000n_{p}=1000 and investigate a Minority-Class source shift with fixed p=0.01p=0.01 and five minority classes.

A motivation to use intermediate λ\lambda is discussed in Section 2.2, as λ\lambda in equation (4) may be chosen according to θmax⁡,σmin⁡\theta_{\max},\sigma_{\min}. In practice, since θmax⁡\theta_{\max} is just an upper bound on the true amount of shift ∥θ∥2\|\theta\|_{2}, in some cases λ\lambda should in fact ideally be when 1θmax⁡2(σmin⁡−1nq)2≤nq≤1∥θ∥2(σmin⁡−1nq)2\frac{1}{\theta_{\max}^{2}(\sigma_{\min}-\frac{1}{\sqrt{n_{q}}})^{2}}\leq n_{q}\leq\frac{1}{\|\theta\|_{2}(\sigma_{\min}-\frac{1}{\sqrt{n_{q}}})^{2}}. Thus for target sample sizes nqn_{q} that are a little bit above the threshold (depending on the certainty of the belief how close to θmax⁡\theta_{\max} the norm of the shift is believed to be), it could be sensible to use an intermediate value λ∈(0,1)\lambda\in(0,1).

Figure 4 suggests that unweighted samples (red) yield the best classifier for very few samples nqn_{q}, while for 10≤nq≤50010\leq n_{q}\leq 500 an intermediate λ∈(0,1)\lambda\in(0,1) (purple) has the highest accuracy and for nq>1000n_{q}>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 h0h_{0} 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\lambda=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\sigma_{\text{min}} and target sample size nqn_{q} 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.

Related Work

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 YY causes the input XX (that is, XX is not a causal parent of YY, hence "anti-causal") and the causal mechanism that generates XX from YY is independent of the distribution of YY. A long line of work has addressed the reverse causal setting where XX causes YY and the conditional distribution of YY given XX is assumed to be constant. This assumption is sensible when there is reason to believe that there is a true optimal mapping from XX to YY which does not change if the distribution of XX 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)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)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(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)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 yy 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.

Discussion

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)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.

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 xx’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 xx to yy, 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.

Acknowledgement

K. Azizzadenesheli is supported in part by NSF Career Award CCF-1254106 and Air Force FA9550-15-1-0221. 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.

References

Appendix A More experimental results

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.

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. ii and set p(i)=ρp(i)=\rho 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 ρ\rho and α\alpha. Note that larger shifts correspond to smaller α\alpha and larger ρ\rho. 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.

A.1 MNIST Experiments under Minority-Class source shifts for different values of p𝑝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.01p=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\rho=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 10001000 training and testing data. We created large shifts of three or more minority classes with p=0.005p=0.005. We use a fixed black-box classifier that is trained on biased source data, with tweak-one ρ=0.5\rho=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.

A.2 CIFAR10 Experiment under Dirichlet source shifts

Figure 9 illustrates the weight estimation alongside final classification performance for Dirichlet source shift of CIFAR10 dataset. We use 1000010000 training and testing data in this experiment, following the way we generate shift on source data. We train h0h_{0} with tweak-one shifted source data with ρ=0.5\rho=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.

A.3 MNIST Experiment under Dirichlet Shift with low target sample size

We show the performance of classifier with different regularization λ\lambda under a Dirichlet shift with α=0.5\alpha=0.5 in Figure 10. The training has 5000 examples in this case. We can see that in this low target sample case, λ=1\lambda=1 only take over after several hundreds example, while some λ\lambda 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\rho=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\lambda=1 to take over for a more corrupted black-box classifier.

Appendix B Proofs

From Thm. 3.4 in (Pires & Szepesvári, 2012) we know that for θ^\widehat{\theta} as defined in equation (3), if with probability at least 1−δ1-\delta, ∥C^−C∥2≤ΔC\|\widehat{C}-C\|_{2}\leq\Delta_{C} and ∥b^−b∥2≤Δb\|\widehat{b}-b\|_{2}\leq\Delta_{b} hold simultaneously, then

where we use the shorthand Υ(θ′)=∥Cθ′−b∥2\Upsilon(\theta^{\prime})=\|C\theta^{\prime}-b\|_{2}.

We can get an upper bound on the right hand side of (7) is the infimum by simply choosing a feasible θ′=θ\theta^{\prime}=\theta. We then have ∥Cθ−b∥2=0\|C\theta-b\|_{2}=0 and hence

Since ∥C(θ^−θ)∥2≥σmin⁡(C)∥θ^−θ∥2\|C\left(\widehat{\theta}-\theta\right)\|_{2}\geq\sigma_{\min}(C)\|\widehat{\theta}-\theta\|_{2} by definition of the minimum singular value, we thus have

The mathematical definition of the finite sample estimates C^h,b^h\widehat{C}_{h},\widehat{b}_{h} (in matrix and vector representation) with respect to some hypothesis hh are as follows

For finite sample estimate C^\widehat{C} we have

For the finite sample estimate b^\widehat{b} with respect to any hypothesis hh it holds that

By Lemma. 2 for concentration of CC and Lemma. 3 for concentration of bb we now have with probability at least 1−δ1-\delta

which, considering that O(1n)O(\frac{1}{\sqrt{n}}) dominates O(1n)O(\frac{1}{n}), yields the statement of the Lemma 1.

B.2 Proof of Lemma 2

B.3 Proof of Lemma 3

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).

We now bound both estimates of probability vectors separately.

Consider a fixed multinomial distribution characterized with probability vector of ς‾∈Δk−1\overline{\varsigma}\in\Delta_{k-1} where Δk−1\Delta_{k-1} is a k−1k-1 dimensional simplex. Further, consider tt realization of this multinomial distribution {ς(i)}i=1t\{\varsigma(i)\}_{i=1}^{t} where ς(i)\varsigma(i) is the one-hot-encoding of the ii’th sample. Consider the empirical estimate mean of this distribution through empirical average of the samples; ς^=1t∑(i)tς(i)\widehat{\varsigma}=\frac{1}{t}\sum(i)^{t}\varsigma(i), then

By plugging in ς‾=qh\overline{\varsigma}=q_{h}, ς^=q^h\widehat{\varsigma}=\widehat{q}_{h} with t=nqt=n_{q} and finally {ς(i)}i=1nq={eh(x(i))}(i)nq\{\varsigma(i)\}_{i=1}^{n_{q}}=\{e_{h(x(i))}\}(i)^{n_{q}} and equivalently for php_{h} we obtain;

with probability at least 1−2δ1-2\delta, therefore;

resulting in the statement in the Lemma 3.

B.4 Proof of Theorem 1

We want to ultimately bound ∣L(h^w^)−L(h⋆)∣|\mathcal{L}(\widehat{h}_{\widehat{w}})-\mathcal{L}(h^{\star})|. By addition and subtraction we have

where n=βnpn=\beta n_{p} and we used optimality of h^w^\widehat{h}_{\widehat{w}}. Here (a) is the weight estimation error and (b) is the finite sample error.

of the hypothesis class H\mathcal{H} (see for example Percy Liang notes on Statistical Learning Theory and chapter 4 in Wainwright (2019))

Plugging both bounds back into equation (B.4) concludes the proof of the theorem.

B.5 Proof of Lemma 4

With a bit abuse of notation let’s restate the empirical loss with known importance weights instead on the random variables {(Xi,Yi)}1n\{\left(X_{i},Y_{i}\right)\}_{1}^{n}

We further define a ghost data set {(Xi′,Yi′)}1n\{\left(X_{i}^{\prime},Y_{i}^{\prime}\right)\}_{1}^{n} and the corresponding ghost loss;

Let’s define a random variable Gn:=sup⁡h∈HLn(h)−L(h)G_{n}:=\sup_{h\in\mathcal{H}}\mathcal{L}_{n}(h)-\mathcal{L}(h). This random variable is the key to derive the tight generalization bound in Lemma 4.

This random variable has the following properties;

and swapping the sup⁡\sup with the expectation

We can remove the condition with law of iterated conditional expectation and have expectation on both of the data sets;

where the expectation is also over the Rademacher variables. After propagation sup⁡\sup

By propagating the expectation and again symmetry in the Rademacher variable we have

and the corresponding Martingale difference;

In the following we show that each ∣Dj∣|D_{j}| is bounded above.

Let’s define xjmax⁡,yjmax⁡x_{j}^{\max},y_{j}^{\max} as the solution to the maximization and xjmin⁡,yjmin⁡x_{j}^{\min},y_{j}^{\min} the solution to the minimization, therefore,

For the firs term in Eq. B.5 after again introducing ghost variables X′,Y′X^{\prime},Y^{\prime} we have the following upper bound

So far we have that the first term in Eq. B.5 is bounded by d(q∣∣p)n2\frac{d(q||p)}{n^{2}}. Now for the second term we have the following upper bound;

For the first inequality, we used the fact that the loss is within $andthesecondoneisfromEq.14.SincethefirstterminRHSisand the second one is from Eq. 14. Since the first term in RHS is(b^{\prime}),therefore,secondmomentofeach, therefore, second moment of eachD_{j}|\mathcal{F}_{j-1}isboundedbyis bounded by\frac{2d(q||p)}{n}$.

Therefore for the Doob Martingale sequence of DjD_{j} we have ∣Dj∣≤d∞(q∣∣p)n|D_{j}|\leq\frac{d_{\infty}(q||p)}{n} as well as ∑jnDj2∣Fj−1≤d(q∣∣p)n\sum_{j}^{n}D_{j}^{2}|\mathcal{F}_{j-1}\leq\frac{d(q||p)}{n}. Using the Freedman’s inequality Freedman (1975), we have

Moreover, if we multiply each loss with −1-1, it results in hypothesis class of −H-\mathcal{H} which has the same Rademacher complexity as H\mathcal{H}, due the symmetric Rademacher random variable. Let G~n\widetilde{G}_{n} denote the same quantity as G~n\widetilde{G}_{n} but on −H-\mathcal{H}. We use this slack variable in order to bound the absolute value of GnG_{n}. Therefore

and the same bound for G~n\widetilde{G}_{n}. By solving it for ϵ\epsilon and δ\delta we have

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).

B.6 Generalization for finite hypothesis classes

For finite hypothesis classes, one may bound (b) in (B.4) using Bernstein’s inequality.

Since we have a bound on the second moment of weighted loss while its first moment is L(h)L(h) we can apply Bernstein’s inequality to obtain for any fixed hh that

For the uniform law for finite hypothesis classes make the union bound on all the hypotheses;

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 $aswellasthefactthattheexponentiationfunctionisconvexinthisregion.Moreover,sinceas well as the fact that the exponentiation function is convex in this region. Moreover, since1+\frac{1}{\alpha}\geq 1andupperboundforthelosssquare,and upper bound for the loss square,l(\cdot,\cdot)^{2}\leq 1$, then;

which gives bound on the second moment of weighted loss.

B.7 Slight drift from the Label Shift

If the label shift approximation is slightly violated, we expect the generalizing bound to deviate from the statement in the Theorem. 1. Define

as the deviation form label shift constraint which is zero in label shift setting.

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)p(x|y)\simeq q(x|y), resulting importance weight ω(x,y):=q(x,y)p(x,y)\omega(x,y):=\frac{q(x,y)}{p(x,y)} for each covariate and label. Similar to decomposing in Eq. B.4, we have

where the desired excess risk is defined with respect to ω\omega. The differences between Eq. B.7 and Eq. B.4 are in a new term (c)(c) as well as term (a)(a). The term (b)(b) remains untouched.

For any hh, the two contributing components in (c)(c), i.e., L(h;ω)\mathcal{L}(h;\omega) and L(h)\mathcal{L}(h) are as follows;

For any h∈Hh\in\mathcal{H}, similar to the derivation in Eq. B.4 we have

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 h0h_{0}

where p(h0(X)=i)=q(h0(X)=i)p(h_{0}(X)=i)=q(h_{0}(X)=i), resulting;

where we drop the h0h_{0} in both beb_{e} and CC. Both the confusion matrix CC and the label distribution qh0q_{h_{0}} on the target for the black box hypothesis h0h_{0} are unknown and we are instead only given access to finite sample estimates C^h0,q^h0\widehat{C}_{h_{0}},\widehat{q}_{h_{0}}. Similar to previous analysis we have

with corresponding finite sample quantity b^=q^−C^1\widehat{b}=\widehat{q}-\widehat{C}\textbf{1}. Similarly to the analysis when there was no violation in label shift assumption, we have Υ(θ′)=∥Cθ′−b−be∥2\Upsilon(\theta^{\prime})=\|C\theta^{\prime}-b-b_{e}\|_{2} and the solution to Eq. 3 satisfies;

We can simplify the upper bound by setting θ′=θ\theta^{\prime}=\theta. We then have