Tuning Spaces of the mlr3 ecosystem.
The package mlr3tuningspaces ships with some predefined tuning spaces for hyperparameter optimization. See the respective manual page for the article from which they were extracted.
Load a tuning space for the classification tree
learner from the Bischl et al. (2021) article.
library(mlr3verse)
# load learner and set search space
learner = lts(lrn("classif.rpart"))
# retrieve task
task = tsk("pima")
# load tuner and set batch size
tuner = tnr("random_search", batch_size = 10)
# hyperparameter tuning on the pima data set
instance = tune(
method = tnr("grid_search", resolution = 5, batch_size = 25),
task = task,
learner = learner,
resampling = rsmp("holdout"),
measure = msr("classif.ce"),
)
# best performing hyperparameter configuration
instance$result
minsplit minbucket cp learner_param_vals x_domain
1: 0.6931472 3.13079 -2.302585 <list[4]> <list[3]>
classif.ce
1: 0.203125
# fit final model on complete data set
learner$param_set$values = instance$result_learner_param_vals
learner$train(task)