Why should resampling happen only at fit time and not at prediction time in an ML pipeline?
Last updated
Resampling shapes what the model learns. At inference every real input must be scored exactly once, so dropping rows or inventing fake ones corrupts predictions and evaluation.
In cross-validation, resample only inside each training fold. Resampling before splitting leaks synthetic neighbors of validation points into training.
imbalanced-learn samplers use
fit_resample, andimblearn.pipeline.Pipelineapplies them duringfitbut skips them inpredictandscore.