Hyperparameters and tuning strategies for random forest
Philipp ProbstMarvin WrightAnne-Laure Boulesteix
Evaluates the impact of random forest hyperparameters on prediction performance and variable importance, offering practical tuning strategies and the automated tuneRanger R package to optimize model accuracy.
Random Forest is widely recognized as an effective and reliable machine learning method that performs reasonably well out of the box. However, practitioners often struggle to determine whether adjusting its core settings—known as hyperparameters—yields enough accuracy gains to justify the extra computational effort. Clear, unified guidance has been lacking in the broader scientific literature regarding how individual parameters behave and how to systematically optimize them.
The article evaluates the practical impact of Random Forest hyperparameters on prediction performance and variable importance measures. It also introduces a practical tuning strategy based on sequential model-based optimization and benchmarks this approach against default configurations and existing automated software packages.
The authors conducted a structured literature review alongside an empirical benchmark across 39 real-world classification datasets from the OpenML platform. The study compared several tuning implementations in R, examining classification error rates, discrimination metrics, probabilistic loss measures, and execution runtimes under repeated cross-validation.
The findings show that Random Forest gains a modest but valuable performance improvement from hyperparameter tuning, reducing classification errors by an average of about 1.3 percentage points compared to default package settings. The number of candidate splitting variables (mtry) is the most influential tuning parameter, whereas the total number of trees is not a tuning parameter and should simply be set sufficiently high (typically 500 to 2,000) until performance stabilizes. Simultaneous tuning of the candidate splitting variables, node size, and sample size consistently outperforms tuning the splitting variables alone. Furthermore, the article demonstrates that using sequential model-based optimization paired with internal out-of-bag validation provides top-tier predictive accuracy while executing significantly faster on larger datasets than cross-validation-based tuning tools like mlrHyperopt.
These results demonstrate that organizations deploying Random Forest in high-stakes environments—such as fraud detection, medical risk scoring, or credit underwriting—can capture meaningful predictive and financial gains through systematic tuning. Even moderate reductions in classification error can lower costs and risks substantially. While the default settings serve as a solid baseline, automated optimization avoids the risk of severe underperformance on complex datasets where standard defaults fail to uncover multi-variable interactions.
Practitioners are advised to adopt sequential model-based optimization to simultaneously tune the candidate variable count, node size, and sample size, utilizing the provided tuneRanger tool or comparable out-of-bag optimization workflows. When computational budgets are extremely limited, lightweight options such as tuneRF offer a fast compromise by focusing solely on candidate splitting variables. Future research should prioritize neutral, large-scale empirical studies comparing algorithmic variants and investigating how hyperparameters impact the reliability of variable importance rankings.
The primary limitations include the study's focus on binary classification tasks and the known risk of slight out-of-bag estimation bias in extremely small sample sizes (under 20 observations). Confidence in the findings is high for standard operational dataset sizes, but caution is warranted when interpreting variable importance rankings derived under biased default splitting rules.
- Paper: Random Forests, Leo Breiman (2001). Introduces the foundational Random Forest algorithm whose essential hyperparameters and operational mechanisms form the central subject of the review.
- Paper: ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R, Marvin N. Wright et al. (2015). Introduces the fast C++ and R implementation 'ranger', which serves as the core computational engine and baseline library tuned by the source's tuneRanger package.
- Paper: Practical Bayesian Optimization of Machine Learning Algorithms, Jasper Snoek et al. (2012). Presents practical sequential model-based optimization methods that provide the algorithmic principles underlying the Bayesian tuning strategies implemented in tuneRanger.
- Paper: A random forest guided tour, Gérard Biau et al. (2015). Provides an extensive theoretical survey of random forests, their splitting mechanics, and variable importance measures examined throughout the source's literature review.
- Paper: Random Search for Hyper-Parameter Optimization, James Bergstra et al. (2012). Establishes random search as an efficient baseline for hyperparameter optimization compared against model-based optimization in the source's benchmarking.
- Paper: Do we need hundreds of classifiers to solve real world classification problems?, Manuel Fernández Delgado et al. (2014). Demonstrates the strong default predictive performance of random forests across extensive benchmark datasets, motivating why and when tuning provides incremental gains.
- Paper: On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation, G. Cawley et al. (2010). Analyzes the statistical risks of overfitting and selection bias during hyperparameter tuning on validation datasets, addressing key concerns in tuning strategy design.
- Paper: On Hyperparameter Optimization of Machine Learning Algorithms: Theory and Practice, Li Yang et al. (2020). Surveys and benchmarks modern hyperparameter optimization strategies across diverse machine learning algorithms, expanding beyond random forests to broader model families.
- Paper: A comparative analysis of gradient boosting algorithms, Candice Bentéjac et al. (2019). Extends the comparative study of tree-ensemble hyperparameter tuning and performance to modern gradient boosting algorithms against random forest baselines.
- Paper: Tabular Data: Deep Learning is Not All You Need, Ravid Shwartz-Ziv et al. (2021). Evaluates tuned tree ensembles against modern deep learning architectures on tabular datasets to benchmark competitive practical performance.
