What is class imbalance and how does it affect deep learning models?
Class imbalance happens when some classes appear much more often than others in a training dataset.
For example, a fraud dataset might contain:
- 99,000 legitimate transactions
- 1,000 fraudulent transactions
Here, legitimate transactions are the majority class, while fraudulent transactions are the minority class.
How does class imbalance affect a deep learning model?
A model trained on highly imbalanced data may become biased toward the majority class because predicting that class correctly produces good overall results more often.
This can cause:
- Poor detection of minority-class examples.
- High overall accuracy but weak real-world performance.
- Low recall for the minority class.
- Misleading evaluation if accuracy is used alone.
For example, if only 1% of examples are positive, a model that predicts every example as negative would achieve about 99% accuracy while completely failing to detect the positive class.
How should an imbalanced model be evaluated?
Metrics such as precision, recall, F1-score, and the confusion matrix are often more informative than accuracy alone because they show how well each class is being predicted.
See “What is a confusion matrix?” and “What are precision, recall, and F1-score?” for those metrics.
Common ways to reduce the problem
Depending on the task, class imbalance can be addressed using techniques such as:
- Giving higher loss weights to minority classes.
- Oversampling minority examples.
- Undersampling majority examples.
- Collecting more minority-class data.
- Using suitable evaluation metrics and decision thresholds.
In short, class imbalance means some classes are much more common than others, which can make a deep learning model favor the majority class and perform poorly on important minority cases.
Learning Sequence
Deep Learning Curriculum
Explore Related Questions
Deepen your understanding across related Deep Learning topics.