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

TunerFromOptimizer ignores ParamSet after cloning #405

Closed mb706 closed 3 months ago

mb706 commented 10 months ago
t1 <- tnr("design_points", design = data.table(cp = c(0, 1)))                                             
t2 <- t1$clone(deep = TRUE)                                                                               
t2$param_set$values$design = data.table(cp = c(0.1, 0.2, 0.3))                            
tune(t1, tsk("iris"), lrn("classif.rpart", cp = to_tune()), rsmp("holdout"))$archive
#> <ArchiveTuning> with 2 evaluations
#>    cp classif.ce batch_nr warnings errors
#> 1:  0       0.02        1        0      0
#> 2:  1       0.68        2        0      0
tune(t2, tsk("iris"), lrn("classif.rpart", cp = to_tune()), rsmp("holdout"))$archive
#> <ArchiveTuning> with 2 evaluations
#>    cp classif.ce batch_nr warnings errors
#> 1:  0       0.02        1        0      0
#> 2:  1       0.68        2        0      0

In this example, it is expected that the second archive tries cp values of 0.1, 0.2 and 0.3. This happens because clone(deep = TRUE) clones the private$.param_set separately and it ends up not pointing to private$.optimizer's $param_set any more. A way to solve this would be for TunerFromOptimizer to overwrite the param_set active binding and always returning private$.optimizer$param_set here.

be-marc commented 3 months ago

Thanks for reporting. Fixed in #436