Insights

Evaluation pitfalls in applied machine learning, with a leakage checklist

How data leakage, test-set label errors and poor metric choices inflate reported accuracy, what the published evidence shows, and a checklist a team can run before trusting a number.

A model is only as good as the test that measured it. The most common way to get a wrong answer is not a bad architecture. It is an evaluation that lets information from the test set reach the model, or a test set that does not represent the data the model will see. This article summarizes two primary studies of these failures and turns them into a checklist.

Leakage, defined

Kapoor and Narayanan define data leakage as a spurious relationship between the inputs and the target. It arises from how the data were collected, sampled or pre-processed, and it will not exist in the data the claims are about. Leakage therefore usually inflates measured performance [1].

Their survey found 22 papers that each examined the use of machine learning in a scientific field. Across 17 fields, these papers identified leakage affecting 294 publications [1]. The setting is ML-based science, not product engineering, but the mechanisms are the same ones an engineering team meets. The authors note one difference. Engineering teams can often check a model by deploying it at limited scale, and they usually care less about small performance differences [1]. That check comes late and costs money. It is cheaper to catch leakage before release.

Eight ways leakage enters

The taxonomy groups leakage into three families and eight types [1].

No clean split between training and test data.

  • No test set. Training and evaluating on the same data.
  • Pre-processing on the whole dataset. Imputing missing values or over- and under-sampling before the split. Oversampling before splitting, for example, puts generated copies of training points into the test set.
  • Feature selection on the whole dataset. Choosing features by how well they perform, using data that includes the test set.
  • Duplicates. The same record appears in both sets.

Features that would not be available at prediction time. A feature can be a proxy for the target. The paper’s example is a hypertension model that used the prescription of anti-hypertensive drugs as an input [1]. Deciding which features are legitimate needs domain knowledge, so the authors give no sub-types here.

A test set drawn from the wrong distribution.

  • Temporal leakage. When predicting the future, the test set must not contain data from before the training period.
  • Non-independence. Training and test samples come from the same people or units. One histopathology study used different observations of the same patient in both sets [1].
  • Sampling bias. The test set is not representative of the population the claim covers. Examples include testing at one location and claiming results elsewhere, or dropping hard borderline cases. Pneumonia models trained on images from one hospital did not generalize to another [1].

In sensor and signal work, non-independence is the type we would check first. Windows cut from one recording, one machine or one subject are strongly correlated. A random split by window spreads that correlation across both sets. The MLPerf Tiny keyword-spotting benchmark avoids this by using the Speech Commands split, in which each speaker appears in only one of the training, validation and test subsets [2].

What leakage did to one field

Kapoor and Narayanan reproduced civil war prediction studies from political science. Of 124 papers found in a systematic search, 12 predicted civil war with a train-test split and shared complete code and data [1]. They found errors in 4 of the 12. These were exactly the 4 that claimed complex models such as random forests beat logistic regression [1]. The errors included imputing training and test data together, reusing an imputed dataset incorrectly, and using proxies for the target. Once corrected, the complex models were no better than logistic regression, except in one paper where the AUC advantage shrank from 0.14 to 0.01 [1].

The same study found that 9 of the 12 papers reported no significance tests or uncertainty estimates [1]. One test set contained only 11 civil war onsets. Its reported smoothed AUC of 0.85 had a bootstrapped 95% confidence interval of 0.66 to 0.95 [1]. A small test set makes an interval that wide. Engineering datasets with rare failure events can look the same.

The test labels may be wrong

Northcutt, Athalye and Mueller checked the test sets of 10 widely used datasets. They flagged likely errors with confident learning, then had crowd workers confirm them [3]. They estimate an average of at least 3.3% label errors across the 10 datasets [3]. Rates ranged from 0.15% for MNIST to 10.12% for QuickDraw. On the ImageNet validation set, 2,916 of 50,000 labels (5.83%) were confirmed as errors [p210, Table 1]. On average, 51% of the algorithmically flagged candidates turned out to be wrong labels [3].

The errors can change which model looks best. On ImageNet with corrected labels, ResNet-18 outperforms ResNet-50 if the share of originally mislabeled test examples rises by about 6%. On CIFAR-10, VGG-11 outperforms VGG-19 at an increase of about 5% [3]. The authors suggest putting effort into clean test labels even when the budget only allows noisier training labels [3]. In an expert review of ImageNet, an image flagged by confident learning was 2.6 times as likely to be mislabeled as an unflagged one, so flagged examples are the place to start a manual review [3]. They also found duplicate images in Caltech-256 [3]. Duplicates turn up even in standard benchmarks.

The metric has to match the question

