Tune Random Forest of the 'ranger' Package

Tuning random forest with one line. The package is mainly based on the packages 'ranger' and 'mlrMBO'.

Philipp Probst


tuneRanger is a package for automatic tuning of random forests with one line of code and intended for users that want to get the best out of their random forest model.

Model based optimization is used as tuning strategy and the three parameters min.node.size, sample.fraction and mtry are tuned at once. Out-of-bag predictions are used for evaluation, which makes it much faster than other packages and tuning strategies that use for example 5-fold cross-validation. Classification as well as regression is supported.

The measure that should be optimized can be chosen from the list of measures in mlr: https://mlr-org.github.io/mlr/articles/measures.html

The package is mainly based on ranger, mlrMBO and mlr.

The package is also described in an arXiv-Paper: https://arxiv.org/abs/1804.03515

Please cite the paper, if you use the package:

  author = {Probst, Philipp and Wright, Marvin and Boulesteix, Anne-Laure}, 
  title = {Hyperparameters and Tuning Strategies for Random Forest},
  journal = {ArXiv preprint arXiv:1804.03515},
  archivePrefix = "arXiv",
  eprint = {1804.03515},
  primaryClass = "stat.ML",
  keywords = {Statistics - Machine Learning, Computer Science - Learning},
  year = 2018,
  url = {https://arxiv.org/abs/1804.03515}


The development version







# A mlr task has to be created in order to use the package
# We make an mlr task with the iris dataset here 
# (Classification task with makeClassifTask, Regression Task with makeRegrTask)
iris.task = makeClassifTask(data = iris, target = "Species")

# Rough Estimation of the Tuning time

# Tuning process (takes around 1 minute); Tuning measure is the multiclass brier score
res = tuneRanger(iris.task, measure = list(multiclass.brier), num.trees = 1000, 
             num.threads = 2, iters = 70)

# Mean of best 5 % of the results
# Model with the new tuned hyperparameters

# Restart after failing in one of the iterations:
res = restartTuneRanger("./optpath.RData", iris.task, measure = list(multiclass.brier))


Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.5 by Philipp Probst, 2 years ago

Browse source code at https://github.com/cran/tuneRanger

Authors: Philipp Probst [aut, cre] , Simon Klau [ctb]

Documentation:   PDF Manual  

GPL-3 license

Imports mlr, smoof, ParamHelpers, methods, BBmisc, DiceKriging

Depends on ranger, mlrMBO, parallel, lubridate, lhs

Suggests survival, testthat

See at CRAN