असंतुलित डेटासेट से निपटना

R में Fraud Detection

Bart Baesens

Professor Data Science at KU Leuven

असंतुलित डेटा सेट

  • मुख्य चुनौती: घटनाओं को fraud या non-fraud लेबल करें
    • वर्गीकरण और anomaly detection तकनीकों के लिए बड़ी चुनौती
  • Classifier बहुमत क्लास (= no-fraud) को तरजीह देता है
    • fraud मामलों पर बड़ा classification error
  • Classifiers balanced वितरण से बेहतर सीखते हैं

भुस्सी के ढेर में सुई

R में Fraud Detection

असंतुलित डेटा सेट

  • मुख्य चुनौती: घटनाओं को fraud या non-fraud लेबल करें
    • वर्गीकरण और anomaly detection तकनीकों के लिए बड़ी चुनौती
  • Classifier बहुमत क्लास (= no-fraud) को तरजीह देता है
    • fraud मामलों पर बड़ा classification error
  • Classifiers balanced वितरण से बेहतर सीखते हैं
  • संभावित समाधान: sampling methods से class distribution बदलें

भुस्सी के ढेर में सुई

R में Fraud Detection

मूल असंतुलन

class_barplot_orig.png

R में Fraud Detection

अल्पसंख्यक क्लास का over-sampling...

class_barplot_over

R में Fraud Detection

... या बहुमत क्लास का under-sampling ...

class_barplot_under

R में Fraud Detection

... या दोनों!

class_barplot_both

R में Fraud Detection

Sampling के बाद परिणाम...

class_barplot_result2

R में Fraud Detection

... या ऐसा भी

class_barplot_result1

R में Fraud Detection

Random over-sampling (ROS)

orig_data_v0

R में Fraud Detection

orig_data_train_test

R में Fraud Detection

random_oversampling_v0

R में Fraud Detection

random_oversampling_v1

R में Fraud Detection

व्यवहार में random over-sampling

  • Kaggle पर Credit Card Fraud Detection डेटासेट
    • $\sim$ 300K anonymized क्रेडिट कार्ड ट्रांसफर, fraud या genuine के रूप में लेबल
  • डेटा के बारे में...
    • Numerical (anonymized) वैरिएबल: V1, V2, ... , V28
    • Time = हर ट्रांसफर और डेटासेट की पहली ट्रांसफर के बीच बीते सेकंड
    • Amount = लेन-देन राशि
    • Class = response वैरिएबल: fraud पर मान 1, अन्यथा 0
R में Fraud Detection

creditcard_V2vsV1

R में Fraud Detection

असंतुलन जाँचें

head(creditcard)
  Time         V1         V2  ...            V27         V28 Amount Class
1    0  1.1918571  0.2661507  ...  -0.0089830991  0.01472417   2.69     0
2   10  0.3849782  0.6161095  ...   0.0424724419 -0.05433739   9.99     0
3   12 -0.7524170  0.3454854  ...  -0.1809975001  0.12939406  15.99     0
4   17  0.9624961  0.3284610  ...   0.0163706433 -0.01460533  34.09     0
5   34  0.2016859  0.4974832  ...   0.1427572469  0.21923761   9.99     0
prop.table(table(creditcard$Class))
   0    1 
0.98 0.02
R में Fraud Detection

ROSE पैकेज का ovun.sample

n_legit <- 24108
new_frac_legit <- 0.50
new_n_total <- n_legit / new_frac_legit ## = 24108 / 0.50 = 48216

library(ROSE) oversampling_result <- ovun.sample(formula = Class ~ ., data = creditcard, method = "over", N = new_n_total, seed = 2018)
oversampled_credit <- oversampling_result$data prop.table(table(oversampled_credit$Class))
  0   1 
0.5 0.5
R में Fraud Detection

creditcard_V2vsV1_oversampled

R में Fraud Detection

अभ्यास करते हैं!

R में Fraud Detection

Preparing Video For Download...