when is undersampling effective in unbalanced ... · 0.0530.298 0.749 0.451 88.8 0.0760.303 0.682...

1
When is undersampling effective in unbalanced classification tasks? Andrea Dal Pozzolo 1 , Olivier Caelen 2 , Gianluca Bontempi 1,3 1 Machine Learning Group, Computer Science Department, Université Libre de Bruxelles, Brussels, Belgium 2 Fraud Risk Management Analytics, Worldline, Brussels, Belgium 3 Interuniversity Institute of Bioinformatics in Brussels (IB) 2 , Brussels, Belgium Introduction A Dataset is unbalanced when the class of interest (minority class) is much smaller or rarer than normal behaviour (majority class), e.g. in fraud detection we want to classify trans- actions as fraud or genuine, but fraud class is rare. Classification algorithms in general suffer when the data is skewed towards one class. A standard solution is undersampling, i.e. removing observations from the majority class until the datasets is balanced. Warping effect on the posterior probability Let p be the posterior probability of a classifier to predict an instance as belonging to the minority class. After undersampling we get p s and we can write: p s = p p + β(1 - p) (1) where β is the probability of selecting a majority instance. 3 15 0 500 1000 1500 -10 0 10 20 -10 0 10 20 x Count class 0 1 Figure 1: p s as a function of β (left) and class distribution (right). Posterior probability ranking Let us denote by ^ p (resp. ^ p s ) the estimation of p (resp. p s ). Assume we have two distinct test points with p 1 <p 2 where Δp = p 2 - p 1 >0. Let ^ p 1 = p 1 + 1 and ^ p 2 = p 2 + 2 , with ε N(b, ν) where b and ν are the bias and the variance of the estimator of p. By making an hypothesis of normality we have a wrong ranking if ^ p 1 > ^ p 2 with probability: P (^ p 2 < ^ p 1 )= P (p 2 + 2 <p 1 + 1 )= P ( 1 - 2 > Δp)= 1 - Φ Δp (2) where 2 - 1 N(0, 2ν) and Φ is the cumulative function of the normal distribution. Let ^ p s,1 = p s,1 + η 1 and ^ p s,2 = p s,2 + η 2 , where η N(b s s ), ν s and Δp s = p s,2 - p s,1 . P (^ p s,2 < ^ p s,1 )= P (η 1 - η 2 > Δp s )= 1 - Φ Δp s s (3) A classifier trained after undersampling has better ranking w.r.t. a classifier learned with unbalanced distribution when P (^ p 2 < ^ p 1 ) >P (^ p s,2 < ^ p s,1 ), using (2) and (3): 1 - Φ Δp >1 - Φ Δp s s Φ Δp Δp s s Δp < Δp s s since Φ is monotone non decreasing and we can assume that ν s . Then it follows that undersampling is useful (better ranking) when dp s dp = β (p + β(1 - p)) 2 > ν s ν (4) where dp s dp is the derivative of p s w.r.t. p. Experimental Results Synthetic data 2 1 0 1 2 0.0 0.2 0.4 0.6 0.8 1.0 1.2 x Posterior probability Figure 2: Left: dp s dp (solid lines), ν s ν (dotted lines). Right: class conditional distributions (thin lines) and the posterior distribution of the minority class (thicker line). 0 5 10 15 20 0 5 10 15 X1 X2 class 0 1 Figure 3: Left: ν s ν (black) and different percentiles of dp s dp . Right: Class distribution. Table 1: Ranking correlation between the posterior probability ^ p ( ^ p s ) and p for different values of β. The value K (K s ) denotes the Kendall rank correlation without (with) un- dersampling. The first (last) five lines refer to samples for which the condition (4) is (not) satisfied. β K K s K s - K %points satisfying (4) 0.053 0.298 0.749 0.451 88.8 0.076 0.303 0.682 0.379 89.7 0.112 0.315 0.619 0.304 91.2 0.176 0.323 0.555 0.232 92.1 0.323 0.341 0.467 0.126 93.7 0.053 0.749 0.776 0.027 88.8 0.076 0.755 0.773 0.018 89.7 0.112 0.762 0.764 0.001 91.2 0.176 0.767 0.761 -0.007 92.1 0.323 0.768 0.748 -0.020 93.7 Real data Figure 4: Difference between the Kendall rank correlation of ^ p s and ^ p with p, namely K s and K, for points having the conditions (4) satisfied and not on selected datasets from the UCI repository. K s and K are calculated as the mean of the correlations over all βs. Summary and conclusions Undersampling has two major effects: i) it increases the variance of the classifier and ii) it produces warped posterior probabilities. Countermeasures: i) averaging strategies (e.g. Bagging) and calibration of the probability to the new priors of the testing set [2]. When (4) is satisfied the posterior probability obtained after sampling returns a more ac- curate ordering. Practical use (4) requires knowledge of p and ν s ν (not easy to estimate). Also (4) may not hold for all testing points and depends on β. This result warns against a naive use of undersampling in unbalanced tasks and suggest the adoption of adaptive selection techniques (e.g. racing [1]). Research is funded by the Doctiris programme of Innoviris (Brussels capital region). References [1] Andrea Dal Pozzolo, Olivier Caelen, Serge Waterschoot, and Gianluca Bontempi. Racing for unbalanced methods selection. In Proceedings of the 14th International Conference on Intelligent Data Engineering and Automated Learning. IDEAL, 2013. [2] Marco Saerens, Patrice Latinne, and Christine Decaestecker. Adjusting the outputs of a classifier to new a priori probabilities: a simple procedure. Neural computation, 14(1):21–41, 2002. ECML-PKDD, 7 - 11 September 2015, Porto, Portugal

