mlr-org / mlr3tuning

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

Allow search_space to be a TuningSpace #317

Closed sebffischer closed 2 years ago

sebffischer commented 2 years ago

During construction of a tuning instance, I would expect that TuningInstanceSingleCrit and TuningInstanceMultiCrit accept an object of class TuningSpace as input for search_space.

library(mlr3verse)
#> Loading required package: mlr3
library(mlr3tuningspaces)
#> Loading required package: mlr3tuning
#> Loading required package: paradox

task = tsk("boston_housing")
learner = lrn("regr.ranger", splitrule = "extratrees")
tuning_space = mlr3tuningspaces::lts("regr.ranger.default")
measure = msr("regr.mse")
resampling = rsmp("holdout")
terminator = trm("evals", n_evals = 5)

# This does not work
instance = TuningInstanceSingleCrit$new(
  task = task,
  learner = learner,
  measure = measure,
  resampling = resampling,
  search_space = tuning_space,
  terminator = terminator
)
#> Error in assert_param_set(search_space): Assertion on 'param_set' failed: Must inherit from class 'ParamSet', but has classes 'TuningSpace','R6'.

Created on 2021-12-26 by the reprex package (v2.0.1)