Tăng phát hiện thành công bằng lấy mẫu lại dữ liệu

Phát hiện gian lận với Python

Charlotte Werger

Data Scientist

Undersampling

Phát hiện gian lận với Python

Oversampling

Phát hiện gian lận với Python

Oversampling trong Python

from imblearn.over_sampling import RandomOverSampler

method = RandomOverSampler() X_resampled, y_resampled = method.fit_resample(X, y)
compare_plots(X_resampled, y_resampled, X, y)

Phát hiện gian lận với Python

Kỹ thuật Oversampling cho lớp thiểu số (SMOTE)

1 https://www.kaggle.com/rafjaa/resampling-strategies-for-imbalanced-datasets
Phát hiện gian lận với Python

Chọn phương pháp lấy mẫu lại nào?

  • Random Under Sampling (RUS): loại bớt dữ liệu, tính toán hiệu quả
  • Random Over Sampling (ROS): đơn giản, nhưng huấn luyện trên nhiều bản sao
  • Synthetic Minority Oversampling Technique (SMOTE): tập dữ liệu thực tế hơn, nhưng huấn luyện trên dữ liệu “giả”
Phát hiện gian lận với Python

Khi nào dùng phương pháp lấy mẫu lại

from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression

# Define resampling method and split into train and test method = SMOTE() X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.8, random_state=0)
# Apply resampling to the training data only X_resampled, y_resampled = method.fit_resample(X_train, y_train)
# Continue fitting the model and obtain predictions model = LogisticRegression() model.fit(X_resampled, y_resampled)
# Get your performance metrics predicted = model.predict(X_test) print (classification_report(y_test, predicted))
Phát hiện gian lận với Python

Ayo berlatih!

Phát hiện gian lận với Python

Preparing Video For Download...