Upload: dinhkien

Post on 05-Sep-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: When is undersampling effective in unbalanced ... · 0.0530.298 0.749 0.451 88.8 0.0760.303 0.682 0.379 89.7 ... Andrea Dal Pozzolo, Olivier Caelen, Gianluca Bontempi Created Date:

When is undersampling effective inunbalanced classification tasks?

Andrea Dal Pozzolo1, Olivier Caelen2, Gianluca Bontempi1,31Machine Learning Group, Computer Science Department, Université Libre de Bruxelles, Brussels, Belgium

2Fraud Risk Management Analytics, Worldline, Brussels, Belgium3Interuniversity Institute of Bioinformatics in Brussels (IB)2, Brussels, Belgium

IntroductionA Dataset is unbalanced when the class of interest (minority class) is much smaller or rarerthan normal behaviour (majority class), e.g. in fraud detection we want to classify trans-actions as fraud or genuine, but fraud class is rare. Classification algorithms in generalsuffer when the data is skewed towards one class. A standard solution is undersampling,i.e. removing observations from the majority class until the datasets is balanced.

Warping effect on the posterior probabilityLet p be the posterior probability of a classifier to predict an instance as belonging to theminority class. After undersampling we get ps and we can write:

ps =p

p+ β(1− p)(1)

where β is the probability of selecting a majority instance.

3 15

0

500

1000

1500

−10 0 10 20 −10 0 10 20x

Cou

nt class01

Figure 1: ps as a function of β (left) and class distribution (right).

Posterior probability rankingLet us denote by p̂ (resp. p̂s) the estimation of p (resp. ps). Assume we have two distincttest points with p1 < p2 where ∆p = p2−p1 > 0. Let p̂1 = p1+ ε1 and p̂2 = p2+ ε2,with ε ∼ N(b, ν) where b and ν are the bias and the variance of the estimator of p. Bymaking an hypothesis of normality we have a wrong ranking if p̂1 > p̂2 with probability:

P(p̂2 < p̂1) = P(p2 + ε2 < p1 + ε1) = P(ε1 − ε2 > ∆p) = 1−Φ

∆p√2ν

(2)

