mlr-org / mlr3tuning

Hyperparameter optimization package of the mlr3 ecosystem
https://mlr3tuning.mlr-org.com/
GNU Lesser General Public License v3.0
55 stars 5 forks source link

The `terminator` parameter in `tune_nested()` isn't taking effect #396

Closed Shitao5 closed 1 year ago

Shitao5 commented 1 year ago

When I use the term_evals parameter, everything works fine:

rr = tune_nested(
  tuner = tnr("random_search", batch_size = 2),
  task = tsk("penguins"),
  learner = lrn("classif.rpart", cp = to_tune(1e-04, 1e-1, logscale = TRUE)),
  inner_resampling = rsmp ("holdout"),
  outer_resampling = rsmp("cv", folds = 2),
  measure = msr("classif.ce"),
  term_evals = 2)
#> INFO  [14:53:22.586] [mlr3] Applying learner 'classif.rpart.tuned' on task 'penguins' (iter 1/2)
#> INFO  [14:53:22.645] [bbotk] Starting to optimize 1 parameter(s) with '<OptimizerRandomSearch>' and '<TerminatorEvals> [n_evals=2, k=0]'

But when I use terminator = trm("evals", n_evals = 2) instead of term_evals = 2, the termination condition becomes ineffective:

rr = tune_nested(
  tuner = tnr("random_search", batch_size = 2),
  task = tsk("penguins"),
  learner = lrn("classif.rpart", cp = to_tune(1e-04, 1e-1, logscale = TRUE)),
  inner_resampling = rsmp ("holdout"),
  outer_resampling = rsmp("cv", folds = 2),
  measure = msr("classif.ce"),
  terminator = trm("evals", n_evals = 2))
#> INFO  [14:55:17.550] [mlr3] Applying learner 'classif.rpart.tuned' on task 'penguins' (iter 1/2)
#> INFO  [14:55:17.691] [bbotk] Starting to optimize 1 parameter(s) with '<OptimizerRandomSearch>' and '<TerminatorNone>'

My mlr3tuning package version is 0.19.0.

be-marc commented 1 year ago

Thanks for reporting. Fixed in #397.