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 bbotk::TerminatorEvals instead. Other terminators do not work with TunerIrace.

Archive

The ArchiveBatchTuning 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 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::OptimizerBatchIrace 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.

  • An overview of all tuners can be found on our website.

  • Learn more about tuners.

The gallery features a collection of case studies and demos about optimization.

  • Use the Hyperband optimizer with different budget parameters.

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage


Method optimize()

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

Usage

TunerBatchIrace$optimize(inst)

Arguments


Method clone()

The objects of this class are cloneable with this method.

Usage

TunerBatchIrace$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-07-24 10:53:21 UTC: Initialization
#> # Elitist race
#> # Elitist new instances: 1
#> # Elitist limit: 2
#> # nbIterations: 2
#> # minNbSurvival: 2
#> # nbParameters: 1
#> # seed: 805011569
#> # confidence level: 0.95
#> # budget: 42
#> # mu: 5
#> # deterministic: FALSE
#> 
#> # 2024-07-24 10:53:21 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|          1|    0.2695312500|          3|00:00:00|   NA|  NA|    NA|
#> |x|          2|          3|          1|    0.2734375000|          6|00:00:00|+1.00|1.00|0.0000|
#> |x|          3|          3|          1|    0.2955729167|          9|00:00:00|+1.00|1.00|0.0000|
#> |x|          4|          3|          1|    0.2822265625|         12|00:00:00|+1.00|1.00|0.0000|
#> |=|          5|          3|          1|    0.2750000000|         15|00:00:00|+1.00|1.00|0.0000|
#> |=|          6|          3|          1|    0.2649739583|         18|00:00:00|+1.00|1.00|0.0000|
#> |=|          7|          3|          1|    0.2700892857|         21|00:00:00|+1.00|1.00|0.0000|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> Best-so-far configuration:           1    mean value:     0.2700892857
#> Description of the best-so-far configuration:
#>   .ID.                cp .PARENT.
#> 1    1 -6.02078412568282       NA
#> 
#> # 2024-07-24 10:53:22 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):
#>                  cp
#> 1 -6.02078412568282
#> 2 -8.98661062173970
#> # 2024-07-24 10:53:22 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|          1|    0.2539062500|          4|00:00:00|   NA|  NA|    NA|
#> |x|          4|          4|          1|    0.2480468750|          6|00:00:00|-0.27|0.37|0.7500|
#> |x|          1|          4|          1|    0.2552083333|          8|00:00:00|-0.29|0.14|1.0000|
#> |x|          3|          4|          5|    0.2685546875|         10|00:00:00|-0.10|0.18|0.8750|
#> |=|          6|          4|          1|    0.2640625000|         12|00:00:00|-0.18|0.05|0.9000|
#> |=|          2|          4|          5|    0.2571614583|         14|00:00:00|-0.12|0.07|0.8522|
#> |=|          7|          4|          5|    0.2578125000|         16|00:00:00|-0.03|0.12|0.7993|
#> |=|          5|          4|          5|    0.2602539062|         18|00:00:00|-0.10|0.04|0.8368|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> Best-so-far configuration:           5    mean value:     0.2602539062
#> Description of the best-so-far configuration:
#>   .ID.                cp .PARENT.
#> 5    5 -3.55350677183612        1
#> 
#> # 2024-07-24 10:53:23 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):
#>                  cp
#> 5 -3.55350677183612
#> 1 -6.02078412568282
#> # 2024-07-24 10:53:23 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.591, CPU sys time: 0.008, Wall-clock time: 1.6

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

# all evaluated hyperparameter configuration
as.data.table(instance$archive)
#>            cp classif.ce  x_domain_cp runtime_learners           timestamp
#>         <num>      <num>        <num>            <num>              <POSc>
#>  1: -6.020784  0.2695312 0.0024277652            0.009 2024-07-24 10:53:21
#>  2: -8.986611  0.2695312 0.0001250733            0.009 2024-07-24 10:53:21
#>  3: -5.962286  0.2695312 0.0025740218            0.009 2024-07-24 10:53:21
#>  4: -6.020784  0.2773438 0.0024277652            0.009 2024-07-24 10:53:21
#>  5: -8.986611  0.2773438 0.0001250733            0.009 2024-07-24 10:53:21
#>  6: -5.962286  0.2773438 0.0025740218            0.009 2024-07-24 10:53:21
#>  7: -6.020784  0.3398438 0.0024277652            0.009 2024-07-24 10:53:21
#>  8: -8.986611  0.3398438 0.0001250733            0.009 2024-07-24 10:53:21
#>  9: -5.962286  0.3398438 0.0025740218            0.010 2024-07-24 10:53:21
#> 10: -6.020784  0.2421875 0.0024277652            0.009 2024-07-24 10:53:21
#> 11: -8.986611  0.2421875 0.0001250733            0.009 2024-07-24 10:53:21
#> 12: -5.962286  0.2421875 0.0025740218            0.009 2024-07-24 10:53:21
#> 13: -6.020784  0.2460938 0.0024277652            0.009 2024-07-24 10:53:22
#> 14: -8.986611  0.2460938 0.0001250733            0.009 2024-07-24 10:53:22
#> 15: -5.962286  0.2460938 0.0025740218            0.009 2024-07-24 10:53:22
#> 16: -6.020784  0.2148438 0.0024277652            0.009 2024-07-24 10:53:22
#> 17: -8.986611  0.2148438 0.0001250733            0.009 2024-07-24 10:53:22
#> 18: -5.962286  0.2148438 0.0025740218            0.007 2024-07-24 10:53:22
#> 19: -6.020784  0.3007812 0.0024277652            0.009 2024-07-24 10:53:22
#> 20: -8.986611  0.3007812 0.0001250733            0.007 2024-07-24 10:53:22
#> 21: -5.962286  0.3007812 0.0025740218            0.009 2024-07-24 10:53:22
#> 22: -6.020784  0.2539062 0.0024277652            0.009 2024-07-24 10:53:22
#> 23: -8.986611  0.2656250 0.0001250733            0.008 2024-07-24 10:53:22
#> 24: -5.355310  0.2656250 0.0047230049            0.007 2024-07-24 10:53:22
#> 25: -3.553507  0.2617188 0.0286240853            0.009 2024-07-24 10:53:22
#> 26: -5.355310  0.2421875 0.0047230049            0.010 2024-07-24 10:53:22
#> 27: -3.553507  0.2617188 0.0286240853            0.007 2024-07-24 10:53:22
#> 28: -5.355310  0.2695312 0.0047230049            0.008 2024-07-24 10:53:22
#> 29: -3.553507  0.2617188 0.0286240853            0.008 2024-07-24 10:53:22
#> 30: -5.355310  0.3398438 0.0047230049            0.009 2024-07-24 10:53:22
#> 31: -3.553507  0.2890625 0.0286240853            0.008 2024-07-24 10:53:22
#> 32: -5.355310  0.2148438 0.0047230049            0.009 2024-07-24 10:53:22
#> 33: -3.553507  0.2343750 0.0286240853            0.007 2024-07-24 10:53:22
#> 34: -5.355310  0.2734375 0.0047230049            0.009 2024-07-24 10:53:22
#> 35: -3.553507  0.2343750 0.0286240853            0.008 2024-07-24 10:53:22
#> 36: -5.355310  0.2812500 0.0047230049            0.009 2024-07-24 10:53:22
#> 37: -3.553507  0.2617188 0.0286240853            0.007 2024-07-24 10:53:22
#> 38: -5.355310  0.2500000 0.0047230049            0.009 2024-07-24 10:53:23
#> 39: -3.553507  0.2773438 0.0286240853            0.008 2024-07-24 10:53:23
#>            cp classif.ce  x_domain_cp runtime_learners           timestamp
#>      race  step instance configuration warnings errors batch_nr
#>     <num> <int>    <int>         <num>    <int>  <int>    <int>
#>  1:     1     1        4             1        0      0        1
#>  2:     1     1        4             2        0      0        1
#>  3:     1     1        4             3        0      0        1
#>  4:     1     1        6             1        0      0        2
#>  5:     1     1        6             2        0      0        2
#>  6:     1     1        6             3        0      0        2
#>  7:     1     1        8             1        0      0        3
#>  8:     1     1        8             2        0      0        3
#>  9:     1     1        8             3        0      0        3
#> 10:     1     1        2             1        0      0        4
#> 11:     1     1        2             2        0      0        4
#> 12:     1     1        2             3        0      0        4
#> 13:     1     1        3             1        0      0        5
#> 14:     1     1        3             2        0      0        5
#> 15:     1     1        3             3        0      0        5
#> 16:     1     1       10             1        0      0        6
#> 17:     1     1       10             2        0      0        6
#> 18:     1     1       10             3        0      0        6
#> 19:     1     1        5             1        0      0        7
#> 20:     1     1        5             2        0      0        7
#> 21:     1     1        5             3        0      0        7
#> 22:     2     1        7             1        0      0        8
#> 23:     2     1        7             2        0      0        8
#> 24:     2     1        7             4        0      0        8
#> 25:     2     1        7             5        0      0        8
#> 26:     2     1        2             4        0      0        9
#> 27:     2     1        2             5        0      0        9
#> 28:     2     1        4             4        0      0       10
#> 29:     2     1        4             5        0      0       10
#> 30:     2     1        8             4        0      0       11
#> 31:     2     1        8             5        0      0       11
#> 32:     2     1       10             4        0      0       12
#> 33:     2     1       10             5        0      0       12
#> 34:     2     1        6             4        0      0       13
#> 35:     2     1        6             5        0      0       13
#> 36:     2     1        5             4        0      0       14
#> 37:     2     1        5             5        0      0       14
#> 38:     2     1        3             4        0      0       15
#> 39:     2     1        3             5        0      0       15
#>      race  step instance configuration warnings errors batch_nr
#>      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)
# }