How-to articleMethodology & analyticsComputer science

How to choose a machine learning algorithm for your research: task, data, accuracy, speed and validation

There is no single best machine learning algorithm. This guide shows how to narrow the choice from your task and data, how to weigh accuracy against speed and interpretability, and how to validate the choice so that an examiner can trust it.

What you will learn

  • Match the learning task (prediction, classification, clustering, sequential decisions) to algorithm families
  • Use sample size, feature type and label availability to shortlist candidate models
  • Choose evaluation metrics that fit the research question and the class balance
  • Distinguish model parameters from hyperparameters and tune them without leaking test data
  • Justify the final choice with baselines, nested validation and attention to interpretability

What you will unlearn

  • One algorithm, such as SVM or deep learning, is best for a given type of data.No algorithm wins across all problems, so candidates must be compared on your data with a fair protocol.
  • Higher accuracy always means a better model.The right metric depends on the task; accuracy can mislead with imbalanced classes or poorly calibrated probabilities.
  • Tuning on the test set is acceptable if you report it.Any use of test data in model selection biases the estimate; tuning belongs inside the training folds.
  • Complex models are needed for publishable research.Simple, well-validated baselines are often competitive and easier to interpret.

Skills you will practise

  • Framing the learning task
  • Shortlisting algorithms
  • Choosing metrics
  • Hyperparameter tuning
  • Nested cross-validation
  • Leakage checks
  • Reporting model comparisons

Start from the task, not the algorithm

The first question is what the model is for. Supervised learning predicts a known outcome from labelled examples: classification for categories, regression for numbers. Unsupervised learning finds structure in unlabelled data, for example clusters or lower-dimensional representations. Reinforcement learning learns a policy from rewards in sequential decisions. Each family contains many algorithms, so the task narrows the field but does not choose for you.

Supervised, unsupervised and reinforcement learning
Figure 1. Types of machine learning algorithms.

A second question matters as much in a thesis: is the aim prediction or explanation? Machine learning is built to predict well, and its fitted coefficients or feature importances are not estimates of causal effects (Mullainathan & Spiess, 2017). If your research question is causal, an accurate predictor does not answer it.

Let the data shortlist the candidates

Once the task is clear, the properties of the data do most of the shortlisting. The table gives starting points, not rules.

Table 1. Data situations and candidate algorithm families
Data situationReasonable candidates to compareCaution
Small labelled sample (hundreds of cases)Regularised linear or logistic regression, small tree ensembles, k-nearest neighboursHigh-variance models overfit; validation estimates are noisy
Tabular features, medium to large sampleRandom forests, gradient-boosted trees, regularised regressionTree ensembles are strong baselines on tabular data (Breiman, 2001)
Many features relative to casesRegularised regression, support vector machines, dimensionality reduction firstFeature selection must happen inside the validation loop
Images, audio or textNeural networks, often pre-trained and fine-tunedData, compute and labelling costs are high
No labelsClustering (k-means, hierarchical, density-based), topic modelsResults depend on distance measures and settings; validate against external criteria
Very small data with physical knowledgeModels that include domain features or physical estimates as inputsDomain inputs can help but do not replace data from the regime of interest (Zhang & Ling, 2018)

Two pieces of evidence put the table in perspective. In a manufacturing study, Wu et al. (2017) compared neural networks, support vector regression and random forests for predicting tool wear and found random forests the most accurate on their data. In credit scoring, a large benchmark of classifiers showed that rankings depend on the data sets and evaluation design used (Lessmann et al., 2015). The no free lunch theorems for optimisation make the general point formally: averaged over all possible problems, no algorithm outperforms any other (Wolpert & Macready, 1997), and the practical lesson carries over to model selection.

In applied fields, frameworks for algorithm selection make the same recommendation: tie the choice to the data available and the decision the model supports (Arena et al., 2024).

Decide what accuracy you need and how to measure it

