You fit a scaler on the full dataset before splitting into train and test. What is wrong?
- Exam domain
- Data Science Pipelines and Workflow Automation13% of the exam
- Difficulty
- Medium
- In this mock
- 7 questions on this domainPractise this domain
Why the exam asks this
Data Science Pipelines and Workflow Automation (13% of the exam)
Objective in the exam guide: Feature engineering, selection, and transformation for model improvement
Feature transformation is part of pipeline design.
Why D is the answer
Test information leaks into training
Fitting on all data lets test-set statistics influence training, which leaks information and inflates scores. Fit on training data only.
Remember: Fit preprocessing on training data only.
How it works
Feature selection and transformation must avoid leakage by fitting on training data only.
In detail
- Fit transformers on training data only.
- Apply them to test data.
Every option, checked
Knowing why each wrong option fails is how you rule it out on exam day.
A. The model cannot use scaled featuresWrong
Scaled features are normal.
B. Nothing, since scaling never changes model results in any meaningful wayWrongMost tempting
Leakage changes results.
Why it tempts: Scaling seems harmless.
C. The scaler becomes slower on GPUsWrong
Speed is not the issue.
D. Test information leaks into trainingRight
Fit preprocessing on training data only.
Use case
An illustrative scenario, not a real incident.
Illustrative: fixing the leak drops the reported score from 91% to a realistic 87%.
See it in different ways
flowchart LR S0["Split"] --> S1["Fit scaler on train"] --> S2["Transform train"] --> S3["Transform test"] --> S4["Train and evaluate"]
How to read this chart
- Read it in order: Split, then Fit scaler on train, then Transform train, then Transform test, then Train and evaluate.
mindmap
root(("Features"))
n1["Selection"]
n2["Remove weak features"]
n3["Transformation"]
n4["Scaling"]
n5["Encoding"]
n6["Safety"]
n7["Fit on train only"]How to read this chart
- The centre is "Features".
- "Selection" covers "Remove weak features".
- "Transformation" covers "Scaling", "Encoding".
- "Safety" covers "Fit on train only".