A data scientist splits a labelled dataset and then fits a StandardScaler on the combined training and test sets before applying it to both. What problem does this introduce?
- AThe model will underfit because scaling reduces the variance of the features.
- BThe validation split becomes unnecessary because scaling already regularises the model.
- CCategorical features get converted to float values, causing label encoding errors.
- DData leakage occurs because statistics from the test set influence the training transformation. Correct
Why A is wrong: Scaling does not inherently cause underfitting; it changes the numeric range of features, not their information content. Conflating scale with variance loss is a common misconception, but it is not the issue introduced by fitting on combined data.
Why B is wrong: Scaling is a preprocessing step that normalises feature ranges; it performs no regularisation and does not replace the need for a held-out validation split. Conflating the two concepts is tempting but incorrect.
Why C is wrong: StandardScaler operates on numeric columns; applying it to categorical columns is a separate concern and not the problem introduced by fitting the scaler across both splits. The described error is a red herring about a different preprocessing stage.
Why D is correct: Fitting the scaler on both splits lets the mean and standard deviation absorb information from the test set. When the model trains with those parameters, it has indirectly seen test distribution information, giving an overly optimistic evaluation.