Deep Learning

How to handle imbalanced datasets in Deep Learning for fraud detection?

GR Asked by Gregory Lane · 04-11-2025
0 upvotes 12,188 views 0 comments
The question

I'm training a CNN-LSTM model to detect credit card fraud, but only 0.1% of my data consists of actual fraud cases. The model keeps achieving 99.9% accuracy by just predicting 'no fraud' for everything. I've tried oversampling, but it's overfitting. What are the best loss functions or architectures to fix this?

3 answers

0
BR
Answered on 10-01-2025

Have you considered using an Anomaly Detection approach like Autoencoders instead of a standard supervised classifier for this specific problem?

SC 14-01-2025

Brandon, that’s a sharp suggestion. An Autoencoder trained only on "normal" transactions will naturally have a high reconstruction error when it encounters fraud. To answer your point about architecture: I’ve found that combining an Autoencoder for feature extraction with a light Gradient Boosting Machine (GBM) on the errors works better than a pure LSTM when the sequence length varies. It captures the "weirdness" of the transaction without needing a massive amount of labeled fraud examples.

0
DI
Answered on 22-01-2025

Try cost-sensitive learning. You can manually assign a higher "penalty weight" to the fraud class in your model's configuration so the optimizer treats a missed fraud as a much bigger error.

GR 25-01-2025

I agree with Diane. Sometimes the simplest solution is just a weighted loss function. It’s much easier to implement in Keras or PyTorch than building complex synthetic data pipelines.

0
KI
Answered on 18-12-2025

Accuracy is a "vanity metric" for imbalanced data; you need to focus on the F1-Score or the Area Under the Precision-Recall Curve (AUPRC). Instead of simple oversampling, I highly recommend using Focal Loss. It adds a factor to the standard Cross-Entropy loss that down-weights the loss for well-classified (easy) examples, forcing the model to focus on the rare, difficult fraud cases. You could also try Synthetic Minority Over-sampling Technique (SMOTE), but apply it only to the training set and keep your validation set "natural" to ensure the model generalizes well to real-world ratios.

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