| rf_tuning | R Documentation |
Finds the optimal set of random forest hyperparameters num.trees, mtry, and min.node.size via grid search by maximizing the model's R squared, or AUC, if the response variable is binomial, via spatial cross-validation performed with rf_evaluate().
rf_tuning(
model = NULL,
num.trees = NULL,
mtry = NULL,
min.node.size = NULL,
xy = NULL,
repetitions = 30,
training.fraction = 0.75,
seed = 1,
verbose = TRUE,
n.cores = parallel::detectCores() - 1,
cluster = NULL
)
model |
A model fitted with |
num.trees |
Numeric integer vector with the number of trees to fit on each model repetition. Default: |
mtry |
Numeric integer vector, number of predictors to randomly select from the complete pool of predictors on each tree split. Default: |
min.node.size |
Numeric integer, minimal number of cases in a terminal node. Default: |
xy |
Data frame or matrix with two columns containing coordinates and named "x" and "y". If |
repetitions |
Integer, number of independent spatial folds to use during the cross-validation. Default: |
training.fraction |
Proportion between 0.2 and 0.9 indicating the number of records to be used in model training. Default: |
seed |
Integer, random seed to facilitate reproduciblity. If set to a given number, the results of the function are always the same. Default: |
verbose |
Logical. If TRUE, messages and plots generated during the execution of the function are displayed, Default: |
n.cores |
Integer, number of cores to use for parallel execution. Creates a socket cluster with |
cluster |
A cluster definition generated with |
A model with a new slot named tuning, with a data frame with the results of the tuning analysis.
rf_evaluate()
Other model_workflow:
rf_compare(),
rf_evaluate(),
rf_importance(),
rf_repeat()
if(interactive()){
data(
plants_rf,
plants_xy
)
plants_rf_tuned <- rf_tuning(
model = plants_rf,
num.trees = c(25, 50),
mtry = c(5, 10),
min.node.size = c(10, 20),
xy = plants_xy,
repetitions = 5,
n.cores = 1
)
plot_tuning(plants_rf_tuned)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.