The below code works fine, however, I am interested to run it in parallel. I have tried different plans within future
and future.apply
but couldn't managed. Any help appreciated.
I am running on windows OS, 8 cores.
library(mlr3verse)
library(future.apply)
#> Warning: package 'future.apply' was built under R version 3.6.3
#> Loading required package: future
#> Warning: package 'future' was built under R version 3.6.3
library(future)
future::plan(multicore)
tsk_clf = tsk("sonar")
tsk_clf$col_roles$stratum = tsk_clf$target_names #stratification
lda = lrn("classif.lda", predict_type = "response")
svm = lrn("classif.svm", type = "C-classification", kernel= "radial",predict_type = "response")
xgb = lrn("classif.xgboost", predict_type = "response")
ranger_lrn = lrn("classif.ranger", predict_type = "response",importance ="permutation")
level_1 =
gunion(list(
PipeOpLearnerCV$new(lda, id = "lda_cv_l1"),
PipeOpLearnerCV$new(svm, id = "svm_cv_l1"),
PipeOpLearnerCV$new(xgb, id = "xgb_cv_l1")
))
level_2 = level_1 %>>%
PipeOpFeatureUnion$new(3, id = "u2") %>>%
PipeOpLearner$new(ranger_lrn,
id = "ranger_l2")
lrn = GraphLearner$new(level_2)
lrn$
train(tsk_clf)$
predict(tsk_clf)$
score()
#> INFO [17:04:06.984] Applying learner 'classif.lda' on task 'sonar' (iter 3/3)
#> INFO [17:04:07.052] Applying learner 'classif.lda' on task 'sonar' (iter 1/3)
#> INFO [17:04:07.097] Applying learner 'classif.lda' on task 'sonar' (iter 2/3)
#> INFO [17:04:07.340] Applying learner 'classif.svm' on task 'sonar' (iter 1/3)
#> INFO [17:04:07.382] Applying learner 'classif.svm' on task 'sonar' (iter 2/3)
#> INFO [17:04:07.430] Applying learner 'classif.svm' on task 'sonar' (iter 3/3)
#> INFO [17:04:08.627] Applying learner 'classif.xgboost' on task 'sonar' (iter 3/3)
#> INFO [17:04:08.672] Applying learner 'classif.xgboost' on task 'sonar' (iter 2/3)
#> INFO [17:04:08.715] Applying learner 'classif.xgboost' on task 'sonar' (iter 1/3)
#> classif.ce
#> 0.01923077
Created on 2020-12-15 by the reprex package (v0.3.0)
devtools::session_info()
#> - Session info ----------------------------------------------------------
#> setting value
#> version R version 3.6.1 (2019-07-05)
#> os Windows 10 x64
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.1252
#> ctype English_United States.1252
#> tz Europe/Berlin
#> date 2020-12-15
#>
#> - Packages --------------------------------------------------------------
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.0)
#> backports 1.1.4 2019-04-10 [1] CRAN (R 3.6.0)
#> bbotk 0.2.0 2020-07-24 [1] CRAN (R 3.6.3)
#> callr 3.5.1 2020-10-13 [1] CRAN (R 3.6.3)
#> checkmate 2.0.0 2020-02-06 [1] CRAN (R 3.6.3)
#> class 7.3-17 2020-04-26 [1] CRAN (R 3.6.3)
#> cli 2.1.0 2020-10-12 [1] CRAN (R 3.6.3)
#> codetools 0.2-16 2018-12-24 [1] CRAN (R 3.6.0)
#> colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.6.3)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.0)
#> data.table 1.13.0 2020-07-24 [1] CRAN (R 3.6.3)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.3)
#> devtools 2.3.2 2020-09-18 [1] CRAN (R 3.6.3)
#> digest 0.6.18 2018-10-10 [1] CRAN (R 3.6.0)
#> dplyr 1.0.2 2020-08-18 [1] CRAN (R 3.6.3)
#> e1071 1.7-3 2019-11-26 [1] CRAN (R 3.6.3)
#> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 3.6.3)
#> evaluate 0.13 2019-02-12 [1] CRAN (R 3.6.0)
#> fansi 0.4.0 2018-10-05 [1] CRAN (R 3.6.0)
#> fs 1.5.0 2020-07-31 [1] CRAN (R 3.6.3)
#> future * 1.18.0 2020-07-09 [1] CRAN (R 3.6.3)
#> future.apply * 1.6.0 2020-07-01 [1] CRAN (R 3.6.3)
#> generics 0.1.0 2020-10-31 [1] CRAN (R 3.6.3)
#> ggplot2 3.3.2 2020-06-19 [1] CRAN (R 3.6.3)
#> globals 0.12.5 2019-12-07 [1] CRAN (R 3.6.1)
#> glue 1.4.2 2020-08-27 [1] CRAN (R 3.6.3)
#> gtable 0.3.0 2019-03-25 [1] CRAN (R 3.6.3)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.6.0)
#> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.6.0)
#> knitr 1.22 2019-03-08 [1] CRAN (R 3.6.0)
#> lattice 0.20-41 2020-04-02 [1] CRAN (R 3.6.3)
#> lgr 0.3.4 2020-03-20 [1] CRAN (R 3.6.3)
#> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 3.6.3)
#> listenv 0.8.0 2019-12-05 [1] CRAN (R 3.6.3)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.0)
#> MASS 7.3-52 2020-08-18 [1] CRAN (R 3.6.3)
#> Matrix 1.2-18 2019-11-27 [1] CRAN (R 3.6.3)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.3)
#> mlr3 * 0.5.0 2020-08-07 [1] CRAN (R 3.6.3)
#> mlr3filters * 0.3.0 2020-07-18 [1] CRAN (R 3.6.3)
#> mlr3learners * 0.3.0 2020-08-29 [1] CRAN (R 3.6.3)
#> mlr3measures 0.2.0 2020-06-27 [1] CRAN (R 3.6.3)
#> mlr3misc 0.5.0 2020-08-13 [1] CRAN (R 3.6.3)
#> mlr3pipelines * 0.2.1 2020-08-18 [1] CRAN (R 3.6.3)
#> mlr3tuning * 0.2.0 2020-07-28 [1] CRAN (R 3.6.3)
#> mlr3verse * 0.1.3 2020-07-06 [1] CRAN (R 3.6.3)
#> mlr3viz * 0.4.0 2020-10-05 [1] CRAN (R 3.6.3)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.6.3)
#> paradox * 0.4.0 2020-07-21 [1] CRAN (R 3.6.3)
#> pillar 1.4.6 2020-07-10 [1] CRAN (R 3.6.3)
#> pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 3.6.3)
#> pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.6.0)
#> pkgload 1.1.0 2020-05-29 [1] CRAN (R 3.6.3)
#> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.6.0)
#> processx 3.4.4 2020-09-03 [1] CRAN (R 3.6.3)
#> ps 1.3.4 2020-08-11 [1] CRAN (R 3.6.3)
#> purrr 0.3.4 2020-04-17 [1] CRAN (R 3.6.3)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.3)
#> ranger 0.12.1 2020-01-10 [1] CRAN (R 3.6.3)
#> Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.6.0)
#> remotes 2.2.0 2020-07-21 [1] CRAN (R 3.6.3)
#> rlang 0.4.7 2020-07-09 [1] CRAN (R 3.6.3)
#> rmarkdown 1.12 2019-03-14 [1] CRAN (R 3.6.0)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.0)
#> scales 1.1.1 2020-05-11 [1] CRAN (R 3.6.3)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.3)
#> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.6.0)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.6.0)
#> testthat 2.3.2 2020-03-02 [1] CRAN (R 3.6.3)
#> tibble 3.0.4 2020-10-12 [1] CRAN (R 3.6.3)
#> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 3.6.3)
#> usethis 1.6.3 2020-09-17 [1] CRAN (R 3.6.3)
#> uuid 0.1-4 2020-02-26 [1] CRAN (R 3.6.3)
#> vctrs 0.3.4 2020-08-29 [1] CRAN (R 3.6.3)
#> withr 2.3.0 2020-09-22 [1] CRAN (R 3.6.3)
#> xfun 0.6 2019-04-02 [1] CRAN (R 3.6.0)
#> xgboost 1.2.0.1 2020-09-02 [1] CRAN (R 3.6.3)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.6.0)
#>
#> [1] C:/Users/mshey/Anaconda3/envs/rstudio/lib/R/library
Looks fine to me. Note that
multicore
mode is not available on Windows and falls back tosequential
. Might this be the culprit here?PS: Next time you face a parallelization/runtime issue, benchmarking the runtime might help ;)
Created on 2020-12-20 by the reprex package (v0.3.0)
Session info