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

Set default of check_values to FALSE #258

Closed be-marc closed 4 years ago

be-marc commented 4 years ago

The following code does not work anymore

library(mlr3learners)

task = tsk("iris")
measure = msr("classif.ce")
resampling = rsmp("holdout")

learner = lrn("classif.svm", kernel = "polynomial")

tune_ps = ParamSet$new(list(
  ParamInt$new("degree", lower = 1, upper = 8)))

evals20 = trm("evals", n_evals = 20)

instance = TuningInstanceSingleCrit$new(task, learner, resampling, measure, tune_ps, evals20)

tuner = tnr("random_search")
tuner$optimize(instance)

> Error in lapply(xss, self$domain$assert) : 
  Assertion on 'X[[i]]' failed: The parameter 'degree' can only be set if the following condition is met 'kernel = polynomial'. Instead the parameter value for 'kernel' is not set at all. Try setting 'kernel' to a value that satisfies the condition. 

We add kernel = "polynomial"to the parameter set in .eval_many in mlr3tuning::ObjectiveTuning before the evaluation but the domain is already checked for dependencies in eval_many in bbotk::Objective.

We should change the default of check_values to FALSE in mlr3tuning::TuningInstanceSingleCrit to disable the domain checks.

If the user really wants the checks, he has to use a trafo like this

tune_ps$trafo = function(x, param_set) {
  x$kernel = "polynomial"
  x}
be-marc commented 4 years ago

Closed by bc4c52adf7d10de29ae8fb737e0c6895eade92b1