# Hyperparameters and Tuning Strategies for Random Forest

tuneRanger tunes random forest hyperparameters with one function call

Philipp Probst, Marvin Wright, Anne-Laure Boulesteix · arXiv · 2018-4-10

- **Problem** Random forest works well with its software defaults, but the default mtry is a rule of thumb. For some datasets it is far from the best choice, leaving large error gaps.
- **Method** tuneRanger wraps model-based optimization around the ranger package. A surrogate model learns from earlier evaluations and proposes the next setting, so one call tunes mtry, sample size and node size.
- **Results** On 39 binary-target OpenML datasets, tuneRangerMMCE reached a mean misclassification error of 0.0923, compared to 0.1054 for ranger with default settings.

## Why default settings fall short

Random forest usually works reasonably well with its software defaults. The default mtry is the square root of p for classification and p/3 for regression, where p is the number of predictors. That value is a rule of thumb, and for a particular dataset it can be far from the best choice.

On monks-problems-2, an artificial dataset with six categorical predictors, the default forest's error rate is about 0.15 higher than the other algorithms. The default mtry of 2 often splits on the wrong variables, because the dependence between the categories needs the right pair to be picked. Setting mtry to 6 makes the predictions nearly perfect, so the failure comes from the setting rather than the method.

Such gains are not always this large. Across 38 datasets, Probst et al. (2018) found an average AUC gain of 0.010 from tuning compared to default values. The authors call this moderate, although it can matter when each wrongly classified observation is costly.

## How tuneRanger searches the settings

The key idea is to replace blind trial and error with a surrogate model that learns from earlier evaluations. The surrogate is fitted to all evaluated settings, and an infill criterion proposes the next candidate that has a good predicted outcome in a region not yet explored. The evaluation uses out-of-bag predictions, so no separate validation split is needed.

It then runs 70 iterative steps by default, and the user can change both numbers.

By default the function tunes mtry, sample size and node size together. mtry is sampled from 0 to p, sample size from 0.2 to 0.9 times n, and node size is drawn more often at small values. The user can narrow the set of tuned parameters or add others, such as the sampling strategy.

After the search, the package averages the best 5 percent of iterations and rounds mtry and node size. That averaged setting trains the final forest, which is returned in the result object. The default measure is the Brier score for classification, and users can switch it to another measure from mlr.

## Benchmark results against other tuners

The benchmark uses 39 binary-target OpenML datasets without missing values, split into 26 small and 13 big ones. Each method trains 2000 trees, and parallel runs use 10 CPU cores where possible.

On the mean misclassification error, tuneRangerMMCE averaged 0.0923, compared to 0.1054 for ranger default. tuneRangerBrier had the lowest mean Brier score, 0.1325, compared to 0.1604 for ranger default. Each variant does best on the measure it optimizes, although the authors note that the rank picture is less clean.

The price is runtime. ranger default averaged a training runtime of 3.8607, while mlrHyperopt averaged 2713.2438. mlrHyperopt is competitive in accuracy, but it uses 10-fold cross-validation, which the authors say makes it about ten times slower on bigger datasets.

## What tuning mtry alone misses

The authors also ran the tuneRanger variants with only mtry tuned, which isolates the value of node size and sample size. Tuning all three parameters improves the mean MMCE by 0.004 and the mean Brier score by 0.010, compared to tuning mtry alone. The authors name mtry as the most influential of the three parameters, so the extra gains are real but smaller.

The authors also ran a single-dataset check on monks-problem-1. Its tuned setting was mtry 6, minimum node size 2 and sample fraction 0.899. Under 5 times repeated 5-fold cross-validation, the error rate improved by 0.014 and the Brier score by 0.120, compared to a ranger forest with 1000 trees.

## Limits of the evidence

Out-of-bag evaluation is the source of tuneRanger's speed, but it has known blind spots. The authors report a bias in very small datasets, with n below 20, many predictor variables and balanced classes. They recommend out-of-bag tuning for most datasets, not for all of them.

All reported benchmark results are for classification on binary-target datasets without missing values. The 39 datasets come from one benchmarking suite, so the averages describe that collection only.

Some tuners failed on some datasets: mlrHyperopt on 2, caret on 4 and tuneRF on 3. Failed runs were given the worst result of the other algorithms if they failed in more than 20 percent of iterations, and otherwise missing values were imputed.

## Paper info

