Avoiding Data Leakage
Data leakage is when information from the test set sneaks into training, making the score look better than it will be in real use. A common cause: scaling all the data before splitting, so the scaler has already "seen" the test rows.
The safe rule: split first, fit anything (scalers, models) on the training part only, and only transform the test part. A pipeline does this for you.
Examplepython
Quick check
Where should a scaler be fitted?
Your turn: write the code
Build the pipeline (scaler then LogisticRegression with max_iter=200), fit it on the training data and print the training score rounded to 3 decimals.
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.