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

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(
  method = "irace",
  task = task,
  learner = learner,
  resampling = rsmp("holdout"),
  measure = msr("classif.ce"),
  term_evals = 42
)
#> # 2022-11-18 12:12:10 UTC: Initialization
#> # Elitist race
#> # Elitist new instances: 1
#> # Elitist limit: 2
#> # nbIterations: 2
#> # minNbSurvival: 2
#> # nbParameters: 1
#> # seed: 1024577473
#> # confidence level: 0.95
#> # budget: 42
#> # mu: 5
#> # deterministic: FALSE
#> 
#> # 2022-11-18 12:12:10 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.2539062500|          3|00:00:00|   NA|  NA|    NA|
#> |x|          2|          3|          1|    0.2695312500|          6|00:00:00|-1.00|0.00|1.3333|
#> |x|          3|          3|          1|    0.2604166667|          9|00:00:00|-0.33|0.11|0.8889|
#> |x|          4|          3|          1|    0.2675781250|         12|00:00:00|-0.33|0.00|0.8889|
#> |=|          5|          3|          2|    0.2585937500|         15|00:00:00|-0.20|0.04|0.8000|
#> |=|          6|          3|          2|    0.2526041667|         18|00:00:00|-0.07|0.11|0.7111|
#> |=|          7|          3|          2|    0.2511160714|         21|00:00:00|+0.05|0.18|0.6349|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> Best-so-far configuration:           2    mean value:     0.2511160714
#> Description of the best-so-far configuration:
#>   .ID.                cp .PARENT.
#> 2    2 -2.88671306171978       NA
#> 
#> # 2022-11-18 12:12:12 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):
#>                  cp
#> 2 -2.88671306171978
#> 3 -2.54683773296070
#> # 2022-11-18 12:12:12 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|          5|    0.2460937500|          4|00:00:00|   NA|  NA|    NA|
#> |x|          3|          4|          5|    0.2343750000|          6|00:00:00|+1.00|1.00|0.0102|
#> |x|          7|          4|          4|    0.2434895833|          8|00:00:00|-0.12|0.25|0.9154|
#> |x|          4|          4|          4|    0.2548828125|         10|00:00:00|-0.30|0.02|0.9878|
#> |=|          6|          4|          4|    0.2484375000|         12|00:00:00|-0.19|0.05|0.8867|
#> |=|          2|          4|          4|    0.2526041667|         14|00:00:00|-0.08|0.10|0.7872|
#> |=|          1|          4|          2|    0.2550223214|         16|00:00:00|-0.06|0.09|0.7789|
#> |=|          5|          4|          2|    0.2519531250|         18|00:00:00|-0.01|0.12|0.7570|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> Best-so-far configuration:           2    mean value:     0.2519531250
#> Description of the best-so-far configuration:
#>   .ID.                cp .PARENT.
#> 2    2 -2.88671306171978       NA
#> 
#> # 2022-11-18 12:12:14 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):
#>                  cp
#> 2 -2.88671306171978
#> 3 -2.54683773296070
#> # 2022-11-18 12:12:14 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: 3.837, CPU sys time: 0.016, Wall-clock time: 3.854

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

