Undersampling is a Minimax Optimal Robustness Intervention in Nonparametric Classiﬁcation
Anonymous Author(s)
AfﬁliationAddress email
Abstract
While a broad range of techniques have been proposed to tackle distribution shift,the simple baseline of training on an undersampled dataset often achieves closeto state-of-the-art-accuracy across several popular benchmarks.
This is rathersurprising, since undersampling algorithms discard excess majority group data.
Tounderstand this phenomenon, we ask if learning is fundamentally constrained by alack of minority group samples.
We prove that this is indeed the case in the settingof nonparametric binary classiﬁcation.
Our results show that in the worst case,an algorithm cannot outperform undersampling unless there is a high degree ofoverlap between the train and test distributions (which is unlikely to be the casein real-world datasets), or if the algorithm leverages additional structure aboutthe distribution shift.
In particular, in the case of label shift we show that there isalways an undersampling algorithm that is minimax optimal.
While in the caseof group-covariate shift we show that there is an undersampling algorithm that isminimax optimal when the overlap between the group distributions is small.
Wealso perform an experimental case study on a label shift dataset and ﬁnd that in linewith our theory the test accuracy of robust neural network classiﬁers is constrainedby the number of minority samples.
Introduction
A key challenge facing the machine learning community is to design models that are robust todistribution shift.
When there is a mismatch between the train and test distributions, current modelsare often brittle and perform poorly on rare examples [11, 2, 20, 10, 1].
In this paper, our focus is ongroup-structured distribution shifts.
In the training set, we have many samples from a majority groupand relatively few samples from the minority group, while during test time we are equally likely toget a sample from either group.
To tackle such distribution shifts, a naïve algorithm is one that ﬁrst undersamples the training data bydiscarding excess majority group samples [14, 23] and then trains a model on this resulting dataset (see
Figure 1 for an illustration of this algorithm).
The samples that remain in this undersampled datasetconstitute i.i.d. draws from the test distribution.
Therefore, while a classiﬁer trained on this pruneddataset cannot suffer biases due to distribution shift, this algorithm is clearly wasteful, as it discardstraining samples.
[Figure]
This perceived inefﬁciency of undersampling has led to the design of several algorithms to combatsuch distribution shift [6, 15, 18, 5, 17, 29, 13, 24].
In spite of this algorithmic progress, the simplebaseline of training models on an undersampled dataset remains competitive.
In the case of labelshift, where one class label is overrepresented in the training data, this has been observed by Cui et al.[7], Cao et al.
[5], and Yang and Xu [28].
While in the case of group-covariate shift, a study by Idrissiet al.
[12] showed that the empirical effectiveness of these more complicated algorithms is limited.
For example, Idrissi et al.
[12] showed that on the group-covariate shift CelebA dataset the worstgroup accuracy of a ResNet-50 model on the undersampled CelebA dataset which discards 97% of theavailable training data is as good as methods that use all of available data such as importance-weighted
ERM [19], Group-DRO [18] and Just-Train-Twice [16].
In Table 1, we report the performance ofthe undersampled classiﬁer compared to the state-of-the-art-methods in the literature across severallabel shift and group-covariate shift datasets.
We ﬁnd that, although undersampling isn’t alwaysthe optimal robustness algorithm, it is typically a very competitive baseline and within 1 – 4% theperformance of the best method.
When reporting worst-group accuracy we denote it by a (cid:63) .
When available, we report the 95% conﬁdence interval.
We ﬁnd that the undersampled classiﬁer is always within 1 – 4% of the best performing robustness algorithm, except on the MultiNLI dataset.
[Table]
Inspired by the strong performance of undersampling in these experiments, we ask:
Is the performance of a model under distribution shift fundamentally constrained by the lack of minority group samples?
To answer this question we analyze the minimax excess risk .
We lower bound the minimax excess riskto prove that the performance of any algorithm is lower bounded only as a function of the minority samples ( n min ).
This shows that even if a robust algorithm optimally trades off between the bias andthe variance, it is fundamentally constrained by the variance on the minority group which decreasesonly with n min .
For our study, we consider the well-studied setting of nonparametric binary classiﬁcation [21].
Byoperating in this nonparametric regime we are able to study the properties of undersampling in richdata distributions, but are able to circumvent the complications that arise due to the optimizationand implicit bias of parametric models.
We explore two distribution shift scenarios: label shift andgroup-covariate shift.
Under label shift, one of the labels is overrepresented in the training data,
P train ( y = 1) ≥ P train ( y = − 1) , whereas the test samples are equally likely to come from eitherclass.
Here the class-conditional distribution P ( x | y ) is Lipschitz in x .
Under group-covariate shift,we have two groups { a, b } and in the training data we have more samples from the distribution P
a ( x )than from P b ( x ) .
Whereas during test time, it is equiprobable to receive samples from either group.
In this case, the distribution P ( y | x ) is Lipschitz in x .
Our Contributions.
We show that in the label shift setting there is a fundamental constraint, andthat the minimax excess risk of any robust learning method is lower bounded by 1 /n min 1 / 3 .
That is,minority group samples fundamentally constrain performance under distribution shift.
Furthermore,by leveraging previous results about nonparametric density estimation [9] we show a matching upperbound on the excess risk of a standard binning estimator trained on an undersampled dataset todemonstrate that undersampling is optimal.
In the case of group-covariate shift, we show that when the overlap (deﬁned in terms of total variationdistance) between the group distribution P a and P b is small, a similar result holds and the minimaxexcess risk of any robust learning algorithm is lower bounded by 1 /n min 1 / 3 .
We show that this lowerbound is tight, by proving an upper bound on the excess risk of the binning estimator acting on theundersampled dataset.
Finally, we experimentally show in a label shift dataset (Imbalanced Binary CIFAR10) that theaccuracy of popular classiﬁers generally follow the trends predicted by our theory.
When the minoritysamples are increased, the accuracy of these classiﬁers increases drastically, whereas when the numberof majority samples are increased the gains in the accuracy are marginal at best.
Taken together, our results underline the need to move beyond designing “general-purpose” robustnessalgorithms (like importance-weighting [5, 17, 13, 24], g-DRO [18], JTT [16], SMOTE [6], etc.)that are agnostic to the structure in the distribution shift.
Our worst case analysis highlights that tosuccessfully beat undersampling, an algorithm must leverage additional structure in the distributionshift.
Related Work
On several group-covariate shift benchmarks (CelebA, CivilComments, Waterbirds), Idrissi et al.
[12]showed that training ResNet classiﬁers on an undersampled dataset either outperforms or performsas well as other popular reweighting methods like Group-DRO [18], reweighted ERM, and JustTrain-Twice [16].
They ﬁnd Group-DRO performs comparably to undersampling, while both tend tooutperform methods that don’t utilize group information.
One classic method to tackle distribution shift is importance weighting [19], which reweights the lossof the minority group samples to yield an unbiased estimate of the loss.
However, recent work [3, 27]has demonstrated the ineffectiveness of such methods when applied to overparameterized neuralnetworks.
Many followup papers [5, 29, 17, 13, 24] have introduced methods that modify the lossfunction in various ways to address this.
However, despite this progress undersampling remains acompetitive alternative to these importance weighted classiﬁers.
Our theory draws from the rich literature on non-parametric classiﬁcation [21].
Apart from borrowingthis setting of nonparametric classiﬁcation, we also utilize upper bounds on the estimation error ofthe simple histogram estimator [9, 8] to prove our upper bounds in the label shift case.
Finally, wenote that to prove our minimax lower bounds we proceed by using the general recipe of reducingfrom estimation to testing [22, Chapter 15].
One difference from this standard framework is that ourtraining samples shall be drawn from a different distribution than the test samples used to deﬁne therisk.
Setting
In this section, we shall introduce our problem setup and deﬁne the types of distribution shift that weconsider.
3.1 Problem Setup
The setting for our study is nonparametric binary classiﬁcation with Lipschitz data distributions.
We are given n training datapoints S :
= { ( x 1 , y 1 ) , . . .
, ( x n , y n ) } ∈ ([0 , 1] × {− 1 , 1 } ) n that are alldrawn from a train distribution P train .
During test time, the data shall be drawn from a differentdistribution P test .
To present a clean analysis, we study the case where the features x are boundedscalars, however, it is easy to extend our results to the high-dimensional setting.
Given a classiﬁer f : R → {− 1 , 1 } , we shall be interested in the test error (risk) of this classiﬁerunder the test distribution P test :
[Equation]
3.2 Types of Distribution Shift
We assume that P train consists of a mixture of two groups of unequal size, and P test contains equalnumbers of samples from both groups.
Given a majority group distribution P maj and a minority groupdistribution P min , the learner has access to n maj majority group samples and n min minority groupsamples:
[Equation]
Here n maj > n/ 2 and n min < n/ 2 with n maj + n min = n .
The full training dataset is S =
S maj ∪ S min = { ( x 1 , y 1 ) , . . .
, ( x n , y n ) } .
We assume that the learner has access to the knowledge 119 whether a particular sample ( x i , y i ) comes from the majority or minority group.
The test samples will be drawn from P test = 12 P maj + 12 P min , a uniform mixture over P maj and P min .
Thus, the training dataset is an imbalanced draw from the distributions P maj and P min , whereas thetest samples are balanced draws.
We let ρ := n maj /n min > 1 denote the imbalance ratio in thetraining data.
We focus on two-types of distribution shifts: label shift and group-covariate shift that we describebelow.
3.2.1 Label Shift
In this setting, the imbalance in the training data comes from there being more samples from one class over another.
Without loss of generality, we shall assume that the class y = 1 is the majority class.
Then, we deﬁne the majority and the minority class distributions as
[Equation]
where P 1 , P − 1 are class-conditional distributions over the interval [0 , 1] .
We assume that classconditional distributions P i have densities on [0 , 1] and that they are 1-Lipschitz: for any x, x (cid:48) ∈ [0 , 1] ,
[Equation]
We denote the class of pairs of distributions ( P maj , P min ) that satisfy these conditions by P LS .
3.2.2 Group-Covariate Shift
In this setting, we have two groups { a, b } , and corresponding to each of these groups is a distribution (with densities) over the features P a ( x ) and P b ( x ) .
We let a correspond to the majority group and b correspond to the minority group.
Then, we deﬁne
P maj ( x, y ) =
P a ( x ) P ( y | x ) and P min ( x, y ) =
P b ( x ) P ( y | x ) .
We assume that for y ∈ {− 1 , 1 } , for all x, x (cid:48) ∈ [0 , 1] :
[Equation]
that is, the distribution of the label given the feature is 1 -Lipschitz, and it varies slowly over thedomain.
To quantify the shift between the train and test distribution, we deﬁne a notion of overlap between thegroup distributions P a and P b as follows:
[Equation]
Notice that when P a and P b have disjoint supports, TV( P a , P b ) = 1 and therefore Overlap ( P a , P b ) =0 .
On the other hand when P a = P b , TV( P a , P b ) = 0 and Overlap ( P a , P b )
= 1 .
When the overlapis 1 , the majority and minority distributions are identical and hence we have no shift between trainand test.
Observe that Overlap ( P a , P b ) =
Overlap ( P maj , P min ) since P ( y | x ) is shared across P majand P min .
Given a level of overlap τ ∈ [0 , 1] we denote the class of pairs of distributions ( P maj , P min ) withoverlap at least τ by P GS ( τ ) .
It is easy to check that, P GS ( τ ) ⊆
P GS (0) at any overlap level τ ∈ [0 , 1] .
Lower Bounds on the Minimax Excess Risk
In this section, we shall prove our lower bounds that show that the performance of any algorithm isconstrained by the number of minority samples n min .
Before we state our lower bounds, we need tointroduce the notion of excess risk and minimax excess risk.
Excess Risk and Minimax Excess Risk.
We measure the performance of an algorithm A throughits excess risk deﬁned in the following way.
Given an algorithm A that takes as input a dataset Sand returns a classiﬁer A S , and a pair of distributions ( P maj , P min ) with P test = 12 P maj + 12 P min , the 150 expected excess risk is given by
[Equation]
where f (cid:63) ( P test ) is the Bayes classiﬁer that minimizes the risk R ( · ; P test ) .
The ﬁrst term correspondsto the expected risk for the algorithm when given n maj samples from P maj and n min samples from 153 P min , whereas the second term corresponds to the Bayes error for the problem.
Excess risk does not let us characterize the inherent difﬁculty of a problem, since for any particulardata distribution ( P maj , P min ) the best possible algorithm A to minimize the excess risk would be thetrivial mapping A S
= f (cid:63) ( P test ) .
Therefore, to prove meaningful lower bounds on the performanceof algorithms we need to deﬁne the notion of minimax excess risk [see 22, Chapter 15].
Given a classof pairs of distributions P deﬁne
[Equation]
where the inﬁmum is over all measurable estimators A .
The minimax excess risk is the excess risk ofthe “best” algorithm in the worst case over the class of problems deﬁned by P .
4.1 Label Shift Lower Bounds
We demonstrate the hardness of the label shift problem in general by establishing a lower boundon the minimax excess risk.
Below we let c > 0 be an absolute constant independent of problemparameters like n maj and n min .
Theorem 4.1.
Consider the label shift setting described in Section 3.2.1.
Recall that P LS is the classof pairs of distributions ( P maj , P min ) that satisfy the assumptions in that section.
The minimax excessrisk over this class is lower bounded as follows:
[Equation]
We establish this result in Appendix B.
We show that rather surprisingly, the lower bound on the minimax excess risk scales only with thenumber of minority class samples n min 1 / 3 , and does not depend on n maj .
Intuitively, this is because any learner must predict which class-conditional distribution ( P ( x | 1) or P ( x | − 1) ) assigns higherlikelihood at that x .
To interpret this result, consider the extreme scenario where n maj → ∞ but n minis ﬁnite.
In this case, the learner has full information about the majority class distribution.
However,the learning task continues to be challenging since any learner would be uncertain about whetherthe minority class distribution assigns higher or lower likelihood at any given x .
This uncertaintyunderlies the reason why the minimax rate of classiﬁcation is constrained by the number of minoritysamples n min .
We also note that the theorem can be trivially extended to higher dimensions.
In this case theexponents degrade to 1 / 3 d rather than 1 / 3 as is to be expected in nonparametric classiﬁcation.
4.2 Group-Covariate Shift Lower Bounds
Next, we shall state our lower bound on the minimax excess risk that demonstrates the hardness of thegroup-covariate shift problem.
In the theorem below c > 0 shall be an absolute constant independentof n maj , n min and τ .
Theorem 4.2.
Consider the group shift setting described in Section 3.2.2.
Given any overlapτ ∈ [0 , 1] recall that P GS ( τ ) is the class of distributions such that Overlap ( P maj , P min ) ≥ τ .
The 186 minimax excess risk in this setting is lower bounded as follows:
[Equation]
where ρ = n maj /n min > 1 .
We prove this theorem in Appendix C.
We see that in the low overlap setting ( τ (cid:28) 1 /ρ ) , the minimax excess risk is lower bounded by1 /n
min 1 / 3 , and we are fundamentally constrained by the number of samples in minority group.
Tosee why this is the case, consider the extreme example with τ = 0 where P a has support [0 , 0 .
5]and P b has support [0 . 5 , 1] .
The n maj majority group samples from P a provide information aboutthe correct label predict in the interval [0 , 0 .
5] (the support of P a ).
However, since the distribution
P ( y | x ) is 1 -Lipschitz in the worst case these samples provide very limited information about thecorrect predictions in [0 . 5 , 1] (the support of P b ).
Thus, predicting on the support of P b requiressamples from the minority group and this results in the n min dependent rate.
In fact, in this extremecase ( τ = 0) even if n maj → ∞ , the minimax excess risk is still bounded away from zero.
Thisintuition also carries over to the case when the overlap is small but non-zero and our lower boundshows that minority samples are much more valuable than majority samples at reducing the risk.
On the other hand, when the overlap is high ( τ (cid:29) 1 /ρ )
the minimax excess risk is lower boundedby 1 / ( n min (2 − τ ) + n maj τ ) 1 / 3 and the extra majority samples are quite beneﬁcial.
This is roughlybecause the supports of P a and P b have large overlap and hence samples from the majority groupare useful in helping make predictions even in regions where P b is large.
In the extreme case whenτ = 1 , we have that P a = P b and therefore recover the classic i.i.d.
setting with no distribution shift.
Here, the lower bound scales with 1 /n 1 / 3 , as one might expect.
Identical to the label shift case, the theorem can be extended to hold in higher dimensions with theexponents being 1 / 3 d rather than 1 / 3 .
Upper Bounds on the Excess Risk for the Undersampled BinningEstimator
We will show that an undersampled estimator matches the rates in the previous section showingthat undersampling is an optimal robustness intervention.
We start by deﬁning the undersamplingprocedure and the undersampling binning estimator.
Undersampling Procedure.
Given training data S :
= { ( x 1 , y 1 ) , . . .
, ( x n , y n ) } , generate a newundersampled dataset S US by
• including all n min samples from S min and,
• including n min samples from S maj by sampling uniformly at random without replacement.
This procedure ensures that in the undersampled dataset S US , the groups are balanced, and that|S US | = 2 n min .
The undersampling binning estimator deﬁned next will ﬁrst run this undersampling procedure toobtain S US and just uses these samples to output a classiﬁer.
Undersampled Binning Estimator
The undersampled binning estimator A USB takes as input adataset S and a positive integer K corresponding to the number of bins, and returns a classiﬁer
A
S ,K USB : [0 , 1] → {− 1 , 1 } .
This estimator is deﬁned as follows:1.
First, we compute the undersampled dataset S US .2.
Given this dataset S US , let n 1 ,j be the number of points with label +1 that lie in the interval
I j =
[ j − 1 K , jK ] .
Also, deﬁne n − 1 ,j analogously.
Then set
[Equation]
otherwise.
3. Deﬁne the classiﬁer A S ,K USB such that if x ∈ I j then
[Equation]
Essentially in each bin I j , we set the prediction to be the majority label among the samplesthat fall in this bin.
Whenever the number of bins K is clear from the context we shall denote A S ,K USB by A S USB .
Below weestablish upper bounds on the excess risk of this simple estimator.
5.1 Label Shift Upper Bounds
We now establish an upper bound on the excess risk of A USB in the label shift setting (see Section 3.2.1).
Below we let c, C > 0 be absolute constants independent of problem parameters liken maj and n min .
Theorem 5.1.
Consider the label shift setting described in Section 3.2.1.
For any ( P maj , P min ) ∈ P LSthe expected excess risk of the Undersampling Binning Estimator (Eq.
(5) ) with number of bins with
K = c (cid:100) n min 1 / 3 (cid:101) is upper bounded by
Excess
[Equation]
We prove this result in Appendix B.
This upper bound combined with the lower bound in Theorem 4.1shows that an undersampling approach is minimax optimal up to constants in the presence of labelshift.
We note that our analysis leaves open the possibility of better algorithms when the learner hasadditional information about the structure of the label shift beyond Lipschitz continuity.
5.2 Group-Covariate Shift Upper Bounds
Next, we present our upper bounds on the excess risk of the undersampled binning estimator in thegroup-covariate shift setting (see Section 3.2.2).
In the theorem below, C > 0 is an absolute constantindependent of the problem parameters n maj , n min and τ .
Theorem 5.2.
Consider the group shift setting described in Section 3.2.2.
For any overlap τ ∈ [0 , 1]and for any ( P maj , P min )
∈ P GS ( τ ) the expected excess risk of the Undersampling Binning Estimator(Eq.
(5) ) with number of bins with K = (cid:100)
n min 1 / 3 (cid:101) is
Excess Risk [ A USB ;
[Equation]
P
[Equation]
, P
[Equation] [Equation]
C
[Equation]
We provide a proof for this theorem in Appendix C. Compared to the lower bound established in
Theorem 4.2 which scales as 1 / ((2 − τ ) n min + n maj τ ) 1 / 3 , the upper bound for the undersampledbinning estimator always scales with 1 /n min 1 / 3 since it operates on the undersampled dataset ( S US ).
Thus, we have shown that in the absence of overlap ( τ (cid:28) 1 /ρ = n min /n maj ) there is an undersampling algorithm that is minimax optimal up to constants.
However when there is high overlap( τ (cid:29) 1 /ρ ) there is a non-trivial gap between the upper and lower bounds:
[Figure]
=
c
[Figure]
Minority Sample Dependence in Practice
[Figure]
We start off with 2500 cat examples and 500 dog examples in the training dataset.
We ﬁnd that in accordance with our theory, for both of the classiﬁers adding only minority class samples (red) leads to large gain in accuracy ( ∼ 6% ), while adding majority class samples (blue) leads to little or no gain.
In fact, adding majority samples sometimes hurts test accuracy due to the added bias.
When we add majority and minority samples in a 5:1 ratio (green), the gain is largely due to the addition of minority samples and is only marginally higher ( < 2% ) than adding only minority samples.
The green curves correspond to the same classiﬁers in both the left and right panels.
Inspired by our worst-case theoretical predictions in nonparametric classiﬁcation, we ask: how doesthe accuracy of neural network classiﬁers trained using robust algorithms evolve as a function of themajority and minority samples?
To explore this question, we conduct a small case study using the imbalanced binary CIFAR10dataset [3, 24] that is constructed using the “cat” and “dog” classes.
The test set consists of allof the 1000 cat and 1000 dog test examples.
To form our initial train and validation sets, we take2500 cat examples but only 500 dog examples from the ofﬁcial train set, corresponding to a 5:1 label imbalance.
We then use 80% of those examples for training and the rest for validation.
In ourexperiment, we either ( a ) add only minority samples; ( b ) add only majority samples; ( c ) add bothmajority and minority samples in a 5:1 ratio.
We consider competitive robust classiﬁers proposedin the literature that are convolutional neural networks trained either by using ( i ) the importanceweighted cross entropy loss, or ( ii ) the importance weighted VS loss [13].
We early stop using theimportance weighted validation loss in both cases.
The additional experimental details are presentedin Appendix D.
Our results in Figure 2 are generally consistent with our theoretical predictions.
By adding onlyminority class samples the test accuracy of both classiﬁers increases by a great extent (6%), while byadding only majority class samples the test accuracy remains constant or in some cases even decreasesowing to the added bias of the classiﬁers.
When we add samples to both groups proportionately, theincrease in the test accuracy appears to largely to be due to the increase in the number of minorityclass samples and on the left panels, we see that the difference between adding only extra minoritygroup samples (red) and both minority and majority group samples (green) is small.
Thus, we ﬁndthat the accuracy for these neural network classiﬁers is also constrained by the number of minorityclass samples.
Discussion
We showed that undersampling is an optimal robustness intervention in nonparametric classiﬁcationin the absence of signiﬁcant overlap between group distributions or without additional structurebeyond Lipschitz continuity.
At a high level our results highlight the need to reason about the speciﬁc structure in the distributionshift and design algorithms that are tailored to take advantage of this structure.
This would requireus to step away from the common practice in robust machine learning where the focus is to design“universal” robustness interventions that are agnostic to the structure in the shift.
Alongside this,our results also dictate the need for datasets and benchmarks with the propensity for transfer fromtraining time to test time.
Checklist
For all authors...
(a) Do the main claims made in the abstract and introduction accurately reﬂect the paper’s
contributions and scope?
[Yes]
(b) Did you describe the limitations of your work?
[Yes]
(c) Did you discuss any potential negative societal impacts of your work?
[Yes]
(d) Have you read the ethics review guidelines and ensured that your paper conforms to
them?
[Yes]
If you are including theoretical results...
(a) Did you state the full set of assumptions of all theoretical results?
[Yes]
(b) Did you include complete proofs of all theoretical results?
[Yes]
If you ran experiments...
(a) Did you include the code, data, and instructions needed to reproduce the main experi-
mental results (either in the supplemental material or as a URL)?
[Yes]
(b) Did you specify all the training details (e
g., data splits, hyperparameters, how they were chosen)?
[Yes]
(c) Did you report error bars (e
g., with respect to the random seed after running experiments multiple times)?
[Yes]
(d) Did you include the total amount of compute and the type of resources used (e g., type
of GPUs, internal cluster, or cloud provider)?
[Yes]
If you are using existing assets (e g., code, data, models) or curating/releasing new assets...
(a) If your work uses existing assets, did you cite the creators?
[Yes]
(b) Did you mention the license of the assets?
[N/A]
(c) Did you include any new assets either in the supplemental material or as a URL?
[N/A]
(d) Did you discuss whether and how consent was obtained from people whose data you’re
using/curating?
[N/A]
(e) Did you discuss whether the data you are using/curating contains personally identiﬁable information or offensive content?
[N/A]
If you used crowdsourcing or conducted research with human subjects...
(a) Did you include the full text of instructions given to participants and screenshots, if
applicable?
[N/A]
(b) Did you describe any potential participant risks, with links to Institutional Review
Board (IRB) approvals, if applicable?
[N/A]
(c) Did you include the estimated
[Table]
[Table]