Handle Imbalance Dataset Problem

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Handle Imbalance Dataset Problem

Mì Ai
Vấn đề Imbalance Data

Majority

Minority
Vấn đề Imbalance Data

What’s happen if above dataset is balance?


Tác hại của Imbalance
• Hầu hết các thuật toán Phân lớp trong ML hoạt động tốt với balance
dataset.
• Khi dataset không balance:
• Model có thiên hướng predict ra lớp Majority để tăng Accuracy.
• Accuracy không còn tác dụng đánh giá.
Tác hại của Imbalance
Ví dụ:
• Ta có 100 điểm dữ liệu bệnh nhân cần dự đoán Ung thư
• Trong đó:
• 99 điểm là không bị Ung thư
• 1 điểm là bị ung thư
• Nếu ta sử dụng một model luôn trả về Không bị ung thư -> model
sẽ đạt accuracy 99% (Quá tuyệt!!!!???).
• Khi ta train model thì model sẽ có xu hướng trả về Không bị ung
thư nhằm đạt Accuracy cao.
Các phương pháp xử lý
• Thay đổi metric đánh giá model
• Undersampling
• Oversampling
• Class weighted
• Ensemble & Boosting
Các phương pháp xử lý
• Thay đổi metric đánh giá model
Các phương pháp xử lý
• Thay đổi metric đánh giá model
Các phương pháp xử lý
• Thay đổi metric đánh giá model
Undersampling
• Random Undersampling
Undersampling
• NearMiss
Undersampling

• NearMiss-1: Majority class examples with minimum average distance


to three closest minority class examples.
• NearMiss-2: Majority class examples with minimum average distance
to three furthest minority class examples.
• NearMiss-3: Majority class examples with minimum distance to each
minority class example.
Undersampling
Oversampling
• Random Oversampling
• Cluster Oversampling
• SMOTE
Oversampling
• Random Oversampling
Oversampling
• Cluster-Based Over Sampling
In this case, the K-means clustering algorithm is independently applied
to minority and majority class instances. This is to identify clusters in
the dataset. Subsequently, each cluster is oversampled such that all
clusters of the same class have an equal number of instances and all
classes have the same size.
Oversampling
• Cluster-Based Over Sampling
Oversampling
• SMOTE
Oversampling
• SMOTE
Oversampling
• SMOTE

MSMOTE is an improve method


Class_weights
Class_weights
Ensemble & Boosting
Ensemble & Boosting
Ensemble & Boosting
The final tactic we'll consider is using tree-based algorithms. Decision trees often
perform well on imbalanced datasets because their hierarchical structure allows
them to learn signals from both classes.

In modern applied machine learning, tree ensembles (Random Forests, Gradient


Boosted Trees, etc.)

We will try:
- RandomForest
- GradientBoosting
- XGBoost
Handson

You might also like