The required accuracy depends on the use. A screening model that flags cases for human review has different needs from one that makes automatic decisions. Choose the metric before you compare models.

  • Imbalanced classes. Accuracy can look high when the model ignores the rare class. Precision-recall analysis is more informative than the ROC curve in this situation (Saito & Rehmsmeier, 2015).
  • Probabilities used for decisions. Report calibration, whether predicted risks match observed frequencies, as well as discrimination (Van Calster et al., 2019).
  • Regression. Report an error measure in the outcome's units (mean absolute error or root mean squared error) alongside any relative measure.

An approximate model that is slightly less accurate but faster and easier to explain is often the right choice, provided the loss is measured and stated.

Weigh speed, resources and interpretability

Training time, prediction time and memory matter when data are large or predictions are needed in real time. Naive Bayes and logistic regression are usually fast to train; kernel support vector machines scale poorly to very large samples; deep networks need substantial compute. These are tendencies that depend on implementation and data size.

Interpretability is a design choice too. For high-stakes decisions, an inherently interpretable model that performs comparably is preferable to a black box explained after the fact (Rudin, 2019). Record compute time and hardware so that others can judge the cost of your results.

Consider also who will maintain the model after your thesis. A model that needs a graphics card, a large retraining pipeline or specialist knowledge to update may never be used by the organisation that supplied your data. If deployment is part of your contribution, include these practical constraints in your selection criteria from the start.

Parameters, hyperparameters and tuning

"Parameters" is often used for two different things. Model parameters, such as regression weights, are learned from data. Hyperparameters, such as the number of trees, the depth of a tree or a regularisation strength, are set before training and control flexibility. More flexibility can fit complex patterns but also noise.

Tuning hyperparameters is part of model selection, so it must not see the data used to estimate final performance. Choosing settings by cross-validation and then reporting that same cross-validated error gives an optimistic estimate; nested cross-validation, with tuning inside an inner loop, avoids this bias (Varma & Simon, 2006).

Putting the criteria together

The criteria interact, so it helps to apply them in a fixed order and to write the reasoning down as you go. The record becomes the justification in your methods chapter.

  1. Fix the question and the use. Prediction or explanation; who will use the output and how.
  2. Fix the evaluation design first. Decide the split (random, grouped by participant or site, or by time), the metric and the baseline before training anything. Grouped and time-ordered splits matter whenever records from the same person, place or period could appear on both sides of the split.
  3. Shortlist two to four candidate families from the task and the data (Table 1), including at least one simple, interpretable model.
  4. Set a comparable tuning budget for every candidate, so that the comparison is fair.
  5. Compare with uncertainty. Report the spread across folds or repeated runs, not a single number.
  6. Choose and explain. Prefer the simplest model whose performance is not meaningfully worse, and state the trade-off you accepted in speed, accuracy or interpretability.

Unsupervised and reinforcement learning follow the same logic with different checks. For clustering, compare solutions across algorithms and settings and test whether clusters relate to external variables they should predict. For reinforcement learning, report the environment, the reward definition and performance across several random seeds, because results can vary widely between runs.

Validate the choice so that it can be trusted

Most failures in applied machine learning are failures of validation rather than of algorithm choice. Data leakage, where information from the test data reaches training through preprocessing, feature selection, duplicated records or time order, has inflated results across many fields (Kapoor & Narayanan, 2023). Security research shows the same pitfalls, including sampling bias and inappropriate baselines (Arp et al., 2022).

Worked example (illustrative)

A doctoral researcher wants to predict which first-year students will withdraw, using 1,200 records with 30 tabular features and a 12 per cent withdrawal rate. A sensible plan is to: (1) hold out the most recent cohort as a test set, because the model will be used on future students; (2) compare a logistic regression baseline, a random forest and a gradient-boosted model; (3) tune each inside the training data with nested cross-validation; (4) report precision-recall and calibration rather than accuracy alone; and (5) prefer the simpler model if the gain from the complex one is within the uncertainty of the estimate. The numbers are hypothetical and show the reasoning only.

