Data Leakage: The Bug That Fakes Accuracy, Reproduced
One column filled in after delivery lifted test accuracy from 0.69 to 0.95.
Video #186 ยท Machine learning and data science
Steps in the video
Files
- data.py (28 lines)
- run.py (39 lines)
Tested with
Python 3.12.15 | numpy==2.5.4, scikit-learn==1.9.1, scipy==1.18.1, joblib==1.6.0, narwhals==2.27.1, threadpoolctl==3.7.0, cloudpickle==3.1.2
What this does not show
Made-up data with leaks built on purpose; small test sets; time leaks and preprocessing leaks are not shown.
Sources
- https://en.wikipedia.org/wiki/Leakage_(machine_learning)
- https://h2o.ai/wiki/target-leakage/
- https://pypi.org/pypi/numpy/json
- https://pypi.org/pypi/scikit-learn/json
- https://scikit-learn.org/stable/common_pitfalls.html
- https://scikit-learn.org/stable/modules/cross_validation.html
- https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GroupKFold.html
Learning IT by Example.