
Hyperparameter Tuning with Covariance Matrix Adaptation Evolution Strategy
Source:R/TunerCmaes.R
mlr_tuners_cmaes.Rd
Subclass for Covariance Matrix Adaptation Evolution Strategy (CMA-ES).
Calls adagio::pureCMAES()
from package adagio.
Control Parameters
start_values
character(1)
Createrandom
start values or based oncenter
of search space? In the latter case, it is the center of the parameters before a trafo is applied.
For the meaning of the control parameters, see adagio::pureCMAES()
.
Note that we have removed all control parameters which refer to the termination of the algorithm and where our terminators allow to obtain the same behavior.
Progress Bars
$optimize()
supports progress bars via the package progressr
combined with a Terminator. Simply wrap the function in
progressr::with_progress()
to enable them. We recommend to use package
progress as backend; enable with progressr::handlers("progress")
.
Logging
All Tuners use a logger (as implemented in lgr) from package
bbotk.
Use lgr::get_logger("bbotk")
to access and control the logger.
Optimizer
This Tuner is based on bbotk::OptimizerCmaes which can be applied on any black box optimization problem. See also the documentation of bbotk.
Resources
book section on tuners.
mlr3hyperband extension package for the Hyperband algorithm.
Super classes
mlr3tuning::Tuner
-> mlr3tuning::TunerFromOptimizer
-> TunerCmaes
Examples
# Hyperparameter Optimization
# load learner and set search space
learner = lrn("classif.rpart",
cp = to_tune(1e-04, 1e-1, logscale = TRUE),
minsplit = to_tune(p_dbl(2, 128, trafo = as.integer)),
minbucket = to_tune(p_dbl(1, 64, trafo = as.integer))
)
# run hyperparameter tuning on the Palmer Penguins data set
instance = tune(
method = tnr("cmaes"),
task = tsk("penguins"),
learner = learner,
resampling = rsmp("holdout"),
measure = msr("classif.ce"),
term_evals = 10)
# best performing hyperparameter configuration
instance$result
#> cp minsplit minbucket learner_param_vals x_domain classif.ce
#> 1: -9.21034 35.35649 34.25562 <list[4]> <list[3]> 0.04347826
# all evaluated hyperparameter configuration
as.data.table(instance$archive)
#> cp minsplit minbucket classif.ce x_domain_cp x_domain_minsplit
#> 1: -2.302585 108.112062 64.000000 0.10434783 0.100000000 108
#> 2: -9.210340 35.356493 34.255616 0.04347826 0.000100000 35
#> 3: -2.302585 9.697157 46.044377 0.04347826 0.100000000 9
#> 4: -2.302585 25.401639 63.205350 0.10434783 0.100000000 25
#> 5: -2.302585 128.000000 12.347091 0.04347826 0.100000000 128
#> 6: -4.896475 128.000000 64.000000 0.10434783 0.007472875 128
#> 7: -4.746180 122.589603 64.000000 0.10434783 0.008684809 122
#> 8: -9.210340 2.000000 8.692479 0.04347826 0.000100000 2
#> 9: -2.302585 15.495505 64.000000 0.10434783 0.100000000 15
#> 10: -6.566245 79.230407 25.393594 0.04347826 0.001407071 79
#> x_domain_minbucket runtime_learners timestamp batch_nr warnings
#> 1: 64 0.012 2022-12-22 07:40:12 1 0
#> 2: 34 0.011 2022-12-22 07:40:12 2 0
#> 3: 46 0.011 2022-12-22 07:40:12 3 0
#> 4: 63 0.011 2022-12-22 07:40:12 4 0
#> 5: 12 0.012 2022-12-22 07:40:13 5 0
#> 6: 64 0.013 2022-12-22 07:40:13 6 0
#> 7: 64 0.012 2022-12-22 07:40:13 7 0
#> 8: 8 0.011 2022-12-22 07:40:13 8 0
#> 9: 64 0.012 2022-12-22 07:40:13 9 0
#> 10: 25 0.012 2022-12-22 07:40:13 10 0
#> errors resample_result
#> 1: 0 <ResampleResult[21]>
#> 2: 0 <ResampleResult[21]>
#> 3: 0 <ResampleResult[21]>
#> 4: 0 <ResampleResult[21]>
#> 5: 0 <ResampleResult[21]>
#> 6: 0 <ResampleResult[21]>
#> 7: 0 <ResampleResult[21]>
#> 8: 0 <ResampleResult[21]>
#> 9: 0 <ResampleResult[21]>
#> 10: 0 <ResampleResult[21]>
# fit final model on complete data set
learner$param_set$values = instance$result_learner_param_vals
learner$train(tsk("penguins"))