Keep preprocessing inside the training boundary
The split applies to transformations as well as the estimator.
Trace every fitted step
Scaling, imputation and feature selection can learn information from data. List every step that computes a value used later. Ask which rows are allowed to inform that value. A transformation that appears harmless in a notebook can still cross the evaluation boundary.
Use the boundary consistently
Fit the preprocessing on the training portion, then apply the learned transformation to validation and test records. The scikit-learn common-pitfalls documentation explains this distinction and shows pipelines as one way to keep it consistent. The key is the data boundary, not the presence of a particular class name in the code.
Recheck cross-validation
Within cross-validation, fitted transformations belong inside each training fold. Selecting columns on the full dataset before running cross-validation has already exposed information from the held-out folds. Keep a diagram of the complete procedure so a reviewer can see where each operation learns from data.
Audit the production path
Compare the experiment transformation with the code that will process live records. Check missing fields, unknown categories and type conversions. Retain a small non-sensitive fixture with expected outputs. A correct research split does not guarantee that deployment uses the same transformations, so record both checks separately.
References provide background. The working methods and fictional examples here are our editorial guidance, not an endorsement by the referenced organisations.
Put this into practice: open the worksheet →