Why resampling outperforms reweighting for correcting sampling bias with stochastic gradients

1 INTRODUCTION . A data set sampled from a certain population is called biased if the subgroups of the population are sampled at proportions that are significantly different from their underlying population proportions . Applying machine learning algorithms naively to biased training data can raise serious concerns and lead to controversial results ( Sweeney , 2013 ; Kay et al. , 2015 ; Menon et al. , 2020 ) . In many domains such as demographic surveys , fraud detection , identification of rare diseases , and natural disasters prediction , a model trained from biased data tends to favor oversampled subgroups by achieving high accuracy there while sacrificing the performance on undersampled subgroups . Although one can improve by diversifying and balancing during the data collection process , it is often hard or impossible to eliminate the sampling bias due to historical and operational issues . In order to mitigate the biases and discriminations against the undersampled subgroups , a common technique is to preprocess the data set by compensating the mismatch between population proportion and the sampling proportion . Among various approaches , two commonly-used choices are reweighting and resampling . In reweighting , one multiplies each sample with a ratio equal to its population proportion over its sampling proportion . In resampling , on the other hand , one corrects the proportion mismatch by either generating new samples for the undersampled subgroups or selecting a subset of samples for the oversampled subgroups . Both methods result in statistically equivalent models in terms of the loss function ( see details in Section 2 ) . However , it has been observed in practice that resampling often outperforms reweighting significantly , such as boosting algorithms in classification ( Galar et al. , 2011 ; Seiffert et al. , 2008 ) , off-policy prediction in reinforcement learning ( Schlegel et al. , 2019 ) and so on . The obvious question is why . Main contributions . Our main contribution is to provide an answer to this question : resampling outperforms reweighting because of the stochastic gradient-type algorithms used for training . To the best of our knowledge , our explanation is the first theoretical quantitative analysis for this phenomenon . With stochastic gradient descent ( SGD ) being the dominant method for model training , our analysis is based on some recent developments for understanding SGD . We show via simple and explicitly analyzable examples why resampling generates expected results while reweighting performs undesirably . Our theoretical analysis is based on two points of view , one from the dynamical stability perspective and the other from stochastic asymptotics . In addition to the theoretical analysis , we present experimental examples from three distinct categories ( classification , regression , and off-policy prediction ) to demonstrate that resampling outperforms reweighting in practice . This empirical study illustrates that this is a quite general phenomenon when models are trained using stochastic gradient type algorithms . Our theoretical analysis and experiments show clearly that adjusting only the loss functions is not sufficient for fixing the biased data problem . The output can be disastrous if one overlooks the optimization algorithm used in the training . In fact , recent understanding has shown that objective function design and optimization algorithm are closely related , for example optimization algorithms such as SGD play a key role in the generalizability of deep neural networks . Therefore in order to address the biased data issue , we advocate for considering data , model , and optimization as an integrated system . Related work . In a broader scope , resampling and reweighting can be considered as instances of preprocessing the training data to tackle biases of machine learning algorithms . Though there are many well-developed resampling ( Mani & Zhang , 2003 ; He & Garcia , 2009 ; Maciejewski & Stefanowski , 2011 ) and reweighting ( Kumar et al. , 2010 ; Malisiewicz et al. , 2011 ; Chang et al. , 2017 ) techniques , we only focus on the reweighting approaches that do not change the optimization problem . It has been well-known that training algorithms using disparate data can lead to algorithmic discrimination ( Bolukbasi et al. , 2016 ; Caliskan et al. , 2017 ) , and over the years there have been growing efforts to mitigate such biases , for example see ( Amini et al. , 2019 ; Kamiran & Calders , 2012 ; Calmon et al. , 2017 ; Zhao et al. , 2019 ; López et al. , 2013 ) . We also refer to ( Guo et al. , 2017 ; He & Ma , 2013 ; Krawczyk , 2016 ) for a comprehensive review of this growing research field . Our approaches for understanding the dynamics of resampling and reweighting under SGD are based on tools from numerical analysis for stochastic systems . Connections between numerical analysis and stochastic algorithms have been rapidly developing in recent years . The dynamical stability perspective has been used in ( Wu et al. , 2018 ) to show the impact of learning rate and batch size in minima selection . The stochastic differential equations ( SDE ) approach for approximating stochastic optimization methods can be traced in the line of work ( Li et al. , 2017 ; 2019 ; Rotskoff & VandenEijnden , 2018 ; Shi et al. , 2019 ) , just to mention a few . 2 PROBLEM SETUP . Let us consider a population that is comprised of two different groups , where a proportion a1 of the population belongs to the first group , and the rest with the proportion a2 = 1 − a1 belongs to the second ( i.e. , a1 , a2 > 0 and a1 + a2 = 1 ) . In what follows , we shall call a1 and a2 the population proportions . Consider an optimization problem for this population over a parameter θ . For simplicity , we assume that each individual from the first group experiences a loss function V1 ( θ ) , while each individual from the second group has a loss function of type V2 ( θ ) . Here the loss function V1 ( θ ) is assumed to be identical across all members of the first group and the same for V2 ( θ ) across the second group , however it is possible to extend the formulation to allow for loss function variation within each group . Based on this setup , a minimization problem over the whole population is to find θ∗ = arg min θ V ( θ ) , where V ( θ ) ≡ a1V1 ( θ ) + a2V2 ( θ ) . ( 1 ) For a given set Ω of N individuals sampled uniformly from the population , the empirical minimization problem is θ∗ = arg min θ 1 N ∑ r∈Ω Vir ( θ ) , ( 2 ) where ir ∈ { 1 , 2 } denotes which group an individual r belongs to . When N grows , the empirical loss in ( 2 ) is consistent with the population loss in ( 1 ) as there are approximately a1 fraction of samples from the first group and a2 fraction of samples from the second . However , the sampling can be far from uniformly random in reality . Let n1 and n2 with n1+n2 = N denote the number of samples from the first and the second group , respectively . It is convenient to define fi , i = 1 , 2 as the sampling proportions for each group , i.e. , f1 = n1/N and f2 = n2/N with f1 + f2 = 1 . The data set is biased when the sampling proportions f1 and f2 are different from the population proportions a1 and a2 . In such a case , the empirical loss is f1V1 ( θ ) + f2V2 ( θ ) , which is clearly wrong when compared with ( 1 ) . Let us consider two basic strategies to adjust the model : reweighting and resampling . In reweighting , one assigns to each sample r ∈ Ω a weight air/fir and the reweighting loss function is Vw ( θ ) ≡ 1 N ∑ r∈Ω air fir Vir ( θ ) = a1V1 ( θ ) + a2V2 ( θ ) . ( 3 ) In resampling , one either adds samples to the minority group ( i.e. , oversampling ) or removing samples from the majority group ( i.e. , undersampling ) . Although the actual implementation of oversampling and undersampling could be quite sophisticated in order to avoid overfitting or loss of information , mathematically we interpret the resampling as constructing a new set of samples of size M , among which a1M samples are of the first group and a2M samples of the second . The resampling loss function is Vs ( θ ) ≡ 1 M ∑ s Vis ( θ ) = a1V1 ( θ ) + a2V2 ( θ ) . ( 4 ) Notice that both Vw ( θ ) and Vs ( θ ) are consistent with the population loss function V ( θ ) . This means that , under mild conditions on V1 ( θ ) and V2 ( θ ) , a deterministic gradient descent algorithm from a generic initial condition converges to similar solutions for Vw ( θ ) and Vs ( θ ) . For a stochastic gradient descent algorithm , the expectations of the stochastic gradients of Vw ( θ ) and Vs ( θ ) also agree at any θ value . However , as we shall explain below , the training behavior can be drastically different for a stochastic gradient algorithm . The key reason is that the variances experienced for Vw ( θ ) and Vs ( θ ) can be drastically different : computing the variances of gradients for resampling and reweighting reveals that V [ ∇V̂s ( θ ) ] = a1∇V1 ( θ ) ∇V1 ( θ ) T + a2∇V2 ( θ ) ∇V2 ( θ ) T − ( E [ ∇V̂s ( θ ) ] ) 2 , V [ ∇V̂w ( θ ) ] = a21 f1 ∇V1 ( θ ) ∇V1 ( θ ) T + a22 f2 ∇V2 ( θ ) ∇V2 ( θ ) T − ( E [ ∇V̂w ( θ ) ] ) 2 . ( 5 ) These formulas indicate that , when f1/f2 is significantly misaligned with a1/a2 , the variance of reweighting can be much larger . Without knowing the optimal learning rates a priori , it is difficult to select an efficient learning rate for reliable and stable performance for stiff problems , when only reweighting is used . In comparison , resampling is more favorable especially when the choice of learning rates is restrictive . 3 STABILITY ANALYSIS . Let us use a simple example to illustrate why resampling outperforms reweighting under SGD , from the viewpoint of stability . Consider two loss functions V1 and V2 with disjoint supports , V1 ( θ ) = { 1 2 ( θ + 1 ) 2 − 12 , θ ≤ 0 0 , θ > 0 , V2 ( θ ) = { 0 , θ ≤ 0 1 2 ( θ − 1 ) 2 − 12 , θ > 0 , ( 6 ) each of which is quadratic on its support . The population loss function is V ( θ ) = a1V1 ( θ ) +a2V2 ( θ ) , with two local minima at θ = −1 and θ = 1 . The gradients for V1 and V2 are ∇V1 ( θ ) = { θ + 1 , θ ≤ 0 0 , θ > 0. , ∇V2 ( θ ) = { 0 , θ ≤ 0 θ − 1 , θ > 0 . Suppose that the population proportions satisfy a2 > a1 , then θ = 1 is the global minimizer and it is desired that SGD should be stable near it . However , as shown in Figure 1 , when the sampling proportion f2 is significantly less than the population proportion a2 , for reweighting θ = 1 can easily become unstable : even if one starts near the global minimizer θ = 1 , the trajectories for reweighting always gear towards θ = −1 after a few steps ( see Figure 1 ( 1 ) ) . On the other hand , for resampling θ = 1 is quite stable ( see Figure 1 ( 2 ) ) . The expectations of the stochastic gradient are the same for both methods . It is the difference in the second moment that explains why trajectories near the two minima exhibit different behaviors . Our explanation is based on the stability analysis framework used in ( Wu et al. , 2018 ) . By definition , a stationary point θ∗ is stochastically stable if there exists a uniform constant 0 < C ≤ 1 such that E [ ‖θk − θ∗‖2 ] ≤ C‖θ0 − θ∗‖2 , where θk is the k-th iterate of SGD . The stability conditions for resampling and reweighting are stated in the following two lemmas , in which we use η to denote the learning rate . Lemma 1 . For resampling , the conditions for the SGD to be stochastically stable around θ = −1 and θ = 1 are respectively ( 1− ηa1 ) 2 + η2a1a2 ≤ 1 , ( 1− ηa2 ) 2 + η2a1a2 ≤ 1 . Lemma 2 . For reweighting , the condition for the SGD to be stochastically stable around θ = −1 and θ = 1 are respectively ( 1− ηa1 ) 2 + η2f1f2 ( a1 f1 ) 2 ≤ 1 , ( 1− ηa2 ) 2 + η2f1f2 ( a2 f2 ) 2 ≤ 1 . Note that the stability conditions for resampling are independent of the sampling proportions ( f1 , f2 ) , while the ones for reweighting clearly depend on ( f1 , f2 ) . We defer the detailed computations to Appendix A. Lemma 2 shows that reweighting can incur a more stringent stability criterion . Let us consider the case a1 = 12 − , a2 = 1 2 + with a small constant > 0 and f2/f1 1 . For reweighting , the global minimum θ = 1 is stochastically stable only if η ( 1 + f1/f2 ) ≤ 4 + O ( ) . This condition becomes rather stringent in terms of the learning rate η since f1/f2 1 . On the other hand , the local minimizer θ = −1 is stable if η ( 1 + f2/f1 ) ≤ 4 +O ( ) , which could be satisfied for a broader range of η because f2/f1 1 . In other words , for a fixed learning rate η , when the ratio f2/f1 between the sampling proportions is sufficiently small , the desired minimizer θ = 1 is no longer statistically stable with respect to SGD .

Summary: This paper provides an analysis of why resampling can be better than reweighting in some cases. By observing the behaviour of resampling and reweighting in simple optimizations with SGD, the theoretical results show that resampling tends to be more stable. The general analysis is based on SDE approximation. Experiments on classification and off-policy evaluation show that resampling can be better in some cases.