mlr-org / mlr3gallery

Case studies using mlr3
https://mlr3gallery.mlr-org.com
21 stars 9 forks source link

"Practical Tuning Series - Build an Automated Machine Learning System" errors #116

Closed pat-s closed 3 years ago

pat-s commented 3 years ago

https://github.com/mlr-org/mlr3gallery/runs/4059593765?check_suite_focus=true#step:16:9389

kknn.k is actually defined but reported as missing during execution.

@be-marc Do you have an idea what might be going on here?

be-marc commented 3 years ago

So kknn.k is a required parameter since 3 months. When a ranger model is trained, we use ParamSet$get_values() which checks if all required parameters are set. Since we are in the ranger branch and train a ranger model, k is not set. However, the parameter set is the collection of all parameter sets and therefore also has a required tag for k. We could disable the check or don't use required tags at all. We need to discuss this at the meeting tomorrow.

learners = list(
  kknn = lrn("classif.kknn", id = "kknn"),
  ranger = lrn("classif.ranger", id = "ranger")
)

graph = ppl("branch", lapply(learners, po))
graph_learner = as_learner(graph)

graph_learner$param_set$values$branch.selection = to_tune(c("kknn", "ranger"))
graph_learner$param_set$values$kknn.k = to_tune(p_int(3, 50, logscale = TRUE, depends = branch.selection == "kknn"))
graph_learner$param_set$values$ranger.mtry = to_tune(p_int(1, 8, depends = branch.selection == "ranger"))

instance = tune(
  method = "random_search",
  task = tsk("iris"),
  learner = graph_learner,
  resampling = rsmp("cv", folds = 3),
  measure = msr("classif.ce"),
  term_evals = 20
)
be-marc commented 3 years ago

@pat-s We did not see the bug in the CI because it is a long running part which is cached. Could you set up a CI run every week (?) which renders the posts with eval_all = TRUE e.g. rmarkdown::rendner("post.Rmd", encoding = "UTF-8", params = list(eval_all = TRUE)).

be-marc commented 3 years ago

Fixed by latest mlr3 github version.