무작위 언더샘플링

R로 배우는 사기 탐지

Bart Baesens

Professor Data Science at KU Leuven

무작위 언더샘플링 (RUS)

언더샘플링 후 클래스 분포 막대그래프

R로 배우는 사기 탐지

원본 데이터의 학습/테스트 분할

R로 배우는 사기 탐지

무작위 언더샘플링 개념도 1

R로 배우는 사기 탐지

무작위 언더샘플링 개념도 2

R로 배우는 사기 탐지

불균형 데이터의 V2 vs 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 vs 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 vs V1 산점도

R로 배우는 사기 탐지

연습해 봅시다!

R로 배우는 사기 탐지

Preparing Video For Download...