Why should oversampling techniques like SMOTE be applied only within training folds during cross-validation?

Quick Overview

Asks why SMOTE and other oversampling methods belong inside the training folds of cross-validation and what goes wrong when they run on the full dataset. Tests understanding of data leakage, imbalanced-class evaluation metrics and correct resampling pipelines.

Why should oversampling techniques like SMOTE be applied only within training folds during cross-validation?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

Why should oversampling techniques like `SMOTE` be applied only within training folds during cross-validation? ```hint Trace one synthetic point Pick one synthetic minority row and ask where the real rows it was built from ended up after the split. ``` ```hint Check what the score measures Compare the class balance of an oversampled validation fold with the balance the model will see in production. ``` ### What a Strong Answer Covers - How SMOTE builds synthetic points, and why running it before the split leaks validation information into training - Why oversampled validation folds misstate precision, PR-AUC and calibration - The correct setup: resampling inside each training fold, with validation folds left real and at the true prevalence - How to enforce this in code, including during hyperparameter search ### Follow-up Questions - Does the same problem occur with plain random oversampling, or with undersampling? - If you tune hyperparameters with `GridSearchCV`, where does SMOTE have to go, and why? - Why are predicted probabilities from a model trained on SMOTE-balanced data miscalibrated, and how would you fix them? - When would you use class weights instead of SMOTE?

Overview: Asks why SMOTE and other oversampling methods belong inside the training folds of cross-validation and what goes wrong when they run on the full dataset. Tests understanding of data leakage, imbalanced-class evaluation metrics and correct resampling pipelines.

PracHub logo
General
Nov 25, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

Why should oversampling techniques like SMOTE be applied only within training folds during cross-validation?

What a Strong Answer Covers Guidance

  • How SMOTE builds synthetic points, and why running it before the split leaks validation information into training
  • Why oversampled validation folds misstate precision, PR-AUC and calibration
  • The correct setup: resampling inside each training fold, with validation folds left real and at the true prevalence
  • How to enforce this in code, including during hyperparameter search

Follow-up Questions Guidance

  • Does the same problem occur with plain random oversampling, or with undersampling?
  • If you tune hyperparameters with GridSearchCV , where does SMOTE have to go, and why?
  • Why are predicted probabilities from a model trained on SMOTE-balanced data miscalibrated, and how would you fix them?
  • When would you use class weights instead of SMOTE?