mlr-org / mlr3tuning

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

store_models = TRUE - not working in ti() #398

Closed mermast closed 7 months ago

mermast commented 8 months ago

It seems setting store_model = TRUE does not work when store_benchmark_result is set to FALSE.

This does not seem in line with following lines in chapter 5 of MLR3 Book -- "The option store_models = TRUE sets store_benchmark_result and store_tuning_instance to TRUE because the models are stored in the benchmark results which in turn is part of the instance. This also means that store_benchmark_result = TRUE sets store_tuning_instance to TRUE."

Example:-

tsk_sonar = tsk("sonar")
learner = lrn("classif.svm",
  cost  = to_tune(1e-5, 1e5, logscale = TRUE),
  gamma = to_tune(1e-5, 1e5, logscale = TRUE),
  kernel = "radial",
  type = "C-classification")

instance = ti(
  task = tsk_sonar,
  learner = learner,
  resampling = rsmp("cv", folds = 3),
  measures = msr("classif.ce"),
  terminator = trm("none"),
  store_models = TRUE, 
  store_benchmark_result = FALSE 
  )

tuner = tnr("grid_search", resolution = 5, batch_size = 10)
tuner$optimize(instance)

instance$archive$learner(2) # THIS WILL THROW ERROR

The above code works when store_benchmark_result = TRUE even with store_models = FALSE Is there anything that I am missing ....

Thanks a lot for the creating superb MLR3 ecosystem !!

be-marc commented 7 months ago

Yes store_benchmark_result was only set to TRUE when using an AutoTuner. I fixed this for tuning instances. Thanks! #399