where ε2−ε1 ∼ N(0, 2ν) andΦ is the cumulative function of the normal distribution. Letp̂s,1 = ps,1+η1 and p̂s,2 = ps,2+η2, where η ∼ N(bs, νs), νs > ν and ∆ps = ps,2−ps,1.

P(p̂s,2 < p̂s,1) = P(η1 − η2 > ∆ps) = 1−Φ

∆ps√2νs

(3)

A classifier trained after undersampling has better ranking w.r.t. a classifier learned withunbalanced distribution when P(p̂2 < p̂1) > P(p̂s,2 < p̂s,1), using (2) and (3):

1−Φ

∆p√2ν

> 1−Φ∆ps√2νs

⇔ Φ

∆p√2ν

< Φ∆ps√2νs

⇔ ∆p√2ν<∆ps√2νs

since Φ is monotone non decreasing and we can assume that νs > ν.Then it follows that undersampling is useful (better ranking) when

dps

dp=

β

(p+ β(1− p))2>

√√√√√√√√√νs

ν(4)

where dpsdp

is the derivative of ps w.r.t. p.

Experimental Results

Synthetic data

−2 −1 0 1 2

0.0

0.2

0.4

0.6

0.8

1.0

1.2

x

Post

erio

r pro

babi

lity

Figure 2: Left: dpsdp

(solid lines),√√√√νsν(dotted lines). Right: class conditional distributions

(thin lines) and the posterior distribution of the minority class (thicker line).

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

● ●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●● ●

●●

●●

●●

●●

● ●

● ●

● ●

●●

●●

● ●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

●●

●●

● ●

0

5

10

15

20

0 5 10 15

X1

X2

class

0

1

Figure 3: Left:√√√√νsν(black) and different percentiles of dps

dp. Right: Class distribution.

Table 1: Ranking correlation between the posterior probability p̂ (p̂s) and p for differentvalues of β. The value K (Ks) denotes the Kendall rank correlation without (with) un-dersampling. The first (last) five lines refer to samples for which the condition (4) is (not)satisfied.

β K Ks Ks − K %points satisfying (4)0.053 0.298 0.749 0.451 88.80.076 0.303 0.682 0.379 89.70.112 0.315 0.619 0.304 91.20.176 0.323 0.555 0.232 92.10.323 0.341 0.467 0.126 93.70.053 0.749 0.776 0.027 88.80.076 0.755 0.773 0.018 89.70.112 0.762 0.764 0.001 91.20.176 0.767 0.761 -0.007 92.10.323 0.768 0.748 -0.020 93.7

Real data

Figure 4: Difference between the Kendall rank correlation of p̂s and p̂ with p, namely Ks

and K, for points having the conditions (4) satisfied and not on selected datasets fromthe UCI repository. Ks and K are calculated as the mean of the correlations over all βs.

Summary and conclusions

Undersampling has two major effects: i) it increases the variance of the classifier and ii)it produces warped posterior probabilities. Countermeasures: i) averaging strategies (e.g.Bagging) and calibration of the probability to the new priors of the testing set [2].When (4) is satisfied the posterior probability obtained after sampling returns a more ac-curate ordering. Practical use (4) requires knowledge of p and νs

ν(not easy to estimate).

Also (4) may not hold for all testing points and depends on β. This result warns againsta naive use of undersampling in unbalanced tasks and suggest the adoption of adaptiveselection techniques (e.g. racing [1]).

Research is funded by the Doctiris programme of Innoviris (Brussels capital region).

References[1] Andrea Dal Pozzolo, Olivier Caelen, Serge Waterschoot, and Gianluca Bontempi.

Racing for unbalanced methods selection.In Proceedings of the 14th International Conference on Intelligent Data Engineering and AutomatedLearning. IDEAL, 2013.

[2] Marco Saerens, Patrice Latinne, and Christine Decaestecker.Adjusting the outputs of a classifier to new a priori probabilities: a simple procedure.Neural computation, 14(1):21–41, 2002.

ECML-PKDD, 7 - 11 September 2015, Porto, Portugal