A practitioner fits a StandardScaler on the training split, transforms the training data, and then needs to prepare the held-out test split for evaluation. Which action correctly preserves the integrity of the evaluation?
- ARefit a fresh StandardScaler on the test split and transform the test data with those new test-derived statistics.
- BFit one StandardScaler on the combined training and test data and apply it to both splits together.
- CSkip scaling the test split because the model has already learned the appropriate weights from scaled training data.
- DReuse the scaler already fitted on the training split to transform the test data with the training-derived statistics. Correct
Why A is wrong: Refitting on the test split is tempting because it scales the test data to a clean mean and variance, but it lets test statistics influence preprocessing, producing inconsistent transforms and an unrealistic evaluation.
Why B is wrong: Combining both splits before fitting feels efficient, but it leaks information from the test set into preprocessing, inflating measured performance and breaking the separation the test split exists to guarantee.
Why C is wrong: Leaving the test data unscaled seems harmless since the model is already trained, but the model expects scaled inputs; feeding raw-magnitude test features produces a train-test mismatch and degraded predictions.
Why D is correct: The scaler must learn its mean and standard deviation only from training data and then apply those fixed statistics to the test data, so the evaluation reflects how the model will see genuinely unseen inputs at deployment.