Kapoor and Narayanan list metric choice as a separate failure. Accuracy on a heavily imbalanced dataset rewards a model that always predicts the majority class [1]. Davis and Goadrich show that on highly skewed data, precision-recall curves give a more informative picture than ROC curves [4]. Their results also carry two practical warnings. Linear interpolation between points is incorrect in precision-recall space, and an algorithm that optimizes area under the ROC curve is not guaranteed to optimize area under the precision-recall curve [4]. For a fault detector where failures are rare, report precision and recall at the operating threshold, not only ROC AUC.

Cross-validation without leaks

The scikit-learn user guide states the basic rule. Pre-processing such as standardization and feature selection must be learned on the training data and then applied to held-out data. Its Pipeline tool makes cross-validation do this automatically [5]. The guide also provides splitters for the dependence structures described above [5]:

  • GroupKFold keeps every sample from a group, such as a subject, in either training or testing, never both.
  • TimeSeriesSplit trains on earlier folds and tests on the next one, so successive training sets grow forward in time.
  • KFold does not shuffle by default. With shuffling enabled and no fixed random_state, each run gives a different split [5].

After deployment

Leakage-free evaluation does not end at release. Sculley et al. point out that manually set decision thresholds go stale when a model is retrained on new data [6]. They suggest monitoring prediction bias, meaning whether the distribution of predicted labels still matches the distribution of observed labels, sliced by relevant dimensions [6]. A change in that comparison often indicates a problem, for example a world that no longer matches the historical training data [6].

Checklist

Each item names the failure it guards against. The L-codes follow Kapoor and Narayanan’s taxonomy [1].

Split and pipeline

  • The test set is created first and kept untouched until final evaluation. (L1.1)
  • Every fitted step (scaling, imputation, resampling, feature selection, dimensionality reduction) sits inside the cross-validation pipeline. (L1.2, L1.3)
  • Exact and near-duplicate records are removed before splitting, or kept within one fold. (L1.4)
  • The split unit matches the deployment unit: subject, machine, recording, site or batch. Group-aware splitters are used. (L3.2)
  • For forecasting, all test data come after all training data, with a gap if labels arrive late. (L3.1)

Features

  • Each feature is available at prediction time in production, with the same latency and quality. (L2)
  • No feature encodes the label, its timestamp or a downstream consequence of it. (L2)
  • A domain expert has reviewed the feature list. (L2)

Test set

  • The test population matches the claim: same sites, devices, operating conditions and difficulty mix. (L3.3)
  • Hard and borderline cases have not been filtered out. (L3.3)
  • Test labels have been audited, starting with the examples a model disagrees with most.

Metrics and reporting

  • The metric matches the class balance and the cost of errors. Precision and recall are reported at the operating threshold.
  • Every headline number has a confidence interval, and model comparisons include a significance test.
  • The baseline is a simple model trained and tested on the same split.
  • Code, data version, split indices and random seeds are recorded so the number can be reproduced.

After release

  • Prediction and observed label distributions are monitored, and thresholds are re-checked after retraining.

For on-device models, the same split rules apply to benchmark data. See TinyML on microcontrollers.

Where Takumetra can help

We can review an existing evaluation pipeline against this checklist and re-run it with group-aware or time-aware splits. We can also design a test set and reporting format before model work starts. See our AI/ML engineering services.

References

  1. S. Kapoor, A. Narayanan, “Leakage and the reproducibility crisis in machine-learning-based science”, Patterns, vol. 4, no. 9, 100804, 2023. DOI: 10.1016/j.patter.2023.100804
  2. C. Banbury, V. Janapa Reddi, P. Torelli, et al., “MLPerf Tiny Benchmark”, arXiv:2106.07597, 2021. arxiv.org/abs/2106.07597
  3. C. G. Northcutt, A. Athalye, J. Mueller, “Pervasive Label Errors in Test Sets Destabilize Machine Learning Benchmarks”, NeurIPS 2021 Track on Datasets and Benchmarks, 2021. arxiv.org/abs/2103.14749
  4. J. Davis, M. Goadrich, “The Relationship Between Precision-Recall and ROC Curves”, Proc. 23rd ICML, pp. 233-240, 2006. DOI: 10.1145/1143844.1143874
  5. scikit-learn developers, “Cross-validation: evaluating estimator performance (scikit-learn 1.9.1 User Guide, section 3.1)”, scikit-learn documentation, 2026. scikit-learn.org/stable/modules/cross_validation.html
  6. D. Sculley, G. Holt, D. Golovin, et al., “Hidden Technical Debt in Machine Learning Systems”, Advances in Neural Information Processing Systems 28 (NIPS 2015), 2015. papers.nips.cc/paper_files/paper/2015/hash/86df7dcfd896fcaf2674f757a2463eba-Abstract.html

Copies of the cited sources are held on file. DOIs were checked against CrossRef.

Related articles