mlr-org / paradox

ParamHelpers Next Generation
https://paradox.mlr-org.com
GNU Lesser General Public License v3.0
28 stars 7 forks source link

How to assign specific value on unmet dependency? #363

Closed bblodfon closed 2 years ago

bblodfon commented 2 years ago

Hi!

When I want to set a hyperparameter of a model that depends on another, how can I specify in the case that the dependency is not met to assign a specific value, e.g. in the example below I would like to have num.random.splits = 1 instead of NA (which gives me a warning when I train the learner later):

library(mlr3extralearners)
library(paradox)
learner = lrn('surv.ranger',
  splitrule = to_tune(c('logrank', 'extratrees', 'C', 'maxstat')),
  num.random.splits = to_tune(p_int(1, 100, depends = splitrule == 'extratrees')))

generate_design_random(learner$param_set$search_space(), 5)
#> <Design> with 5 rows:
#>     splitrule num.random.splits
#> 1:          C                NA
#> 2: extratrees                13
#> 3: extratrees                52
#> 4:    logrank                NA
#> 5:          C                NA

Created on 2022-06-08 by the reprex package (v2.0.1)

bblodfon commented 2 years ago

Not an issuem, though NA is passed to the AutoTuner for num.random.splits, it's not actually used when training the learner on resamplings!