Similar to tuneRF in randomForest
but for ranger
.
tuneMtryFast(formula = NULL, data = NULL,
dependent.variable.name = NULL, mtryStart = floor(sqrt(ncol(data) -
1)), num.treesTry = 50, stepFactor = 2, improve = 0.05,
trace = TRUE, plot = TRUE, doBest = FALSE, ...)
If doBest=FALSE (default), it returns a matrix whose first column contains the mtry values searched, and the second column the corresponding OOB error.
If doBest=TRUE, it returns the ranger
object produced with the optimal mtry.
Object of class formula or character describing the model to fit. Interaction terms supported only for numerical variables.
Training data of class data.frame, matrix, dgCMatrix (Matrix) or gwaa.data (GenABEL).
Name of dependent variable, needed if no formula given. For survival forests this is the time variable.
starting value of mtry; default is the same as in ranger
number of trees used at the tuning step
at each iteration, mtry is inflated (or deflated) by this value
the (relative) improvement in OOB error must be by this much for the search to continue
whether to print the progress of the search
whether to plot the OOB error as function of mtry
whether to run a forest using the optimal mtry found
options to be given to ranger
Provides fast tuning for the mtry hyperparameter.
Starting with the default value of mtry, search for the optimal value (with respect to Out-of-Bag error estimate) of mtry for randomForest.
library(tuneRanger)
data(iris)
res <- tuneMtryFast(Species ~ ., data = iris, stepFactor = 1.5)
Run the code above in your browser using DataLab