Coding Hubs School of AI – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 8448811540
Back to Machine Learning Notes
Topic #2004

SMOTE

SMOTE (Synthetic Minority Oversampling Technique) fixes plain oversampling's biggest weakness — instead of duplicating existing minority points exactly, it generates new, synthetic minority examples by interpolating between real ones.

The Algorithm

StepWhat Happens
1Pick a random minority-class point \(x_i\)
2Find its \(k\) nearest minority-class neighbors (typically \(k=5\))
3Randomly pick one neighbor, \(x_{zi}\)
4Generate a new synthetic point along the line segment between them
5Repeat until the desired class balance is reached

Formula

\[ x_{\text{new}} = x_i + \lambda(x_{zi}-x_i), \qquad \lambda \sim \text{Uniform}(0,1) \]

\(\lambda\) is a random number between 0 and 1, so the new synthetic point lands somewhere along the straight line connecting \(x_i\) and its neighbor — never exactly on top of either one.

Worked Example

Minority point \(x_i=(2,3)\), its nearest minority neighbor \(x_{zi}=(4,5)\), random \(\lambda=0.5\):

\[ x_{\text{new}} = (2,3) + 0.5\bigl((4,5)-(2,3)\bigr) = (2,3)+0.5(2,2) = (3,4) \]

The synthetic point \((3,4)\) sits exactly halfway between the two real minority points — a genuinely new example, not a duplicate of either.

Graphical Intuition

x_i (2,3) x_zi (4,5) synthetic (3,4)

The new point is a plausible interpolation between two real minority examples — not an exact copy of either one.

Python Implementation

from imblearn.over_sampling import SMOTE
from collections import Counter

smote = SMOTE(k_neighbors=5, random_state=42)
X_resampled, y_resampled = smote.fit_resample(X_train, y_train)

print(Counter(y_train))        # {0: 950, 1: 50}
print(Counter(y_resampled))     # {0: 950, 1: 950} -- balanced with SYNTHETIC, not duplicated, minority points

SMOTE vs Plain Oversampling

Plain OversamplingSMOTE
New minority pointsExact duplicatesSynthetic, interpolated points
Overfitting to specific points?Higher riskLower risk
Requires numeric featuresNo — works on anythingYes — interpolation needs continuous numeric features

Practical Use Cases

  • The most commonly used resampling technique for imbalanced tabular classification with numeric features
  • Fraud, medical, and defect-detection datasets where minority examples are genuinely scarce

Limitations

  • Only works cleanly on numeric features — categorical features need a variant like SMOTE-NC
  • Can generate synthetic points in ambiguous or noisy regions if minority-class examples are themselves scattered and not well-clustered
  • Must still only ever be applied to the training set, same as any resampling technique

Common Mistakes

  • Applying vanilla SMOTE to data with categorical features without switching to SMOTENC or a similar variant.
  • Using a \(k\) for nearest neighbors larger than the number of available minority samples — SMOTE needs at least \(k+1\) minority examples to work.

Interview Relevance

Q: "Why is SMOTE generally preferred over simple random oversampling?" Random oversampling duplicates existing minority points exactly, which can cause a model to overfit to those specific repeated examples; SMOTE instead generates new, synthetic points by interpolating between real minority examples, giving the model more varied, plausible minority-class data to learn from.

Practice Question

Given minority points \(x_i=(1,1)\) and its neighbor \(x_{zi}=(5,9)\), compute the synthetic point SMOTE would generate with \(\lambda=0.25\).

Related ML Notes

Want to go beyond the notes?

Join Coding Hubs School of AI's Machine Learning course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →