Skip to contents

Subclass for iterated racing. Calls irace::irace() from package irace.

Source

Lopez-Ibanez M, Dubois-Lacoste J, Caceres LP, Birattari M, Stuetzle T (2016). “The irace package: Iterated racing for automatic algorithm configuration.” Operations Research Perspectives, 3, 43--58. doi:10.1016/j.orp.2016.09.002 .

Dictionary

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

tnr("irace")

Control Parameters

n_instances

integer(1)
Number of resampling instances.

For the meaning of all other parameters, see irace::defaultScenario(). Note that we have removed all control parameters which refer to the termination of the algorithm. Use TerminatorEvals instead. Other terminators do not work with TunerIrace.

Archive

The ArchiveTuning holds the following additional columns:

  • "race" (integer(1))
    Race iteration.

  • "step" (integer(1))
    Step number of race.

  • "instance" (integer(1))
    Identifies resampling instances across races and steps.

  • "configuration" (integer(1))
    Identifies configurations across races and steps.

Result

The tuning result (instance$result) is the best performing elite of the final race. The reported performance is the average performance estimated on all used instances.

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::OptimizerIrace 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::TunerFromOptimizer -> TunerIrace

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method optimize()

Performs the tuning on a TuningInstanceSingleCrit until termination. The single evaluations and the final results will be written into the ArchiveTuning that resides in the TuningInstanceSingleCrit. The final result is returned.

Usage

TunerIrace$optimize(inst)

Arguments


Method clone()

The objects of this class are cloneable with this method.

Usage

TunerIrace$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# retrieve task
task = tsk("pima")

# load learner and set search space
learner = lrn("classif.rpart", cp = to_tune(1e-04, 1e-1, logscale = TRUE))
# \donttest{
# hyperparameter tuning on the pima indians diabetes data set
instance = tune(
  tuner = tnr("irace"),
  task = task,
  learner = learner,
  resampling = rsmp("holdout"),
  measure = msr("classif.ce"),
  term_evals = 42
)
#> # 2024-03-06 08:51:28 UTC: Initialization
#> # Elitist race
#> # Elitist new instances: 1
#> # Elitist limit: 2
#> # nbIterations: 2
#> # minNbSurvival: 2
#> # nbParameters: 1
#> # seed: 1205511132
#> # confidence level: 0.95
#> # budget: 42
#> # mu: 5
#> # deterministic: FALSE
#> 
#> # 2024-03-06 08:51:28 UTC: Iteration 1 of 2
#> # experimentsUsedSoFar: 0
#> # remainingBudget: 42
#> # currentBudget: 21
#> # nbConfigurations: 3
#> # Markers:
#>      x No test is performed.
#>      c Configurations are discarded only due to capping.
#>      - The test is performed and some configurations are discarded.
#>      = The test is performed but no configuration is discarded.
#>      ! The test is performed and configurations could be discarded but elite configurations are preserved.
#>      . All alive configurations are elite and nothing is discarded
#> 
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> | |   Instance|      Alive|       Best|       Mean best| Exp so far|  W time|  rho|KenW|  Qvar|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> |x|          1|          3|          2|    0.2187500000|          3|00:00:00|   NA|  NA|    NA|
#> |x|          2|          3|          2|    0.2304687500|          6|00:00:00|+0.00|0.50|0.3710|
#> |x|          3|          3|          2|    0.2369791667|          9|00:00:00|+0.45|0.64|0.1907|
#> |x|          4|          3|          2|    0.2373046875|         12|00:00:00|-0.05|0.21|0.6853|
#> |=|          5|          3|          2|    0.2351562500|         15|00:00:00|+0.06|0.25|0.5905|
#> |=|          6|          3|          2|    0.2434895833|         18|00:00:00|-0.08|0.10|0.7186|
#> |=|          7|          3|          2|    0.2500000000|         21|00:00:00|-0.01|0.13|0.6622|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> Best-so-far configuration:           2    mean value:     0.2500000000
#> Description of the best-so-far configuration:
#>   .ID.                cp .PARENT.
#> 2    2 -2.86463783557157       NA
#> 
#> # 2024-03-06 08:51:28 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):
#>                  cp
#> 2 -2.86463783557157
#> 3 -2.40355436396728
#> # 2024-03-06 08:51:28 UTC: Iteration 2 of 2
#> # experimentsUsedSoFar: 21
#> # remainingBudget: 21
#> # currentBudget: 21
#> # nbConfigurations: 4
#> # Markers:
#>      x No test is performed.
#>      c Configurations are discarded only due to capping.
#>      - The test is performed and some configurations are discarded.
#>      = The test is performed but no configuration is discarded.
#>      ! The test is performed and configurations could be discarded but elite configurations are preserved.
#>      . All alive configurations are elite and nothing is discarded
#> 
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> | |   Instance|      Alive|       Best|       Mean best| Exp so far|  W time|  rho|KenW|  Qvar|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> |x|          8|          4|          4|    0.2539062500|          4|00:00:00|   NA|  NA|    NA|
#> |x|          6|          4|          5|    0.2656250000|          6|00:00:00|+0.27|0.63|0.5000|
#> |x|          3|          4|          4|    0.2630208333|          8|00:00:00|-0.15|0.24|0.8637|
#> |x|          1|          4|          4|    0.2519531250|         10|00:00:00|-0.12|0.16|0.8732|
#> |=|          5|          4|          4|    0.2468750000|         12|00:00:00|-0.02|0.18|0.7888|
#> |=|          4|          4|          4|    0.2454427083|         14|00:00:00|-0.11|0.08|0.8493|
#> |=|          2|          4|          4|    0.2494419643|         16|00:00:00|-0.02|0.12|0.8018|
#> |=|          7|          4|          2|    0.2534179688|         18|00:00:00|-0.07|0.07|0.8132|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> Best-so-far configuration:           2    mean value:     0.2534179688
#> Description of the best-so-far configuration:
#>   .ID.                cp .PARENT.
#> 2    2 -2.86463783557157       NA
#> 
#> # 2024-03-06 08:51:29 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):
#>                  cp
#> 2 -2.86463783557157
#> 4 -3.41642413742496
#> # 2024-03-06 08:51:29 UTC: Stopped because there is not enough budget left to race more than the minimum (2)
#> # You may either increase the budget or set 'minNbSurvival' to a lower value
#> # Iteration: 3
#> # nbIterations: 3
#> # experimentsUsedSoFar: 39
#> # timeUsed: 0
#> # remainingBudget: 3
#> # currentBudget: 3
#> # number of elites: 2
#> # nbConfigurations: 2
#> # Total CPU user time: 1.479, CPU sys time: 0, Wall-clock time: 1.48

# best performing hyperparameter configuration
instance$result
#>           cp configuration learner_param_vals  x_domain classif.ce
#>        <num>         <num>             <list>    <list>      <num>
#> 1: -2.864638             2          <list[2]> <list[1]>   0.253418

# all evaluated hyperparameter configuration
as.data.table(instance$archive)
#>            cp classif.ce  x_domain_cp runtime_learners           timestamp
#>         <num>      <num>        <num>            <num>              <POSc>
#>  1: -8.426736  0.2304688 0.0002189348            0.028 2024-03-06 08:51:28
#>  2: -2.864638  0.2187500 0.0570037721            0.010 2024-03-06 08:51:28
#>  3: -2.403554  0.2187500 0.0903960810            0.008 2024-03-06 08:51:28
#>  4: -8.426736  0.2929688 0.0002189348            0.008 2024-03-06 08:51:28
#>  5: -2.864638  0.2421875 0.0570037721            0.008 2024-03-06 08:51:28
#>  6: -2.403554  0.2968750 0.0903960810            0.007 2024-03-06 08:51:28
#>  7: -8.426736  0.2890625 0.0002189348            0.009 2024-03-06 08:51:28
#>  8: -2.864638  0.2500000 0.0570037721            0.008 2024-03-06 08:51:28
#>  9: -2.403554  0.2695312 0.0903960810            0.008 2024-03-06 08:51:28
#> 10: -8.426736  0.2226562 0.0002189348            0.009 2024-03-06 08:51:28
#> 11: -2.864638  0.2382812 0.0570037721            0.008 2024-03-06 08:51:28
#> 12: -2.403554  0.2382812 0.0903960810            0.008 2024-03-06 08:51:28
#> 13: -8.426736  0.2539062 0.0002189348            0.025 2024-03-06 08:51:28
#> 14: -2.864638  0.2265625 0.0570037721            0.011 2024-03-06 08:51:28
#> 15: -2.403554  0.2265625 0.0903960810            0.008 2024-03-06 08:51:28
#> 16: -8.426736  0.2812500 0.0002189348            0.008 2024-03-06 08:51:28
#> 17: -2.864638  0.2851562 0.0570037721            0.008 2024-03-06 08:51:28
#> 18: -2.403554  0.2851562 0.0903960810            0.008 2024-03-06 08:51:28
#> 19: -8.426736  0.3046875 0.0002189348            0.009 2024-03-06 08:51:28
#> 20: -2.864638  0.2890625 0.0570037721            0.007 2024-03-06 08:51:28
#> 21: -2.403554  0.2890625 0.0903960810            0.008 2024-03-06 08:51:28
#> 22: -2.864638  0.2773438 0.0570037721            0.009 2024-03-06 08:51:28
#> 23: -2.403554  0.2773438 0.0903960810            0.008 2024-03-06 08:51:28
#> 24: -3.416424  0.2539062 0.0328296195            0.008 2024-03-06 08:51:28
#> 25: -4.868892  0.2617188 0.0076818704            0.009 2024-03-06 08:51:28
#> 26: -3.416424  0.2851562 0.0328296195            0.008 2024-03-06 08:51:29
#> 27: -4.868892  0.2695312 0.0076818704            0.008 2024-03-06 08:51:29
#> 28: -3.416424  0.2500000 0.0328296195            0.009 2024-03-06 08:51:29
#> 29: -4.868892  0.2812500 0.0076818704            0.008 2024-03-06 08:51:29
#> 30: -3.416424  0.2187500 0.0328296195            0.008 2024-03-06 08:51:29
#> 31: -4.868892  0.2304688 0.0076818704            0.008 2024-03-06 08:51:29
#> 32: -3.416424  0.2265625 0.0328296195            0.008 2024-03-06 08:51:29
#> 33: -4.868892  0.2539062 0.0076818704            0.008 2024-03-06 08:51:29
#> 34: -3.416424  0.2382812 0.0328296195            0.008 2024-03-06 08:51:29
#> 35: -4.868892  0.2226562 0.0076818704            0.008 2024-03-06 08:51:29
#> 36: -3.416424  0.2734375 0.0328296195            0.008 2024-03-06 08:51:29
#> 37: -4.868892  0.2851562 0.0076818704            0.008 2024-03-06 08:51:29
#> 38: -3.416424  0.3281250 0.0328296195            0.008 2024-03-06 08:51:29
#> 39: -4.868892  0.3125000 0.0076818704            0.008 2024-03-06 08:51:29
#>            cp classif.ce  x_domain_cp runtime_learners           timestamp
#>     batch_nr  race  step instance configuration warnings errors
#>        <int> <num> <int>    <int>         <num>    <int>  <int>
#>  1:        1     1     1        7             1        0      0
#>  2:        1     1     1        7             2        0      0
#>  3:        1     1     1        7             3        0      0
#>  4:        2     1     1       10             1        0      0
#>  5:        2     1     1       10             2        0      0
#>  6:        2     1     1       10             3        0      0
#>  7:        3     1     1        3             1        0      0
#>  8:        3     1     1        3             2        0      0
#>  9:        3     1     1        3             3        0      0
#> 10:        4     1     1        9             1        0      0
#> 11:        4     1     1        9             2        0      0
#> 12:        4     1     1        9             3        0      0
#> 13:        5     1     1        5             1        0      0
#> 14:        5     1     1        5             2        0      0
#> 15:        5     1     1        5             3        0      0
#> 16:        6     1     1        8             1        0      0
#> 17:        6     1     1        8             2        0      0
#> 18:        6     1     1        8             3        0      0
#> 19:        7     1     1        1             1        0      0
#> 20:        7     1     1        1             2        0      0
#> 21:        7     1     1        1             3        0      0
#> 22:        8     2     1        6             2        0      0
#> 23:        8     2     1        6             3        0      0
#> 24:        8     2     1        6             4        0      0
#> 25:        8     2     1        6             5        0      0
#> 26:        9     2     1        8             4        0      0
#> 27:        9     2     1        8             5        0      0
#> 28:       10     2     1        3             4        0      0
#> 29:       10     2     1        3             5        0      0
#> 30:       11     2     1        7             4        0      0
#> 31:       11     2     1        7             5        0      0
#> 32:       12     2     1        5             4        0      0
#> 33:       12     2     1        5             5        0      0
#> 34:       13     2     1        9             4        0      0
#> 35:       13     2     1        9             5        0      0
#> 36:       14     2     1       10             4        0      0
#> 37:       14     2     1       10             5        0      0
#> 38:       15     2     1        1             4        0      0
#> 39:       15     2     1        1             5        0      0
#>     batch_nr  race  step instance configuration warnings errors
#>      resample_result
#>               <list>
#>  1: <ResampleResult>
#>  2: <ResampleResult>
#>  3: <ResampleResult>
#>  4: <ResampleResult>
#>  5: <ResampleResult>
#>  6: <ResampleResult>
#>  7: <ResampleResult>
#>  8: <ResampleResult>
#>  9: <ResampleResult>
#> 10: <ResampleResult>
#> 11: <ResampleResult>
#> 12: <ResampleResult>
#> 13: <ResampleResult>
#> 14: <ResampleResult>
#> 15: <ResampleResult>
#> 16: <ResampleResult>
#> 17: <ResampleResult>
#> 18: <ResampleResult>
#> 19: <ResampleResult>
#> 20: <ResampleResult>
#> 21: <ResampleResult>
#> 22: <ResampleResult>
#> 23: <ResampleResult>
#> 24: <ResampleResult>
#> 25: <ResampleResult>
#> 26: <ResampleResult>
#> 27: <ResampleResult>
#> 28: <ResampleResult>
#> 29: <ResampleResult>
#> 30: <ResampleResult>
#> 31: <ResampleResult>
#> 32: <ResampleResult>
#> 33: <ResampleResult>
#> 34: <ResampleResult>
#> 35: <ResampleResult>
#> 36: <ResampleResult>
#> 37: <ResampleResult>
#> 38: <ResampleResult>
#> 39: <ResampleResult>
#>      resample_result

# fit final model on complete data set
learner$param_set$values = instance$result_learner_param_vals
learner$train(task)
# }