intermediateadvanced-ml

Class Imbalance & SMOTE

When 99% of your data is one class, your model can cheat by never predicting the other one.

Key Points

What it is

Class imbalance happens when one class vastly outnumbers another in your dataset (e.g. 1% fraud, 99% legitimate transactions). SMOTE (Synthetic Minority Over-sampling Technique) is a common fix that generates new, synthetic examples of the minority class rather than simply duplicating existing ones.

Why it exists

Many high-stakes real-world problems are naturally imbalanced — fraud, disease diagnosis, equipment failure. Models trained naively on this data learn to ignore the rare, important class entirely because it barely affects the loss function. SMOTE and related techniques exist to force the model to actually pay attention to the minority class.

Intuition

Imagine training a security guard on 999 photos of empty hallways and 1 photo of an intruder. The guard could technically be '99.9% accurate' by simply never flagging anything as a threat — while missing the one thing that actually matters. SMOTE is like generating many realistic, slightly varied photos of intruders so the guard actually learns what one looks like.

How it works

  1. Identify the minority class

    Confirm the dataset is imbalanced and decide which class needs boosting.

  2. Find nearest neighbors

    For each minority-class point, find its k nearest minority-class neighbors.

  3. Interpolate new points

    Create synthetic points along the line between a point and one of its neighbors, effectively 'filling in' the minority class region.

  4. Retrain on the balanced set

    Train the model on the original data plus the synthetic minority examples.

When to use

When not to use

Common mistakes

In practice

Standard practice in fraud detection, churn prediction, medical diagnosis, and any classification task where the class you care most about is rare — used together with precision/recall-focused evaluation rather than raw accuracy.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

confusion-matrixprecision-recallroc-auc
Chirp at me!