Synthetic Over-sampling

Fraud Detection in R

Sebastiaan Höppner

PhD researcher in Data Science at KU Leuven

Over-sampling with 'SMOTE'

  • SMOTE : Synthetic Minority Oversampling TEchnique (Chawla et al., 2002)
  • Over-sample minority class (= fraud) by creating synthetic minority cases
Fraud Detection in R
dim(transfer_data)
1000    4
head(transfer_data)
  isFraud    amount   balance     ratio
1   false  528.6840 1529.4732 0.3456641
2   false  184.0193  836.3509 0.2200265
3   false 1885.8024 2984.0684 0.6319568
4   false  732.0286 1248.7217 0.5862224
prop.table(table(transfer_data$isFraud))
 false  true
  0.99  0.01
Fraud Detection in R

smote_scatterplot_1

Fraud Detection in R

smote_scatterplot_2

Fraud Detection in R

SMOTE

Let's select a fraud case X (Tim)

smote_zoomin

Fraud Detection in R

SMOTE - step 1

Step 1

Find K nearest fraudulent neighbors of X (Tim)

e.g. K = 4

smote_step1

Fraud Detection in R

SMOTE - step 2

Step 2

Randomly choose one of Tim's nearest neighbors

e.g. X4 (Bart)

smote_step2

Fraud Detection in R

SMOTE - step 3

Step 3 : create synthetic sample

synthetic_case_1

Fraud Detection in R

SMOTE - step 3

Step 3 : create synthetic sample

synthetic_case_2

Fraud Detection in R

SMOTE - step 3

Step 3 : create synthetic sample

synthetic_case_3

Fraud Detection in R

SMOTE - step 3

smote_step3

Fraud Detection in R

SMOTE - step 4

Step 4

Repeat steps 1-3 for each fraud case dup_size times

e.g. dup_size = 10

smote_step3

Fraud Detection in R
library(smotefamily)
smote_output = SMOTE(X = transfer_data[, -1],
                       target = transfer_data$isFraud,
                       K = 4,
                       dup_size = 10)

oversampled_data = smote_output$data
table(oversampled_data$isFraud)
false  true
  990   110
prop.table(table(oversampled_data$isFraud))
false  true
  0.9   0.1
Fraud Detection in R

smote_result

Fraud Detection in R

Let's practice!

Fraud Detection in R

Preparing Video For Download...