How does SMOTE generate new synthetic data points?
Last updated
SMOTE creates synthetic minority points by interpolating between a minority sample and one of its nearest minority-class neighbors, placing a new point at a random position on the line segment between them.
Algorithm:
For a minority sample x, find its k nearest minority neighbors (default
k_neighbors=5).Pick one neighbor x_nn at random.
Draw λ ~ Uniform(0, 1) and create x_new = x + λ · (x_nn − x).
Repeat across minority samples until the target ratio is reached.
Why it helps: The new points are not exact copies, so the minority region widens and the model is less likely to memorize individual rows than with random duplication.
Key properties and caveats:
Only minority points are used, so majority-class positions are ignored and synthetics can land in overlap zones.
It relies on distances, so features need scaling, and it only makes sense for continuous features (use SMOTE-NC or SMOTEN for categorical ones).
Apply it only to training folds (inside an
imblearnPipeline), never before the train/test split.
[lang:python]
from imblearn.over_sampling import SMOTE
X_res, y_res = SMOTE(k_neighbors=5, random_state=0).fit_resample(X_train, y_train)