Grid search to optimise hyperparameters for FUN
gridsearch(x, y, searchspace, FUN, nfolds = 5, nrepcv = 2, ...)matrix/data.frame, feature matrix, see ranger() for
details.
numeric/factor, classification labels, see ranger() for
details.
data.frame, hyperparameters to tune. Column names have
to match the argument names of FUN.
function function to optimize.
integer(1) number of cross validation folds.
integer(1) number of repeats.
further arguments passed to FUN
data.frame with tested hyperparameters and metric
iris <- subset(iris, Species != "setosa")
searchspace <- expand.grid(
mtry = c(2, 3),
num.trees = c(500, 1000)
)
## nfolds and nrepcv are too low for real world applications, and are just
## used for demonstration and to keep the run time of the examples low
gs_rusranger(
iris[-5], as.numeric(iris$Species == "versicolor"),
searchspace = searchspace, nfolds = 3, nrepcv = 1
)
#> mtry num.trees Min Q1 Median Q3 Max
#> 1 2 500 0.00781250 0.00781250 0.00781250 0.00781250 0.00781250
#> 2 3 500 0.00390625 0.00390625 0.00390625 0.00390625 0.00390625
#> 3 2 1000 0.01384083 0.01384083 0.01384083 0.01384083 0.01384083
#> 4 3 1000 0.02249135 0.02249135 0.02249135 0.02249135 0.02249135