# all evaluated hyperparameter configuration
as.data.table(instance$archive)
#>            cp classif.ce  x_domain_cp runtime_learners           timestamp
#>  1: -7.732859  0.2539062 0.0004381894            0.019 2022-11-18 12:12:11
#>  2: -2.886713  0.2578125 0.0557591887            0.018 2022-11-18 12:12:11
#>  3: -2.546838  0.2578125 0.0783289719            0.018 2022-11-18 12:12:11
#>  4: -7.732859  0.2851562 0.0004381894            0.019 2022-11-18 12:12:11
#>  5: -2.886713  0.2734375 0.0557591887            0.018 2022-11-18 12:12:11
#>  6: -2.546838  0.2734375 0.0783289719            0.028 2022-11-18 12:12:11
#>  7: -7.732859  0.2421875 0.0004381894            0.020 2022-11-18 12:12:11
#>  8: -2.886713  0.2539062 0.0557591887            0.024 2022-11-18 12:12:11
#>  9: -2.546838  0.2539062 0.0783289719            0.018 2022-11-18 12:12:11
#> 10: -7.732859  0.2890625 0.0004381894            0.019 2022-11-18 12:12:11
#> 11: -2.886713  0.2773438 0.0557591887            0.018 2022-11-18 12:12:11
#> 12: -2.546838  0.2773438 0.0783289719            0.015 2022-11-18 12:12:11
#> 13: -7.732859  0.2460938 0.0004381894            0.020 2022-11-18 12:12:12
#> 14: -2.886713  0.2304688 0.0557591887            0.045 2022-11-18 12:12:12
#> 15: -2.546838  0.2304688 0.0783289719            0.020 2022-11-18 12:12:12
#> 16: -7.732859  0.2382812 0.0004381894            0.019 2022-11-18 12:12:12
#> 17: -2.886713  0.2226562 0.0557591887            0.018 2022-11-18 12:12:12
#> 18: -2.546838  0.2226562 0.0783289719            0.019 2022-11-18 12:12:12
#> 19: -7.732859  0.2734375 0.0004381894            0.022 2022-11-18 12:12:12
#> 20: -2.886713  0.2421875 0.0557591887            0.026 2022-11-18 12:12:12
#> 21: -2.546838  0.2421875 0.0783289719            0.064 2022-11-18 12:12:12
#> 22: -2.886713  0.2578125 0.0557591887            0.017 2022-11-18 12:12:13
#> 23: -2.546838  0.2578125 0.0783289719            0.017 2022-11-18 12:12:13
#> 24: -3.889545  0.2500000 0.0204546600            0.018 2022-11-18 12:12:13
#> 25: -4.762852  0.2460938 0.0085412120            0.018 2022-11-18 12:12:13
#> 26: -3.889545  0.2382812 0.0204546600            0.018 2022-11-18 12:12:13
#> 27: -4.762852  0.2226562 0.0085412120            0.020 2022-11-18 12:12:13
#> 28: -3.889545  0.2421875 0.0204546600            0.018 2022-11-18 12:12:13
#> 29: -4.762852  0.2656250 0.0085412120            0.018 2022-11-18 12:12:13
#> 30: -3.889545  0.2890625 0.0204546600            0.019 2022-11-18 12:12:13
#> 31: -4.762852  0.2929688 0.0085412120            0.020 2022-11-18 12:12:13
#> 32: -3.889545  0.2226562 0.0204546600            0.017 2022-11-18 12:12:13
#> 33: -4.762852  0.2539062 0.0085412120            0.020 2022-11-18 12:12:13
#> 34: -3.889545  0.2734375 0.0204546600            0.052 2022-11-18 12:12:14
#> 35: -4.762852  0.2812500 0.0085412120            0.022 2022-11-18 12:12:14
#> 36: -3.889545  0.2734375 0.0204546600            0.017 2022-11-18 12:12:14
#> 37: -4.762852  0.2656250 0.0085412120            0.019 2022-11-18 12:12:14
#> 38: -3.889545  0.2421875 0.0204546600            0.020 2022-11-18 12:12:14
#> 39: -4.762852  0.2343750 0.0085412120            0.020 2022-11-18 12:12:14
#>            cp classif.ce  x_domain_cp runtime_learners           timestamp
#>     batch_nr race step instance configuration warnings errors
#>  1:        1    1    1        6             1        0      0
#>  2:        1    1    1        6             2        0      0
#>  3:        1    1    1        6             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        7             1        0      0
#>  8:        3    1    1        7             2        0      0
#>  9:        3    1    1        7             3        0      0
#> 10:        4    1    1        3             1        0      0
#> 11:        4    1    1        3             2        0      0
#> 12:        4    1    1        3             3        0      0
#> 13:        5    1    1        2             1        0      0
#> 14:        5    1    1        2             2        0      0
#> 15:        5    1    1        2             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        9             2        0      0
#> 23:        8    2    1        9             3        0      0
#> 24:        8    2    1        9             4        0      0
#> 25:        8    2    1        9             5        0      0
#> 26:        9    2    1        7             4        0      0
#> 27:        9    2    1        7             5        0      0
#> 28:       10    2    1        1             4        0      0
#> 29:       10    2    1        1             5        0      0
#> 30:       11    2    1        3             4        0      0
#> 31:       11    2    1        3             5        0      0
#> 32:       12    2    1        8             4        0      0
#> 33:       12    2    1        8             5        0      0
#> 34:       13    2    1       10             4        0      0
#> 35:       13    2    1       10             5        0      0
#> 36:       14    2    1        6             4        0      0
#> 37:       14    2    1        6             5        0      0
#> 38:       15    2    1        2             4        0      0
#> 39:       15    2    1        2             5        0      0
#>     batch_nr race step instance configuration warnings errors
#>          resample_result
#>  1: <ResampleResult[21]>
#>  2: <ResampleResult[21]>
#>  3: <ResampleResult[21]>
#>  4: <ResampleResult[21]>
#>  5: <ResampleResult[21]>
#>  6: <ResampleResult[21]>
#>  7: <ResampleResult[21]>
#>  8: <ResampleResult[21]>
#>  9: <ResampleResult[21]>
#> 10: <ResampleResult[21]>
#> 11: <ResampleResult[21]>
#> 12: <ResampleResult[21]>
#> 13: <ResampleResult[21]>
#> 14: <ResampleResult[21]>
#> 15: <ResampleResult[21]>
#> 16: <ResampleResult[21]>
#> 17: <ResampleResult[21]>
#> 18: <ResampleResult[21]>
#> 19: <ResampleResult[21]>
#> 20: <ResampleResult[21]>
#> 21: <ResampleResult[21]>
#> 22: <ResampleResult[21]>
#> 23: <ResampleResult[21]>
#> 24: <ResampleResult[21]>
#> 25: <ResampleResult[21]>
#> 26: <ResampleResult[21]>
#> 27: <ResampleResult[21]>
#> 28: <ResampleResult[21]>
#> 29: <ResampleResult[21]>
#> 30: <ResampleResult[21]>
#> 31: <ResampleResult[21]>
#> 32: <ResampleResult[21]>
#> 33: <ResampleResult[21]>
#> 34: <ResampleResult[21]>
#> 35: <ResampleResult[21]>
#> 36: <ResampleResult[21]>
#> 37: <ResampleResult[21]>
#> 38: <ResampleResult[21]>
#> 39: <ResampleResult[21]>
#>          resample_result

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