NCA-GENL - Data Analysis and Visualization (14% of the exam) - Section 4.4
Apply essential machine learning techniques for data preparation.
Apply essential data preparation techniques including handling missing values, feature scaling, categorical encoding, and train-validation-test splitting to produce clean, model-ready datasets. Understand how poor data preparation introduces bias or data leakage, and recognise the steps that must occur before training begins.
Practice question for this objective
lock_openFree sampleData Analysis and Visualizationeasy
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.check_circle Correct
Understand why a preprocessing scaler must be fitted only on training data to avoid data leakage into evaluation. Data leakage in preprocessing happens when statistics computed on held-out data (test or validation) are used to transform training data. Fitting a StandardScaler on the full dataset before splitting means the scaler's mean and standard deviation encode test-set information, so the model is effectively trained on transformed features that were shaped by data it should never have seen. The correct practice is to fit the scaler exclusively on the training split and then apply (transform only) it to the validation and test splits.
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.
Answers that look right on this material and are not. Each one is a distractor from a different question in the NCA-GENL bank for this domain.
Fitting on the training split alone is required because validation and test sets are always smaller, and small sets cannot produce a numerically stable mean or standard deviation.
errorWhy it is wrong: Tempting because held-out sets are often smaller, but the reason is leakage prevention, not numerical stability, and a small set can still yield a usable mean, so the justification is wrong.
Drop the entire feature column because any imputation risks distorting the model.
errorWhy it is wrong: Removing a feature entirely discards all the predictive signal it carries across the 92% of complete rows. Dropping columns is a last resort for features that are mostly missing or entirely redundant, not for 8% missingness in a useful column.
The statistics should be computed from the entire dataset including the test split, because using all available rows gives the most accurate estimate of the true mean and standard deviation
errorWhy it is wrong: Tempting because more rows do give a tighter statistical estimate, but fitting the scaler on the test split leaks test-set information into preprocessing and inflates apparent performance.