
Hyperparameter Optimization with Successive Halving
Source:R/OptimizerBatchSuccessiveHalving.R
mlr_optimizers_successive_halving.RdOptimizer using the Successive Halving Algorithm (SHA).
SHA is initialized with the number of starting configurations n, the proportion of configurations discarded in each stage eta, and the minimum r_min and maximum _max budget of a single evaluation.
The algorithm starts by sampling n random configurations and allocating the minimum budget r_min to them.
The configurations are evaluated and 1 / eta of the worst-performing configurations are discarded.
The remaining configurations are promoted to the next stage and evaluated on a larger budget.
The following table is the stage layout for eta = 2, r_min = 1 and r_max = 8.
i | n_i | r_i |
| 0 | 8 | 1 |
| 1 | 4 | 2 |
| 2 | 2 | 4 |
| 3 | 1 | 8 |
i is the stage number, n_i is the number of configurations and r_i is the budget allocated to a single configuration.
The number of stages is calculated so that each stage consumes approximately the same budget. This sometimes results in the minimum budget having to be slightly adjusted by the algorithm.
Source
Jamieson K, Talwalkar A (2016). “Non-stochastic Best Arm Identification and Hyperparameter Optimization.” In Gretton A, Robert CC (eds.), Proceedings of the 19th International Conference on Artificial Intelligence and Statistics, volume 51 series Proceedings of Machine Learning Research, 240-248. http://proceedings.mlr.press/v51/jamieson16.html.
Resources
The gallery features a collection of case studies and demos about optimization.
Tune the hyperparameters of XGBoost with Hyperband (Hyperband can be easily swapped with SHA).
Use data subsampling and Hyperband to optimize a support vector machine.
Dictionary
This bbotk::Optimizer can be instantiated via the dictionary
bbotk::mlr_optimizers or with the associated sugar function bbotk::opt():
Parameters
ninteger(1)
Number of configurations in the base stage.etanumeric(1)
With every stage, the budget is increased by a factor ofetaand only the best1 / etaconfigurations are promoted to the next stage. Non-integer values are supported, butetais not allowed to be less or equal to 1.samplerparadox::Sampler
Object defining how the samples of the parameter space should be drawn. The default is uniform sampling.repetitionsinteger(1)
If1(default), optimization is stopped once all stages are evaluated. Otherwise, optimization is stopped afterrepetitionsruns of SHA. The bbotk::Terminator might stop the optimization before all repetitions are executed.adjust_minimum_budgetlogical(1)
IfTRUE, the minimum budget is increased so that the last stage uses the maximum budget defined in the search space.
Archive
The bbotk::Archive holds the following additional columns that are specific to SHA:
stage(integer(1))
Stage index. Starts counting at 0.repetition(integer(1))
Repetition index. Start counting at 1.
Custom Sampler
Hyperband supports custom paradox::Sampler object for initial configurations in each bracket. A custom sampler may look like this (the full example is given in the examples section):
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
Hyperband uses a logger (as implemented in lgr) from package
bbotk.
Use lgr::get_logger("bbotk") to access and control the logger.
Super classes
bbotk::Optimizer -> bbotk::OptimizerBatch -> OptimizerBatchSuccessiveHalving
Examples
library(bbotk)
library(data.table)
# set search space
search_space = domain = ps(
x1 = p_dbl(-5, 10),
x2 = p_dbl(0, 15),
fidelity = p_dbl(1e-2, 1, tags = "budget")
)
# Branin function with fidelity, see `bbotk::branin()`
fun = function(xs) branin_wu(xs[["x1"]], xs[["x2"]], xs[["fidelity"]])
# create objective
objective = ObjectiveRFun$new(
fun = fun,
domain = domain,
codomain = ps(y = p_dbl(tags = "minimize"))
)
# initialize instance and optimizer
instance = OptimInstanceSingleCrit$new(
objective = objective,
search_space = search_space,
terminator = trm("evals", n_evals = 50)
)
#> OptimInstanceSingleCrit is deprecated. Use OptimInstanceBatchSingleCrit instead.
optimizer = opt("successive_halving")
# optimize branin function
optimizer$optimize(instance)
#> x1 x2 fidelity x_domain y
#> <num> <num> <num> <list> <num>
#> 1: -3.787326 12.87492 0.16 <list[3]> 2.370823
# best scoring evaluation
instance$result
#> x1 x2 fidelity x_domain y
#> <num> <num> <num> <list> <num>
#> 1: -3.787326 12.87492 0.16 <list[3]> 2.370823
# all evaluations
as.data.table(instance$archive)
#> x1 x2 fidelity stage repetition y
#> <num> <num> <num> <int> <num> <num>
#> 1: -4.4071897 9.0300579 0.01 0 1 28.004065
#> 2: 9.1716220 9.8549374 0.01 0 1 253.925823
#> 3: -1.3260802 4.9397575 0.01 0 1 22.719578
#> 4: 6.7168385 14.6921133 0.01 0 1 343.451440
#> 5: -0.6764425 10.7277920 0.01 0 1 30.718370
#> 6: 8.1303687 13.0894546 0.01 0 1 332.606891
#> 7: -0.5637486 14.7492562 0.01 0 1 79.619962
#> 8: 9.7528811 3.2784449 0.01 0 1 99.505602
#> 9: 3.8475633 9.9679510 0.01 0 1 95.713095
#> 10: 6.3873757 5.8434606 0.01 0 1 96.599814
#> 11: 7.5411296 0.6909546 0.01 0 1 37.720661
#> 12: 6.4422920 9.2537184 0.01 0 1 169.646079
#> 13: 1.2590489 8.9771249 0.01 0 1 37.280804
#> 14: -2.9288774 6.1028044 0.01 0 1 23.823395
#> 15: -3.7873256 12.8749222 0.01 0 1 2.502786
#> 16: 4.8397394 7.7652178 0.01 0 1 87.972692
#> 17: -3.7873256 12.8749222 0.02 1 1 2.491108
#> 18: -1.3260802 4.9397575 0.02 1 1 22.730919
#> 19: -2.9288774 6.1028044 0.02 1 1 23.906122
#> 20: -4.4071897 9.0300579 0.02 1 1 28.181990
#> 21: -0.6764425 10.7277920 0.02 1 1 30.715041
#> 22: 1.2590489 8.9771249 0.02 1 1 37.265167
#> 23: 7.5411296 0.6909546 0.02 1 1 37.157884
#> 24: -0.5637486 14.7492562 0.02 1 1 79.614977
#> 25: -3.7873256 12.8749222 0.04 2 1 2.468986
#> 26: -1.3260802 4.9397575 0.04 2 1 22.753620
#> 27: -2.9288774 6.1028044 0.04 2 1 24.072018
#> 28: -4.4071897 9.0300579 0.04 2 1 28.540104
#> 29: -3.7873256 12.8749222 0.08 3 1 2.429681
#> 30: -1.3260802 4.9397575 0.08 3 1 22.799097
#> 31: -3.7873256 12.8749222 0.16 4 1 2.370823
#> x1 x2 fidelity stage repetition y
#> timestamp batch_nr x_domain_x1 x_domain_x2 x_domain_fidelity
#> <POSc> <int> <num> <num> <num>
#> 1: 2025-07-10 09:00:46 1 -4.4071897 9.0300579 0.01
#> 2: 2025-07-10 09:00:46 1 9.1716220 9.8549374 0.01
#> 3: 2025-07-10 09:00:46 1 -1.3260802 4.9397575 0.01
#> 4: 2025-07-10 09:00:46 1 6.7168385 14.6921133 0.01
#> 5: 2025-07-10 09:00:46 1 -0.6764425 10.7277920 0.01
#> 6: 2025-07-10 09:00:46 1 8.1303687 13.0894546 0.01
#> 7: 2025-07-10 09:00:46 1 -0.5637486 14.7492562 0.01
#> 8: 2025-07-10 09:00:46 1 9.7528811 3.2784449 0.01
#> 9: 2025-07-10 09:00:46 1 3.8475633 9.9679510 0.01
#> 10: 2025-07-10 09:00:46 1 6.3873757 5.8434606 0.01
#> 11: 2025-07-10 09:00:46 1 7.5411296 0.6909546 0.01
#> 12: 2025-07-10 09:00:46 1 6.4422920 9.2537184 0.01
#> 13: 2025-07-10 09:00:46 1 1.2590489 8.9771249 0.01
#> 14: 2025-07-10 09:00:46 1 -2.9288774 6.1028044 0.01
#> 15: 2025-07-10 09:00:46 1 -3.7873256 12.8749222 0.01
#> 16: 2025-07-10 09:00:46 1 4.8397394 7.7652178 0.01
#> 17: 2025-07-10 09:00:46 2 -3.7873256 12.8749222 0.02
#> 18: 2025-07-10 09:00:46 2 -1.3260802 4.9397575 0.02
#> 19: 2025-07-10 09:00:46 2 -2.9288774 6.1028044 0.02
#> 20: 2025-07-10 09:00:46 2 -4.4071897 9.0300579 0.02
#> 21: 2025-07-10 09:00:46 2 -0.6764425 10.7277920 0.02
#> 22: 2025-07-10 09:00:46 2 1.2590489 8.9771249 0.02
#> 23: 2025-07-10 09:00:46 2 7.5411296 0.6909546 0.02
#> 24: 2025-07-10 09:00:46 2 -0.5637486 14.7492562 0.02
#> 25: 2025-07-10 09:00:46 3 -3.7873256 12.8749222 0.04
#> 26: 2025-07-10 09:00:46 3 -1.3260802 4.9397575 0.04
#> 27: 2025-07-10 09:00:46 3 -2.9288774 6.1028044 0.04
#> 28: 2025-07-10 09:00:46 3 -4.4071897 9.0300579 0.04
#> 29: 2025-07-10 09:00:46 4 -3.7873256 12.8749222 0.08
#> 30: 2025-07-10 09:00:46 4 -1.3260802 4.9397575 0.08
#> 31: 2025-07-10 09:00:46 5 -3.7873256 12.8749222 0.16
#> timestamp batch_nr x_domain_x1 x_domain_x2 x_domain_fidelity