Terminators

Terminators of the mlr3 ecosystem.

A Terminator is an object that determines when to stop the optimization, e.g. after a budget of evaluations is depleted or the optimization stagnates.

Example Usage

Stop tuning when a performance level is reached.

library(mlr3verse)

# load terminator and set performance level
terminator = trm("perf_reached", level = 0.25)

# load tuner
tuner = tnr("random_search", batch_size = 10)

# retrieve task
task = tsk("pima")

# load learner and set search space
learner = lts(lrn("classif.rpart"))

# set instance
instance = TuningInstanceSingleCrit$new(
  task = task,
  learner = learner,
  resampling = rsmp("holdout"),
  measure = msr("classif.ce"),
  terminator = terminator
)

# hyperparameter tuning on the pima data set
tuner$optimize(instance)
   minsplit minbucket        cp learner_param_vals  x_domain
1: 3.547704  3.806944 -5.322484          <list[4]> <list[3]>
   classif.ce
1:  0.2070312
# best performing hyperparameter configuration
instance$result
   minsplit minbucket        cp learner_param_vals  x_domain
1: 3.547704  3.806944 -5.322484          <list[4]> <list[3]>
   classif.ce
1:  0.2070312
# fit final model on complete data set
learner$param_set$values = instance$result_learner_param_vals
learner$train(task)