- **Authors**: Philipp Probst, Marvin Wright, Anne-Laure Boulesteix
- **Venue**: arXiv · Preprint
- **First published**: 2018-4-10
- **Added**: 2026-11-12
- **Updated**: 2019-2-26
- **Version**: v2
- **arXiv**: 1804.03515
- **DOI**: 10.1002/widm.1301
- **Category**: stat.ML · cs.LG
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1804.03515v2) · [PDF ↗](https://arxiv.org/pdf/1804.03515v2)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Philipp Probst, Marvin Wright, Anne-Laure Boulesteix (2018). Hyperparameters and Tuning Strategies for Random Forest. arXiv:1804.03515v2. https://doi.org/10.1002/widm.1301

**BibTeX**

```
@article{probst2018hyperparameters,
  title = {{Hyperparameters and Tuning Strategies for Random Forest}},
  author = {Philipp Probst and Marvin Wright and Anne-Laure Boulesteix},
  year = {2018},
  eprint = {1804.03515},
  archivePrefix = {arXiv},
  doi = {10.1002/widm.1301},
  url = {https://arxiv.org/abs/1804.03515v2}
}
```

## Other paper commentary

- [Federated Learning with Differential Privacy: Algorithms and Performance Analysis](https://refivu.com/en/papers/159abc6e-c571-4ed4-b7d1-e630e54b4510-federated-learning-with-differential-privacy-algorithms-and.md)
- [Tabular Data: Deep Learning is Not All You Need](https://refivu.com/en/papers/0cc42765-172d-4179-95b3-7ecf786ac425-tabular-data-deep-learning-is-not-all-you.md)
- [A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification](https://refivu.com/en/papers/f99c2916-c5f5-45e3-8503-ed9342776182-a-gentle-introduction-to-conformal-prediction-and.md)
- [European Union regulations on algorithmic decision-making and a "right to explanation"](https://refivu.com/en/papers/8d7d2fe1-f155-44ca-8f0a-551e154b6b3a-european-union-regulations-on-algorithmic-decision-making.md)
- [Robust Physical-World Attacks on Deep Learning Models](https://refivu.com/en/papers/07947804-f6f2-481e-a0c5-1e222ca2e06f-robust-physical-world-attacks-on-deep-learning-models.md)
- [Invariant Risk Minimization](https://refivu.com/en/papers/7f6a0d34-8d04-4205-b5c5-1e73e1c91b62-invariant-risk-minimization.md)
- [NLTK: The Natural Language Toolkit](https://refivu.com/en/papers/26e265b2-45d0-4d0e-b6a7-a161ecf1fe09-nltk-the-natural-language-toolkit.md)
- [One pixel attack for fooling deep neural networks](https://refivu.com/en/papers/d5d76088-1786-441c-91fa-bf247a220946-one-pixel-attack-for-fooling-deep-neural-networks.md)
- [Self-training with Noisy Student improves ImageNet classification](https://refivu.com/en/papers/57e759e6-5034-4019-9e65-3fac466f7c21-self-training-with-noisy-student-improves-imagenet.md)
- [EDA: Easy Data Augmentation Techniques for Boosting Performance on Text Classification Tasks](https://refivu.com/en/papers/6bc7db3b-907c-40de-8993-2cc4b32ed04f-eda-easy-data-augmentation-techniques-for-boosting.md)
- [PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization](https://refivu.com/en/papers/d88e659c-e7cf-4fb4-acf4-46e297868666-posenet-a-convolutional-network-for-real-time-6.md)
- [Gate-Variants of Gated Recurrent Unit (GRU) Neural Networks](https://refivu.com/en/papers/15731593-7d6d-4afb-b434-961a20dea639-gate-variants-of-gated-recurrent-unit-gru-neural.md)

## Terms in this paper

- [AUC](https://refivu.com/en/terms/017a335bbf0e-auc)
- [random forest](https://refivu.com/en/terms/e69b7b54f2ea-random-forest)
- [Random search](https://refivu.com/en/terms/4122ba3151ed-random-search)
- [regression](https://refivu.com/en/terms/239d667a7188-regression)
- [Brier score](https://refivu.com/en/terms/5fd6d59d3a08-brier-score)
- [Grid search](https://refivu.com/en/terms/92f46976faa5-grid-search)
- [Gini impurity](https://refivu.com/en/terms/f06eefc4727a-gini-impurity)
- [mtry](https://refivu.com/en/terms/19e311a0bce6-mtry)
- [sample size](https://refivu.com/en/terms/674241886f4d-sample-size)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/bd438638-5e53-476f-bacd-11a4982c1650-hyperparameters-and-tuning-strategies-for-random-forest)
