Course contentsShow
← Machine Learning and Deep Learning
Lesson 242 of 3,5384. Classification with Logistic RegressionFree lesson

Class Imbalance Introduction

Recognizing when classes have unequal representation and its impact on model training and evaluation.

Class Imbalance Introduction

What you'll learn: You'll understand what class imbalance is and why unequal class sizes can seriously affect your classification model's performance.

What is Class Imbalance?

Class imbalance occurs when your dataset contains far more examples of one class than another. Imagine you're building a fraud detection model: you might have 9,950 legitimate transactions and only 50 fraudulent ones in a dataset of 10,000 examples. That's a 199:1 ratio—a heavily imbalanced dataset.

Why Does This Matter?

Think of it like teaching someone to identify rare birds. If you show them 995 pigeons and only 5 eagles, they'll become really good at recognizing pigeons but terrible at spotting eagles. Worse yet, they might just guess "pigeon" every time and be right 99.5% of the time!

This is exactly what happens with imbalanced classification models. A model could achieve 99.5% accuracy by simply predicting "not fraud" for every transaction—but it would fail completely at its actual job of catching fraud.

The Real Impact

When classes are imbalanced:

  • Accuracy becomes misleading: High accuracy doesn't mean your model is actually useful
  • The minority class gets ignored: The model learns to favor the majority class because that minimizes overall error
  • Evaluation becomes tricky: You need different metrics beyond simple accuracy to truly assess performance

This is why recognizing class imbalance early is crucial. You can't rely on the same training approaches and evaluation metrics you'd use for balanced datasets.

Key Takeaway: Class imbalance occurs when one class vastly outnumbers another in your dataset, causing models to ignore the minority class and making accuracy an unreliable metric—recognizing this problem is the first step toward building fair, effective classifiers.