error message when using examples from mlr3 book
slzhao opened this issue · comments
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:
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')"
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.2.2 (2022-10-31 ucrt)
#> os Windows 10 x64 (build 22621)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.utf8
#> ctype English_United States.utf8
#> tz America/Chicago
#> date 2023-08-31
#> pandoc 3.1.1 @ D:/toolSync/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.2.2)
#> backports 1.4.1 2021-12-13 [1] CRAN (R 4.2.0)
#> bbotk 0.7.2 2022-12-08 [1] CRAN (R 4.2.3)
#> broom 1.0.3 2023-01-25 [1] CRAN (R 4.2.2)
#> cellranger 1.1.0 2016-07-27 [1] CRAN (R 4.2.2)
#> checkmate 2.1.0 2022-04-21 [1] CRAN (R 4.2.2)
#> class 7.3-20 2022-01-16 [1] CRAN (R 4.2.2)
#> cli 3.4.1 2022-09-23 [1] CRAN (R 4.2.2)
#> clue 0.3-63 2022-11-19 [1] CRAN (R 4.2.2)
#> cluster 2.1.4 2022-08-22 [1] CRAN (R 4.2.2)
#> codetools 0.2-18 2020-11-04 [1] CRAN (R 4.2.2)
#> colorspace 2.0-3 2022-02-21 [1] CRAN (R 4.2.2)
#> crayon 1.5.2 2022-09-29 [1] CRAN (R 4.2.2)
#> data.table 1.14.6 2022-11-16 [1] CRAN (R 4.2.2)
#> DBI 1.1.3 2022-06-18 [1] CRAN (R 4.2.2)
#> dbplyr 2.3.0 2023-01-16 [1] CRAN (R 4.2.2)
#> DEoptimR 1.1-2 2023-08-28 [1] CRAN (R 4.2.2)
#> digest 0.6.30 2022-10-18 [1] CRAN (R 4.2.2)
#> diptest 0.76-0 2021-05-04 [1] CRAN (R 4.2.0)
#> dplyr * 1.1.1 2023-03-22 [1] CRAN (R 4.2.3)
#> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.2.2)
#> evaluate 0.18 2022-11-07 [1] CRAN (R 4.2.2)
#> fansi 1.0.3 2022-03-24 [1] CRAN (R 4.2.2)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.2)
#> flexmix 2.3-19 2023-03-16 [1] CRAN (R 4.2.3)
#> forcats * 1.0.0 2023-01-29 [1] CRAN (R 4.2.3)
#> fpc 2.2-10 2023-01-07 [1] CRAN (R 4.2.3)
#> fs 1.6.3 2023-07-20 [1] CRAN (R 4.2.3)
#> future 1.29.0 2022-11-06 [1] CRAN (R 4.2.2)
#> gargle 1.2.1 2022-09-08 [1] CRAN (R 4.2.2)
#> generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.2)
#> ggplot2 * 3.4.0 2022-11-04 [1] CRAN (R 4.2.2)
#> globals 0.16.2 2022-11-21 [1] CRAN (R 4.2.2)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.2)
#> googledrive 2.0.0 2021-07-08 [1] CRAN (R 4.2.2)
#> googlesheets4 1.0.1 2022-08-13 [1] CRAN (R 4.2.2)
#> gtable 0.3.1 2022-09-01 [1] CRAN (R 4.2.2)
#> haven 2.5.1 2022-08-22 [1] CRAN (R 4.2.2)
#> highr 0.9 2021-04-16 [1] CRAN (R 4.2.2)
#> hms 1.1.2 2022-08-19 [1] CRAN (R 4.2.2)
#> htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.2.3)
#> httr 1.4.4 2022-08-17 [1] CRAN (R 4.2.2)
#> jsonlite 1.8.3 2022-10-21 [1] CRAN (R 4.2.2)
#> kernlab 0.9-32 2023-01-31 [1] CRAN (R 4.2.2)
#> knitr 1.41 2022-11-18 [1] CRAN (R 4.2.2)
#> lattice 0.20-45 2021-09-22 [1] CRAN (R 4.2.2)
#> lgr 0.4.4 2022-09-05 [1] CRAN (R 4.2.3)
#> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.2)
#> listenv 0.8.0 2019-12-05 [1] CRAN (R 4.2.2)
#> lubridate 1.9.0 2022-11-06 [1] CRAN (R 4.2.2)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.2)
#> MASS 7.3-58.1 2022-08-03 [1] CRAN (R 4.2.2)
#> mclust 6.0.0 2022-10-31 [1] CRAN (R 4.2.2)
#> mlr3 * 0.16.1 2023-06-17 [1] CRAN (R 4.2.3)
#> mlr3cluster 0.1.8 2023-03-12 [1] CRAN (R 4.2.3)
#> mlr3data 0.7.0 2023-06-29 [1] CRAN (R 4.2.3)
#> mlr3filters 0.7.1 2023-02-15 [1] CRAN (R 4.2.3)
#> mlr3fselect 0.11.0 2023-03-02 [1] CRAN (R 4.2.3)
#> mlr3hyperband 0.4.5 2023-03-02 [1] CRAN (R 4.2.3)
#> mlr3learners 0.5.6 2023-01-06 [1] CRAN (R 4.2.3)
#> mlr3mbo 0.2.1 2023-06-05 [1] CRAN (R 4.2.3)
#> mlr3misc 0.12.0 2023-05-12 [1] CRAN (R 4.2.3)
#> mlr3pipelines 0.5.0-1 2023-05-22 [1] CRAN (R 4.2.3)
#> mlr3tuning 0.19.0 2023-06-26 [1] CRAN (R 4.2.3)
#> mlr3tuningspaces 0.4.0 2023-04-20 [1] CRAN (R 4.2.3)
#> mlr3verse * 0.2.8 2023-08-24 [1] https://mlr-org.r-universe.dev (R 4.2.3)
#> mlr3viz 0.6.1 2023-01-23 [1] CRAN (R 4.2.3)
#> modelr 0.1.10 2022-11-11 [1] CRAN (R 4.2.2)
#> modeltools 0.2-23 2020-03-05 [1] CRAN (R 4.2.0)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.2)
#> nnet 7.3-18 2022-09-28 [1] CRAN (R 4.2.2)
#> palmerpenguins 0.1.1 2022-08-15 [1] CRAN (R 4.2.3)
#> paradox 0.11.1 2023-03-17 [1] CRAN (R 4.2.3)
#> parallelly 1.32.1 2022-07-21 [1] CRAN (R 4.2.1)
#> pillar 1.8.1 2022-08-19 [1] CRAN (R 4.2.2)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.2)
#> prabclus 2.3-2 2020-01-08 [1] CRAN (R 4.2.3)
#> purrr * 1.0.1 2023-01-10 [1] CRAN (R 4.2.2)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.2)
#> Rcpp 1.0.9 2022-07-08 [1] CRAN (R 4.2.2)
#> readr * 2.1.3 2022-10-01 [1] CRAN (R 4.2.2)
#> readxl 1.4.1 2022-08-17 [1] CRAN (R 4.2.2)
#> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.2)
#> rlang 1.1.0 2023-03-14 [1] CRAN (R 4.2.3)
#> rmarkdown 2.18 2022-11-09 [1] CRAN (R 4.2.2)
#> robustbase 0.99-0 2023-06-16 [1] CRAN (R 4.2.3)
#> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.2)
#> rvest 1.0.3 2022-08-19 [1] CRAN (R 4.2.2)
#> scales 1.2.1 2022-08-20 [1] CRAN (R 4.2.2)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.2)
#> spacefillr 0.3.2 2022-10-25 [1] CRAN (R 4.2.3)
#> stringi 1.7.8 2022-07-11 [1] CRAN (R 4.2.1)
#> stringr * 1.5.0 2022-12-02 [1] CRAN (R 4.2.2)
#> tibble * 3.2.1 2023-03-20 [1] CRAN (R 4.2.3)
#> tidyr * 1.3.0 2023-01-24 [1] CRAN (R 4.2.3)
#> tidyselect 1.2.0 2022-10-10 [1] CRAN (R 4.2.2)
#> tidyverse * 1.3.2 2022-07-18 [1] CRAN (R 4.2.2)
#> timechange 0.1.1 2022-11-04 [1] CRAN (R 4.2.2)
#> tzdb 0.3.0 2022-03-28 [1] CRAN (R 4.2.2)
#> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.2.2)
#> uuid 1.1-0 2022-04-19 [1] CRAN (R 4.2.0)
#> vctrs 0.6.2 2023-04-19 [1] CRAN (R 4.2.3)
#> withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.2)
#> xfun 0.39 2023-04-20 [1] CRAN (R 4.2.3)
#> xml2 1.3.3 2021-11-30 [1] CRAN (R 4.2.2)
#> yaml 2.3.6 2022-10-18 [1] CRAN (R 4.2.2)
#>
#> [1] D:/toolSync/R/library
#>
#> ──────────────────────────────────────────────────────────────────────────────
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.