I was trying to use the examples from mlr3 book in https://mlr3book.mlr-org.com/chapters/chapter1/introduction_and_overview.html
The first example (here is an example of the simplest functionality) works well. The second example (here is an example of the simplest functionality) doesn't work. Here is the code to reproduce the error message:
library(mlr3)
library(mlr3verse)
tasks = tsks(c("breast_cancer", "sonar"))
glrn_rf_tuned = as_learner(ppl("robustify") %>% auto_tuner(
tnr("grid_search", resolution = 5),
lrn("classif.ranger", num.trees = to_tune(200, 500)),
rsmp("holdout")
))
#Error in ppl("robustify") %>% auto_tuner(tnr("grid_search", resolution = 5),: could not find function "%>%"
library(tidyverse)
glrn_rf_tuned = as_learner(ppl("robustify") %>% auto_tuner(
tnr("grid_search", resolution = 5),
lrn("classif.ranger", num.trees = to_tune(200, 500)),
rsmp("holdout")
))
#Error in UseMethod("as_learner") :
# no applicable method for 'as_learner' applied to an object of class "c('TunerGridSearch', 'Tuner', 'R6')"
Reproducible example
library(mlr3)
#> Warning: package 'mlr3' was built under R version 4.2.3
library(mlr3verse)
#> Warning: package 'mlr3verse' was built under R version 4.2.3
tasks = tsks(c("breast_cancer", "sonar"))
glrn_rf_tuned = as_learner(ppl("robustify") %>% auto_tuner(
tnr("grid_search", resolution = 5),
lrn("classif.ranger", num.trees = to_tune(200, 500)),
rsmp("holdout")
))
#> Error in ppl("robustify") %>% auto_tuner(tnr("grid_search", resolution = 5), : could not find function "%>%"
#Error in ppl("robustify") %>% auto_tuner(tnr("grid_search", resolution = 5),: could not find function "%>%"
library(tidyverse)
#> Warning: package 'tibble' was built under R version 4.2.3
#> Warning: package 'tidyr' was built under R version 4.2.3
#> Warning: package 'dplyr' was built under R version 4.2.3
#> Warning: package 'forcats' was built under R version 4.2.3
glrn_rf_tuned = as_learner(ppl("robustify") %>% auto_tuner(
tnr("grid_search", resolution = 5),
lrn("classif.ranger", num.trees = to_tune(200, 500)),
rsmp("holdout")
))
#> Error in UseMethod("as_learner"): no applicable method for 'as_learner' applied to an object of class "c('TunerGridSearch', 'Tuner', 'R6')"
Thanks, the %>% should be %>>%`. This is already fixed in the main branch. Looks like the online version hasn't updated yet; I've kicked off that job again.
Description
I was trying to use the examples from mlr3 book in https://mlr3book.mlr-org.com/chapters/chapter1/introduction_and_overview.html The first example (here is an example of the simplest functionality) works well. The second example (here is an example of the simplest functionality) doesn't work. Here is the code to reproduce the error message:
Reproducible example