Skip to content
Quantoros

How does placing imputation and feature selection inside a searched Pipeline prevent leakage?

Classic MLLevel: IntermediateFold-local preprocessing

How does placing imputation and feature selection inside a searched Pipeline prevent leakage?

Hints
  • Cross-validation clones the complete estimator.
  • Selection can use target information.

Answer

Each CV training fold fits its own preprocessing and selection before scoring its held-out fold. Precomputing these steps on all rows lets validation data influence fitted transformations.

Source and licence: scikit-learn 1.7.2 — compose · BSD-3-Clause · answer: Quantoros editorial

Related questions