Table 2. What to report when you compare algorithms
ReportWhy
Candidate models and why they were chosenShows the choice was principled, not post hoc
A simple baselineShows how much the complex model adds
Data splits and how leakage was preventedLets readers trust the performance estimate (Kapoor & Narayanan, 2023)
Hyperparameter search space and procedureSupports reproducibility (Pineau et al., 2021)
Metrics with uncertaintyShows whether differences between models are meaningful
Code, versions and computeAllows the work to be repeated

Common mistakes

For metrics in more depth, see choosing and reporting evaluation metrics in a machine learning dissertation; for the business version of this question, see how to choose and justify a machine learning algorithm in business research; and for optimisation algorithms, see how to choose and benchmark a metaheuristic.

Key takeaways

Your next step

Want to apply this to your own study?

  1. 1Tell us your topic, data and deadline
  2. 2A statistician reviews your work with you
  3. 3You get a plan and a quote
Quantitative analysis

References

  1. Arena, S., Florian, E., Sgarbossa, F., Sølvsberg, E., & Zennaro, I. (2024). A conceptual framework for machine learning algorithm selection for predictive maintenance. Engineering Applications of Artificial Intelligence, 133, 108340. https://doi.org/10.1016/j.engappai.2024.108340
  2. Arp, D., Quiring, E., Pendlebury, F., Warnecke, A., Pierazzi, F., Wressnegger, C., Cavallaro, L., & Rieck, K. (2022). Dos and don'ts of machine learning in computer security. In Proceedings of the 31st USENIX Security Symposium (pp. 3971–3988). USENIX Association. https://www.usenix.org/conference/usenixsecurity22/presentation/arp
  3. Breiman, L. (2001). Random forests. Machine Learning, 45(1), 5–32. https://doi.org/10.1023/A:1010933404324
  4. Kapoor, S., & Narayanan, A. (2023). Leakage and the reproducibility crisis in machine-learning-based science. Patterns, 4(9), 100804. https://doi.org/10.1016/j.patter.2023.100804
  5. Lessmann, S., Baesens, B., Seow, H.-V., & Thomas, L. C. (2015). Benchmarking state-of-the-art classification algorithms for credit scoring: An update of research. European Journal of Operational Research, 247(1), 124–136. https://doi.org/10.1016/j.ejor.2015.05.030
  6. Lipton, Z. C., & Steinhardt, J. (2019). Troubling trends in machine learning scholarship. ACM Queue, 17(1). https://queue.acm.org/detail.cfm?id=3328534
  7. Mullainathan, S., & Spiess, J. (2017). Machine learning: An applied econometric approach. Journal of Economic Perspectives, 31(2), 87–106. https://doi.org/10.1257/jep.31.2.87
  8. Pineau, J., Vincent-Lamarre, P., Sinha, K., Larivière, V., Beygelzimer, A., d'Alché-Buc, F., Fox, E., & Larochelle, H. (2021). Improving reproducibility in machine learning research (a report from the NeurIPS 2019 reproducibility program). Journal of Machine Learning Research, 22(164), 1–20. https://www.jmlr.org/papers/v22/20-303.html
  9. Rudin, C. (2019). Stop explaining black box machine learning models for high stakes decisions and use interpretable models instead. Nature Machine Intelligence, 1(5), 206–215. https://doi.org/10.1038/s42256-019-0048-x
  10. Saito, T., & Rehmsmeier, M. (2015). The precision-recall plot is more informative than the ROC plot when evaluating binary classifiers on imbalanced datasets. PLoS ONE, 10(3), e0118432. https://doi.org/10.1371/journal.pone.0118432
  11. Van Calster, B., McLernon, D. J., van Smeden, M., Wynants, L., & Steyerberg, E. W. (2019). Calibration: The Achilles heel of predictive analytics. BMC Medicine, 17, 230. https://doi.org/10.1186/s12916-019-1466-7
  12. Varma, S., & Simon, R. (2006). Bias in error estimation when using cross-validation for model selection. BMC Bioinformatics, 7, 91. https://doi.org/10.1186/1471-2105-7-91
  13. Wolpert, D. H., & Macready, W. G. (1997). No free lunch theorems for optimization. IEEE Transactions on Evolutionary Computation, 1(1), 67–82. https://doi.org/10.1109/4235.585893
  14. Wu, D., Jennings, C., Terpenny, J., Gao, R. X., & Kumara, S. (2017). A comparative study on machine learning algorithms for smart manufacturing: Tool wear prediction using random forests. Journal of Manufacturing Science and Engineering, 139(7), 071018. https://doi.org/10.1115/1.4036350
  15. Zhang, Y., & Ling, C. (2018). A strategy to apply machine learning to small datasets in materials science. npj Computational Materials, 4, 25. https://doi.org/10.1038/s41524-018-0081-z

