Hyperparameter Tuning with Covariance Matrix Adaptation Evolution Strategy
Source:R/TunerBatchCmaes.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 bbotk::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::OptimizerBatchCmaes which can be applied on any black box optimization problem. See also the documentation of bbotk.
Resources
There are several sections about hyperparameter optimization in the mlr3book.
The gallery features a collection of case studies and demos about optimization.
Use the Hyperband optimizer with different budget parameters.
Super classes
mlr3tuning::Tuner
-> mlr3tuning::TunerBatch
-> mlr3tuning::TunerBatchFromOptimizerBatch
-> TunerBatchCmaes
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(
tuner = tnr("cmaes"),
task = tsk("penguins"),
learner = learner,
resampling = rsmp("holdout"),
measure = msr("classif.ce"),
term_evals = 10)
# best performing hyperparameter configuration
instance$result
#> cp minbucket minsplit learner_param_vals x_domain classif.ce
#> <num> <num> <num> <list> <list> <num>
#> 1: -2.302585 18.54552 102.0216 <list[4]> <list[3]> 0.07826087
# all evaluated hyperparameter configuration
as.data.table(instance$archive)
#> cp minbucket minsplit classif.ce x_domain_cp x_domain_minbucket
#> <num> <num> <num> <num> <num> <int>
#> 1: -9.071539 55.670870 128.00000 0.10434783 0.0001148896 55
#> 2: -2.302585 18.545516 102.02161 0.07826087 0.1000000000 18
#> 3: -6.928636 64.000000 128.00000 0.13913043 0.0009793354 64
#> 4: -4.101324 35.825608 128.00000 0.07826087 0.0165507468 35
#> 5: -8.413512 1.000000 128.00000 0.07826087 0.0002218493 1
#> 6: -4.024649 64.000000 91.40801 0.13913043 0.0178696947 64
#> 7: -6.359513 35.189353 128.00000 0.07826087 0.0017302090 35
#> 8: -2.464699 57.818568 128.00000 0.11304348 0.0850344183 57
#> 9: -7.284711 1.069881 128.00000 0.07826087 0.0006859466 1
#> 10: -2.302585 50.401641 128.00000 0.07826087 0.1000000000 50
#> x_domain_minsplit runtime_learners timestamp warnings errors
#> <int> <num> <POSc> <int> <int>
#> 1: 128 0.006 2024-09-11 07:59:34 0 0
#> 2: 102 0.005 2024-09-11 07:59:34 0 0
#> 3: 128 0.006 2024-09-11 07:59:34 0 0
#> 4: 128 0.007 2024-09-11 07:59:34 0 0
#> 5: 128 0.005 2024-09-11 07:59:34 0 0
#> 6: 91 0.005 2024-09-11 07:59:35 0 0
#> 7: 128 0.006 2024-09-11 07:59:35 0 0
#> 8: 128 0.005 2024-09-11 07:59:35 0 0
#> 9: 128 0.006 2024-09-11 07:59:35 0 0
#> 10: 128 0.005 2024-09-11 07:59:35 0 0
#> batch_nr resample_result
#> <int> <list>
#> 1: 1 <ResampleResult>
#> 2: 2 <ResampleResult>
#> 3: 3 <ResampleResult>
#> 4: 4 <ResampleResult>
#> 5: 5 <ResampleResult>
#> 6: 6 <ResampleResult>
#> 7: 7 <ResampleResult>
#> 8: 8 <ResampleResult>
#> 9: 9 <ResampleResult>
#> 10: 10 <ResampleResult>
# fit final model on complete data set
learner$param_set$values = instance$result_learner_param_vals
learner$train(tsk("penguins"))