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 .
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.
Getting started with hyperparameter optimization.
An overview of all tuners can be found on our website.
Tune a support vector machine on the Sonar data set.
Learn about tuning spaces.
Estimate the model performance with nested resampling.
Learn about multi-objective optimization.
Simultaneously optimize hyperparameters and use early stopping with XGBoost.
Automate the tuning.
The gallery features a collection of case studies and demos about optimization.
Learn more advanced methods with the Practical Tuning Series.
Learn about hotstarting models.
Run the default hyperparameter configuration of learners as a baseline.
Use the Hyperband optimizer with different budget parameters.
The cheatsheet summarizes the most important functions of mlr3tuning.
Super classes
mlr3tuning::Tuner
-> mlr3tuning::TunerBatch
-> mlr3tuning::TunerBatchFromOptimizerBatch
-> TunerBatchIrace
Methods
Inherited methods
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.
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))
# runtime of the example is too long
# \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 = 200
)
#> # 2024-12-18 10:07:01 UTC: Initialization
#> # Elitist race
#> # Elitist new instances: 1
#> # Elitist limit: 2
#> # nbIterations: 2
#> # minNbSurvival: 2
#> # nbParameters: 1
#> # seed: 1855097766
#> # confidence level: 0.95
#> # budget: 200
#> # mu: 5
#> # deterministic: FALSE
#>
#> # 2024-12-18 10:07:01 UTC: Iteration 1 of 2
#> # experimentsUsedSoFar: 0
#> # remainingBudget: 200
#> # currentBudget: 100
#> # nbConfigurations: 16
#> # 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| 16| 2| 0.2460937500| 16|00:00:00| NA| NA| NA|
#> |x| 2| 16| 5| 0.2539062500| 32|00:00:00|+0.85|0.93|0.2432|
#> |x| 3| 16| 5| 0.2513020833| 48|00:00:00|+0.72|0.81|0.5409|
#> |x| 4| 16| 5| 0.2421875000| 64|00:00:00|+0.63|0.73|0.4926|
#> |-| 5| 6| 5| 0.2398437500| 80|00:00:00|+0.01|0.21|0.8365|
#> |=| 6| 6| 2| 0.2513020833| 86|00:00:00|-0.12|0.07|0.9438|
#> |=| 7| 6| 5| 0.2483258929| 92|00:00:00|-0.01|0.13|0.8680|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> Best-so-far configuration: 5 mean value: 0.2483258929
#> Description of the best-so-far configuration:
#> .ID. cp .PARENT.
#> 5 5 -2.86582979189387 NA
#>
#> # 2024-12-18 10:07:03 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):
#> cp
#> 5 -2.86582979189387
#> 2 -3.72929920176664
#> # 2024-12-18 10:07:03 UTC: Iteration 2 of 2
#> # experimentsUsedSoFar: 92
#> # remainingBudget: 108
#> # currentBudget: 108
#> # nbConfigurations: 15
#> # 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| 15| 24| 0.2695312500| 15|00:00:00| NA| NA| NA|
#> |x| 4| 15| 24| 0.2421875000| 28|00:00:00|+0.00|0.50|0.4667|
#> |x| 3| 15| 24| 0.2434895833| 41|00:00:00|+0.00|0.33|0.3111|
#> |x| 6| 15| 24| 0.2509765625| 54|00:00:00|-0.13|0.16|0.5342|
#> |=| 5| 15| 24| 0.2460937500| 67|00:00:00|-0.00|0.20|0.5544|
#> |=| 7| 15| 24| 0.2486979167| 80|00:00:00|-0.02|0.15|0.6385|
#> |=| 2| 15| 18| 0.2488839286| 93|00:00:00|+0.04|0.18|0.6580|
#> |=| 1| 15| 18| 0.2495117188| 106|00:00:00|-0.01|0.12|0.7102|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> Best-so-far configuration: 18 mean value: 0.2495117188
#> Description of the best-so-far configuration:
#> .ID. cp .PARENT.
#> 18 18 -3.03505397360393 5
#>
#> # 2024-12-18 10:07:06 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):
#> cp
#> 18 -3.03505397360393
#> 26 -3.07347033861101
#> # 2024-12-18 10:07:06 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: 198
#> # timeUsed: 0
#> # remainingBudget: 2
#> # currentBudget: 2
#> # number of elites: 2
#> # nbConfigurations: 2
#> # Total CPU user time: 5.449, CPU sys time: 0.124, Wall-clock time: 5.578
#> # 2024-12-18 10:07:06 UTC: Starting post-selection:
#> # Configurations selected: 18, 26.
#> # Pending instances: 0, 0.
#> # Seed: 1855097766
#> # Configurations: 2
#> # Available experiments: 2
#> # minSurvival: 1
#> # 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|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> |.| 1| 2| 18| 0.2539062500| 0|00:00:00| NA| NA| NA|
#> |.| 8| 2| 18| 0.2636718750| 0|00:00:00|+1.00|1.00|0.0000|
#> |.| 4| 2| 18| 0.2473958333| 0|00:00:00|+1.00|1.00|0.0000|
#> |.| 3| 2| 18| 0.2470703125| 0|00:00:00|+1.00|1.00|0.0000|
#> |.| 7| 2| 18| 0.2476562500| 0|00:00:00|+1.00|1.00|0.0000|
#> |.| 2| 2| 18| 0.2486979167| 0|00:00:00|+1.00|1.00|0.0000|
#> |.| 5| 2| 18| 0.2460937500| 0|00:00:00|+1.00|1.00|0.0000|
#> |.| 6| 2| 18| 0.2495117188| 0|00:00:00|+1.00|1.00|0.0000|
#> |-| 9| 1| 18| 0.2513020833| 2|00:00:00| NA| NA| NA|
#> +-+-----------+-----------+-----------+----------------+-----------+--------+-----+----+------+
#> Best-so-far configuration: 18 mean value: 0.2513020833
#> Description of the best-so-far configuration:
#> .ID. cp .PARENT.
#> 18 18 -3.03505397360393 5
#>
#> # 2024-12-18 10:07:06 UTC: Elite configurations (first number is the configuration ID; listed from best to worst according to the sum of ranks):
#> cp
#> 18 -3.03505397360393
#> # Total CPU user time: 5.553, CPU sys time: 0.124, Wall-clock time: 5.682
# best performing hyperparameter configuration
instance$result
#> cp configuration learner_param_vals x_domain classif.ce
#> <num> <int> <list> <list> <num>
#> 1: -3.035054 18 <list[2]> <list[1]> 0.2513021
# all evaluated hyperparameter configuration
as.data.table(instance$archive)
#> cp classif.ce runtime_learners timestamp race step
#> <num> <num> <num> <POSc> <int> <int>
#> 1: -7.183177 0.3085938 0.008 2024-12-18 10:07:01 1 1
#> 2: -3.729299 0.2460938 0.008 2024-12-18 10:07:01 1 1
#> 3: -8.910116 0.3085938 0.008 2024-12-18 10:07:01 1 1
#> 4: -5.456238 0.3085938 0.007 2024-12-18 10:07:01 1 1
#> 5: -2.865830 0.2539062 0.006 2024-12-18 10:07:01 1 1
#> ---
#> 196: -3.782776 0.2578125 0.006 2024-12-18 10:07:06 2 1
#> 197: -2.949281 0.2539062 0.006 2024-12-18 10:07:06 2 1
#> 198: -2.692814 0.2812500 0.006 2024-12-18 10:07:06 2 1
#> 199: -3.035054 0.2656250 0.007 2024-12-18 10:07:06 3 1
#> 200: -3.073470 0.2656250 0.006 2024-12-18 10:07:06 3 1
#> instance configuration warnings errors x_domain batch_nr resample_result
#> <int> <int> <int> <int> <list> <int> <list>
#> 1: 10 1 0 0 <list[1]> 1 <ResampleResult>
#> 2: 10 2 0 0 <list[1]> 1 <ResampleResult>
#> 3: 10 3 0 0 <list[1]> 1 <ResampleResult>
#> 4: 10 4 0 0 <list[1]> 1 <ResampleResult>
#> 5: 10 5 0 0 <list[1]> 1 <ResampleResult>
#> ---
#> 196: 10 27 0 0 <list[1]> 15 <ResampleResult>
#> 197: 10 28 0 0 <list[1]> 15 <ResampleResult>
#> 198: 10 29 0 0 <list[1]> 15 <ResampleResult>
#> 199: 2 18 0 0 <list[1]> 16 <ResampleResult>
#> 200: 2 26 0 0 <list[1]> 16 <ResampleResult>
# fit final model on complete data set
learner$param_set$values = instance$result_learner_param_vals
learner$train(task)
# }