随机欠采样

R 中的欺诈检测

Bart Baesens

Professor Data Science at KU Leuven

随机欠采样(RUS)

类别柱状图(欠采样)

R 中的欺诈检测

原始数据:训练/测试

R 中的欺诈检测

随机欠采样示意(v0)

R 中的欺诈检测

随机欠采样示意(v1)

R 中的欺诈检测

V2 对 V1(不平衡)信用卡数据

R 中的欺诈检测
table(creditcard$Class)
    0     1 
24108   492
n_fraud <- 492
new_frac_fraud <- 0.50
new_n_total <- n_fraud / new_frac_fraud ## = 492 / 0.50 = 984

library(ROSE) undersampling_result <- ovun.sample(formula = Class ~ ., data = creditcard, method = "under", N = new_n_total, seed = 2018)
undersampled_credit <- undersampling_result$data
prop.table(table(undersampled_credit$Class))
  0   1 
0.5 0.5
R 中的欺诈检测

V2 对 V1(欠采样)信用卡数据

R 中的欺诈检测

两者一起用!

两种类别柱状图

R 中的欺诈检测
n_new <- nrow(creditcard) ## = 24600
fraction_fraud_new <- 0.50

sampling_result <- ovun.sample(formula = Class ~ ., data = creditcard, method = "both", N = n_new, p = fraction_fraud_new, seed = 2018) sampled_credit <- sampling_result$data
prop.table(table(sampled_credit$Class))
        0         1 
0.5039837 0.4960163
R 中的欺诈检测

V2 对 V1(组合采样)信用卡数据

R 中的欺诈检测

让我们练习吧!

R 中的欺诈检测

Preparing Video For Download...