How to cite this article

Choose your referencing style, then copy. Check your university's or journal's guide for local variations.

PhD Research Lab Academy. (2021, August 30). How to choose a machine learning algorithm for your research: task, data, accuracy, speed and validation. PhD Research Lab. https://www.phdassistance.com/blog/selecting-the-right-type-of-algorithm-for-various-applications/

PhD Research Lab Academy. “How to Choose a Machine Learning Algorithm for Your Research: Task, Data, Accuracy, Speed and Validation.” PhD Research Lab, 30 Aug. 2021, www.phdassistance.com/blog/selecting-the-right-type-of-algorithm-for-various-applications. Accessed [access date].

PhD Research Lab Academy (2021) How to choose a machine learning algorithm for your research: task, data, accuracy, speed and validation. PhD Research Lab. Available at: https://www.phdassistance.com/blog/selecting-the-right-type-of-algorithm-for-various-applications/ (Accessed: [access date]).

PhD Research Lab Academy. “How to Choose a Machine Learning Algorithm for Your Research: Task, Data, Accuracy, Speed and Validation.” PhD Research Lab. August 30, 2021. https://www.phdassistance.com/blog/selecting-the-right-type-of-algorithm-for-various-applications.

PhD Research Lab Academy, ‘How to Choose a Machine Learning Algorithm for Your Research: Task, Data, Accuracy, Speed and Validation’ (PhD Research Lab, 30 August 2021) <https://www.phdassistance.com/blog/selecting-the-right-type-of-algorithm-for-various-applications> accessed [access date].

PhD Research Lab Academy. How to choose a machine learning algorithm for your research: task, data, accuracy, speed and validation [Internet]. PhD Research Lab; 2021 Aug 30 [cited [access date]]. Available from: https://www.phdassistance.com/blog/selecting-the-right-type-of-algorithm-for-various-applications/

PhD Research Lab Academy, “How to choose a machine learning algorithm for your research: task, data, accuracy, speed and validation,” PhD Research Lab, Aug. 30, 2021. [Online]. Available: https://www.phdassistance.com/blog/selecting-the-right-type-of-algorithm-for-various-applications. [Accessed: [access date]].

@online{selecting_the_right_type_of_algorithm_for_various_applications_2021,
  author = {{PhD Research Lab Academy}},
  title = {{How to choose a machine learning algorithm for your research: task, data, accuracy, speed and validation}},
  organization = {PhD Research Lab},
  date = {2021-08-30},
  url = {https://www.phdassistance.com/blog/selecting-the-right-type-of-algorithm-for-various-applications},
  urldate = {[access date]}
}

This article is for learning. Use it to understand the method and cite the original sources above in your own work; do not copy or submit it as your own.

How to choose a machine learning algorithm for your researchNeed help applying it to your study?
Quantitative analysis