Source-linked AI summary
How to avoid machine learning pitfalls: a guide for academic researchers
Michael A. Lones
TL;DR
Machine-learning mistakes can cause models to fail on unseen data and erode trust in ML findings and products. The guide organizes practical advice across the ML process, emphasizing rigorous evaluation, fair comparison, and valid conclusions. It also highlights that benchmark results can be over-optimistic and statistical tests are imperfect.
Problem
Common ML mistakes can make models fail on unseen data and erode trust in ML findings and products, while academic research requires rigorous comparisons and valid conclusions.
Method
The guide presents accessible, academically focused guidance covering model development, repeated evaluation, fair comparison, and reporting across five stages of the ML process.
Results
The guide identifies practical pitfalls including test leakage, unreliable final-model evaluation, temporal leakage, benchmark over-optimism, and unsupported generalization.
Takeaways & Limitations
Researchers should evaluate and compare models in the same context, use multiple datasets and metrics, and limit conclusions to what the data supports.
Takeaways & Limitations
Benchmark results may be over-optimistic because unrestricted test access enables training to the test set, and foundation-model training data may include benchmark tests.
Abstract
from arXiv · showhide
Mistakes in machine learning practice are commonplace, and can result in a loss of confidence in the findings and products of machine learning. This guide outlines common mistakes that occur when using machine learning, and what can be done to avoid them. Whilst it should be accessible to anyone with a basic understanding of machine learning techniques, it focuses on issues that are of particular concern within academic research, such as the need to do rigorous comparisons and reach valid conclusions. It covers five stages of the machine learning process: what to do before model building, how to reliably build models, how to robustly evaluate models, how to compare models fairly, and how to report results.
1 Introduction
Machine-learning mistakes can undermine model performance on unseen data and erode trust in ML findings and products. This guide offers accessible, academically focused guidance for avoiding those mistakes, especially through rigorous evaluation and comparison.
- Mistakes in ML can make models fail on data not seen during training and testing, causing project failures and societal loss of trust.
- The guide helps newcomers avoid common ML mistakes while remaining accessible to readers with basic knowledge of ML techniques.
- Its academic focus emphasizes rigorously evaluating and comparing models to support publishable research.
- The guidance is informal and non-exhaustive, and readers are directed to subject-specific guidance where available.
Changes
The guide has evolved through annual updates, adding and expanding advice on data, evaluation, fairness, deep learning, and reporting. Its current version is identified as v51.
- The guide has been updated annually since its first release in 2021 and is intended to continue evolving with ML pitfalls.
- The current cited arXiv version is v51, and the guide identifies its published Patterns version as “Avoiding machine learning pitfalls.”
- Newer revisions added guidance on meaningful baselines, data cleaning, model fairness, checklists, and decisions about data use.
- Revisions expanded advice on deep learning, feature selection, sequential overfitting, metrics, repeated evaluation, and model combination.
2 Before you start to build models
Before building models, researchers should clarify project goals, understand data quality and limitations, and examine prior work and deployment context. Careful data handling helps prevent inappropriate models and unsupported generalization.
- Researchers should define project goals, understand the data, consider its limitations, and review prior work before training and evaluating models.
- Data planning must distinguish training and testing needs while accounting for experimentation and overfitting risks.
- Researchers should verify data provenance, collection methodology, quality, and known limitations rather than treating repeated use as evidence of quality.
- Exploratory analysis should avoid closely examining test data because resulting assumptions can limit model generality in an untestable way.
- Insufficient data may prevent generalization, with the required amount depending on the dataset’s signal-to-noise ratio.
- Domain experts can guide useful problem selection, feature and model choices, and suitability of model transparency for the application.
3 How to reliably build models
Reliable model building requires an organized process, appropriate model choices, and strict separation of training and test information. Test leakage makes evaluation unreliable because the test set no longer measures generality independently.
- Model building should be organized, use data correctly, and give adequate consideration to model choice rather than becoming a disorderly collection of experiments.
- A reliable evaluation requires training data to build the model and test data to measure its generality without leakage.
- When test information enters model configuration, training, or selection, the test set no longer provides a reliable measure of generality.
3.2 Do try out a range of different models
No single machine-learning model is best for every problem, so researchers should compare models suited to their data and keep current with relevant developments. Modern libraries simplify implementation but can also make inappropriate model–data pairings easy to apply.
- No machine-learning approach is best across every possible problem, so model choice should fit the particular task.The No Free Lunch theorem motivates selecting models according to their suitability for the problem.
- Researchers should try a range of models rather than assume that one model family is universally appropriate.This is especially relevant because different models encode different inductive biases.
- Modern machine-learning libraries lower implementation barriers but can permit inappropriate model–data pairings that lose information and produce poor models.For example, categorical-feature models may be applied to numerical features, or vice versa, without suitable transformation.
- Researchers using deep learning should follow recent developments because newer architectures have largely superseded older models for several applications.Transformers have become a go-to model for sequential data and are increasingly used with other data types.
3.5 Don’t assume deep learning will be the best approach
Deep neural networks are not automatically the best solution: their suitability depends on the task and data, and other machine-learning models can outperform them. Researchers should therefore test alternatives rather than assume deep learning will prevail.
- Assuming deep neural networks are best for every problem can prevent researchers from testing more appropriate models.
- Deep learning can be outperformed by older approaches such as random forests and SVMs, particularly on some data types.Tree-based models often outperform deep learners on tabular data.
- The suitability of a neural-network architecture depends on the data type and task rather than on deep learning alone.
3.6 Do be careful where and how you do feature selection
Feature selection is part of model training and must be performed without using information from the held-out test data. Selecting features before the train–test split leaks test-set information into training and can invalidate evaluation.
- Treat feature selection as part of model training rather than as a preprocessing step performed on the entire dataset.
- Selecting features before splitting off the test set leaks information from the test data into the training process.
3.7 Do optimise your model’s hyperparameters
Hyperparameters materially affect model performance and should be tuned for the specific dataset with a defensible optimisation strategy. Feature-selection procedures must also keep training and test information separate, while spurious correlations can produce misleading models.
- Hyperparameters such as SVM kernels, random-forest tree counts, and neural-network architectures can significantly affect model performance.
- Feature selection must use the training set while applying the same selected features to the test set.
- Models can appear effective by exploiting spurious background correlations instead of recognising the intended objects.In the tank example, consistent background colours allow classification without object recognition, resulting in a poor model.
- Hyperparameters should be fitted to the particular dataset rather than selected through informal trial and error.A systematic optimisation strategy is easier to justify when reporting results.
3.8 Do avoid learning spurious correlations
Spurious correlations are features correlated with the target but lacking semantic meaning, so models may appear accurate while failing to generalise. Their risk increases with complex data and models, although regularisation and data augmentation can help mitigate it.
- What spurious correlations are: Spurious correlations are target-associated features without semantic meaning that can mislead models during training.The guide describes them as red herrings that models may use instead of meaningful features.
- Why they matter: A model relying on spurious correlations can achieve strong metric scores yet fail in practice.The tank example illustrates how weather-related pixels could replace the intended visual signal.
- Why they matter: Complex data contains more spurious correlations, while complex models have greater capacity to overfit them.The guide identifies this as a particular concern for deep learning.
- Mitigation: Regularisation and data augmentation can help mitigate spurious-correlation overfitting in deep learning.These approaches are presented as possible mitigations rather than guarantees.
4 How to robustly evaluate models
Robust evaluation requires appropriate, independent test data and procedures that account for model instability, dependencies, repeated selection, class imbalance, fairness, and temporal order. The guide emphasises that evaluation choices determine whether reported performance reflects generalisable knowledge.
- Use appropriate test data: Test-set performance is meaningful only when the test data is non-overlapping with training data and representative of the wider population.Training-set performance alone can be nearly meaningless for assessing generalisable knowledge.
- Prevent leakage: Data augmentation should be restricted to training data, because augmented test data can let models overfit augmentation-specific characteristics.The supplied passage warns that this undermines reliable testing of the original samples.
- Prevent leakage: Sequential overfitting occurs when repeated test-set results guide successive model or hyperparameter choices, making the test set part of training.Use a validation set during model selection and reserve the test set for final generality measurement.
- Evaluate repeatedly: Multiple evaluations are needed because stochastic or unstable models can vary substantially across training runs or small data changes.Cross-validation, repeated resampling, or repeated training can provide distributions rather than a single potentially misleading estimate.
- Evaluate the final instance: Cross-validation estimates a general model’s potential, but selecting the best fold-specific model instance may require another independent test set.The highest-scoring instance may have benefited from an unusually easy fold.
- Choose metrics carefully: Accuracy can be misleading on imbalanced data: a classifier always predicting the 90% class achieves 90% accuracy despite being useless.F1 score, Cohen’s kappa, and MCC are suggested as relatively imbalance-insensitive alternatives.
- Consider fairness: Evaluation should also examine fairness, because models trained on biased or geographically narrow data may operate unfairly for other populations.The guide recommends understanding resulting biases and taking steps to mitigate them where possible.
- Respect temporal dependencies: Time-series evaluation must respect temporal order because look-ahead bias can leak future information into training and bias test performance.Blocked cross-validation is one possible remedy, depending partly on whether the series is stationary or non-stationary.
5 How to compare models fairly
Fair model comparison requires the same experimental context, meaningful baselines, repeated evaluations, and appropriate statistical testing. Published benchmark gains can be over-optimistic when datasets or test sets are reused across models and researchers.
- Comparison principles: Unfair comparisons can mislead subsequent research, so models should be evaluated in the same context from multiple perspectives.The guide identifies correct statistical testing as part of fair comparison.
- Avoid misleading comparisons: A higher published metric does not by itself establish a better model when data partitions, class imbalance, datasets, or optimisation effort differ.Comparisons based only on published figures should therefore be treated cautiously.
- Build fair comparisons: A fair comparison freshly implements each model, optimises them to the same degree, evaluates them multiple times, and tests whether differences are statistically significant.These controls address unequal implementation, tuning, evaluation variability, and chance differences.
- Use meaningful baselines: Meaningful baselines include the established approach being extended, simpler alternatives, and naïve models that show the new method is not doing something trivial.For tabular deep learning, the guide gives decision trees and SVMs as examples of simpler comparators.
- Use statistical tests: Statistical tests for individual model instances require multiple evaluations, while tests comparing more than two models must account for inflated false-significance risk from repeated pairwise testing.Mann–Whitney’s U test is presented as safer than Student’s t-test when score distributions are not normally distributed.
- Interpret benchmarks cautiously: Shared benchmarks can produce over-optimistic results because unrestricted test access and community-wide reuse allow models to overfit the test set.Foundation-model training data may even include benchmark test sets, further complicating interpretation.
- Consider combinations: Model combinations can compensate for individual weaknesses by combining different models’ trade-offs and strengths.Ensembles are given as an established family of composite approaches.
6 How to report your results
Reporting ML results should provide a complete, transparent, and nuanced account of what worked, what did not, and how robust the findings are. Multiple datasets, metrics, model analyses, and appropriate caveats help readers assess performance and limitations.
- Report both successful and unsuccessful results, because ML models often involve trade-offs rather than one model being best in every relevant way.
- Sharing models and experiment scripts improves reproducibility, supports fairer comparisons, and encourages careful documentation and clean code.
- Use multiple datasets and metrics to reduce dependence on individual datasets and present different perspectives on model performance.
- Do not generalise beyond the evaluated data: strong performance on one dataset does not establish performance on other datasets.
- Multiple datasets may share biases or lack independence, while deep-learning data can have limited quality checking because quantity is needed.
- Statistical significance does not necessarily indicate practical importance, and threshold-based tests can overstate or understate evidence.
7 Final thoughts
Machine learning remains an emerging practice in which common mistakes can make models appear effective when they are not. The guide describes these pitfalls and offers advice while emphasizing continued vigilance as new threats emerge.
- Mistakes can make an ML model appear to perform well despite poor real performance, potentially misinforming published research and causing harm after deployment.
- The guide addresses common pitfalls alongside broader good practices such as fairness, transparency, and avoiding bias.
- Because new threats emerge as ML develops, practitioners should remain vigilant about methods that may later prove inadequate.