topskill.dev
CoursesTracks
All courses/Machine Learning FundamentalsData leakage
Fitting and reliable evaluation
3 / 7
← Machine Learning Fundamentals
○What machine learning learns○Features and labels○Training and inference○Regression or classification○The machine learning process○Data quality and coverage○Representing data✦Module Quiz
○Linear regression○Try a tiny linear model○Logistic regression○Nearest neighbors○Decision trees○Random forests○Boosting○Naive Bayes○Support vector machines✦Module Quiz
○Clustering○K-means○Choosing and interpreting clusters○Principal component analysis○Neural networks and deep learning○Self-supervised learning○Transfer learning○Reinforcement learning✦Module Quiz
○Generalization and overfitting○Holding out evaluation data●Data leakage○Baselines○Bias and variance intuition○Reading learning curves✦Module Quiz
○Prediction errors and residuals○Measuring regression error○Squared error and large misses○The confusion matrix○Precision and recall○Try a held-out classifier✦Module Quiz
○Bias and limits○Monitoring and drift○Comparing models for a decision✦Module Quiz
Fitting and reliable evaluation

Data leakage

Data leakage occurs when training or model selection uses information that should not be available for the intended prediction. It can produce convincing scores for an unusable model.

For a prediction made at dispatch, "actual arrival time" leaks the answer. A less obvious feature, "refund issued for lateness," also comes from the outcome. Renaming it does not make it a valid input.

Leakage can enter preparation too. Suppose missing distances are filled with the average distance across the entire dataset before a split. The training process has now learned a little about the held-out examples. Instead, learn the replacement value from training data and reuse that value unchanged on validation, test, and future inputs.

The same rule applies to scaling and PCA. During cross-validation, fit preparation separately inside each training partition. Near-duplicate rows across training and test sets can also make a result misleading.

Ask two questions about every feature and fitted step: could we know this at prediction time, and did any held-out information influence learning? A suspiciously excellent score is a reason to inspect the pipeline before celebrating.

Check your understanding

Can a refund issued after a delivery be used to predict lateness at dispatch?

Answer: No. It is unavailable at dispatch and reveals information about the later outcome.

Fact 1
1 / 1
FACT 1

No. It is unavailable at dispatch and reveals information about the later outcome.