-
-
Notifications
You must be signed in to change notification settings - Fork 405
Closed
Labels
Description
Description
configureMLR()
only gets run when MLR is attached (.onAttach()
), not when it is just loaded (.onLoad()
). This causes problems when developing packages that depend on MLR because unless we run require(mlr)
or library(mlr)
, the options are not set, and some MLR functions may break (e.g. predict()
).
Reproducible example
This part is hard because a package must be built to recreate the bug. Essentially, if when you do something like this inside a package it will fail because predict()
uses parameters that aren't set (namely show.learner.output
). If we require(mlr)
inside use_predictions()
, everything works as expected.
#' Example from mlr.mlr-org.com
#' @import mlr
run_model <- function() {
# Generate the task
task = makeClassifTask(data = iris, target = "Species")
# Generate the learner
lrn = makeLearner("classif.lda")
# Train the learner
mod = train(lrn, task)
}
#' @import mlr
use_predictions <- function() {
table(predict(run_model(), newdata = iris)$data$response)
}
Created on 2019-05-17 by the reprex package (v0.2.1)
Session info
show.learner.output
#> Error in eval(expr, envir, enclos): object 'show.learner.output' not found
Created on 2019-05-17 by the reprex package (v0.2.1)
Session info
devtools::session_info()
#> - Session info ----------------------------------------------------------
#> setting value
#> version R version 3.5.3 (2019-03-11)
#> os Windows 10 x64
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.1252
#> ctype English_United States.1252
#> tz America/Mexico_City
#> date 2019-05-17
#>
#> - Packages --------------------------------------------------------------
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.3)
#> backports 1.1.4 2019-04-10 [1] CRAN (R 3.5.3)
#> callr 3.2.0 2019-03-15 [1] CRAN (R 3.5.3)
#> cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.3)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.3)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.3)
#> devtools 2.0.2 2019-04-08 [1] CRAN (R 3.5.3)
#> digest 0.6.18 2018-10-10 [1] CRAN (R 3.5.3)
#> evaluate 0.13 2019-02-12 [1] CRAN (R 3.5.3)
#> fs 1.2.7 2019-03-19 [1] CRAN (R 3.5.3)
#> glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.3)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.5.3)
#> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.3)
#> knitr 1.22 2019-03-08 [1] CRAN (R 3.5.3)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.3)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.3)
#> pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.5.3)
#> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.3)
#> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.3)
#> processx 3.3.0 2019-03-10 [1] CRAN (R 3.5.3)
#> ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.3)
#> R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.3)
#> Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.3)
#> remotes 2.0.4 2019-04-10 [1] CRAN (R 3.5.3)
#> rlang 0.3.4 2019-04-07 [1] CRAN (R 3.5.3)
#> rmarkdown 1.12 2019-03-14 [1] CRAN (R 3.5.3)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.3)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.3)
#> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.5.3)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.5.3)
#> testthat 2.1.1 2019-04-23 [1] CRAN (R 3.5.3)
#> usethis 1.5.0 2019-04-07 [1] CRAN (R 3.5.3)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.3)
#> xfun 0.6 2019-04-02 [1] CRAN (R 3.5.3)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.3)
#>
#> [1] C:/Users/f0g00bq/Documents/R/R-3.5.3/library
Expected output
Just add configureMLR()
to MLR's .onLoad()
!