Machine Learning

How to handle highly imbalanced datasets in ML classification?

AA Asked by Aaron Fitzgerald · 22-08-2025
0 upvotes 11,275 views 0 comments
The question

I'm working on a credit card fraud detection model where only 0.1% of the transactions are actually fraudulent. My model has 99.9% accuracy, but it's failing to catch any actual fraud! What are the best techniques for handling this kind of class imbalance so the model actually learns the minority class?

3 answers

0
CY
Answered on 24-08-2025

This is a classic "Accuracy Paradox." In fraud detection, accuracy is a useless metric because the model can just predict "not fraud" every time and be right 99.9% of the time. You need to look at Precision, Recall, and the F1-Score instead. To fix the data itself, try SMOTE (Synthetic Minority Over-sampling Technique), which creates "fake" minority samples to balance the classes. Alternatively, you can use "cost-sensitive learning" where you penalize the model more heavily for missing a fraud case than for a false alarm. These methods force the algorithm to pay attention to the rare cases.

0
PA
Answered on 25-08-2025

Cynthia, between over-sampling and under-sampling, which one do you find leads to less "overfitting" in a production environment?

BR 26-08-2025

Patrick, that’s a sharp question. Over-sampling (like SMOTE) carries a higher risk of overfitting because you're creating synthetic data. Under-sampling is safer for overfitting but you risk throwing away valuable information from the majority class. Personally, I prefer using ensemble methods like Balanced Random Forest. These algorithms handle the sampling internally across different "trees," which usually results in a much more robust model that generalizes well to new, unseen transactions.

0
HE
Answered on 27-08-2025

You should also try the Precision-Recall curve instead of the ROC curve. It gives a much better picture of performance on imbalanced data.

AA 28-08-2025

Spot on, Heather. The PR curve focuses specifically on the minority class, which is exactly what Aaron needs for his fraud detection model.

Share your thoughts

Your email address will not be published. Required fields are marked (*)

Professional Counselling Session

Still have questions?
Schedule a free counselling session

Our experts are ready to help you with any questions about courses, admissions, or career paths. Get personalized guidance from industry professionals.

Request a Call Back

Search Online

We Accept

We Accept

Follow Us

"PMI®", "PMBOK®", "PMP®", "CAPM®" and "PMI-ACP®" are registered marks of the Project Management Institute, Inc. | "CSM", "CST" are Registered Trade Marks of The Scrum Alliance, USA. | COBIT® is a trademark of ISACA® registered in the United States and other countries.

Book Free Session