Skip to contents

Subclass for Covariance Matrix Adaptation Evolution Strategy (CMA-ES). Calls adagio::pureCMAES() from package adagio.

Source

Hansen N (2016). “The CMA Evolution Strategy: A Tutorial.” 1604.00772.

Dictionary

This Tuner can be instantiated with the associated sugar function tnr():

tnr("cmaes")

Control Parameters

start_values

character(1)
Create random start values or based on center 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.

The cheatsheet summarizes the most important functions of mlr3tuning.

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method clone()

The objects of this class are cloneable with this method.

Usage

TunerBatchCmaes$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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: -7.336334  15.20906 107.2338          <list[4]> <list[3]> 0.07826087

# all evaluated hyperparameter configuration
as.data.table(instance$archive)
#>            cp minbucket  minsplit classif.ce runtime_learners
#>         <num>     <num>     <num>      <num>            <num>
#>  1: -7.336334 15.209063 107.23382 0.07826087            0.007
#>  2: -9.210340 64.000000  22.89758 0.12173913            0.006
#>  3: -2.621780 31.763900 128.00000 0.07826087            0.005
#>  4: -2.302585  1.000000 106.26335 0.07826087            0.005
#>  5: -2.302585 62.039211 128.00000 0.12173913            0.006
#>  6: -4.416664 54.268412 108.94055 0.07826087            0.005
#>  7: -2.302585  4.755131  72.28910 0.07826087            0.006
#>  8: -4.734599 30.835601  24.51517 0.07826087            0.005
#>  9: -9.210340 39.906483  97.63893 0.07826087            0.005
#> 10: -6.242816 18.946310  96.50841 0.07826087            0.007
#>               timestamp warnings errors  x_domain batch_nr  resample_result
#>                  <POSc>    <int>  <int>    <list>    <int>           <list>
#>  1: 2024-12-18 10:06:54        0      0 <list[3]>        1 <ResampleResult>
#>  2: 2024-12-18 10:06:54        0      0 <list[3]>        2 <ResampleResult>
#>  3: 2024-12-18 10:06:54        0      0 <list[3]>        3 <ResampleResult>
#>  4: 2024-12-18 10:06:54        0      0 <list[3]>        4 <ResampleResult>
#>  5: 2024-12-18 10:06:54        0      0 <list[3]>        5 <ResampleResult>
#>  6: 2024-12-18 10:06:54        0      0 <list[3]>        6 <ResampleResult>
#>  7: 2024-12-18 10:06:54        0      0 <list[3]>        7 <ResampleResult>
#>  8: 2024-12-18 10:06:54        0      0 <list[3]>        8 <ResampleResult>
#>  9: 2024-12-18 10:06:54        0      0 <list[3]>        9 <ResampleResult>
#> 10: 2024-12-18 10:06:54        0      0 <list[3]>       10 <ResampleResult>

# fit final model on complete data set
learner$param_set$values = instance$result_learner_param_vals
learner$train(tsk("penguins"))