简体   繁体   中英

How to map transform in r-drake

May i ask how to use function GraphLearner$new to transform in r-drake. The codes following:

learner_plan = drake_plan(
  ## 1. Choose learner--------------------------------------------------------
  polrn_classif = target(fnc_po_learner(list_learners),
                         transform = map(
                           list_learners = c(
                             "classif.ranger",
                             "classif.lightgbm",
                             "classif.xgboost",
                             "classif.log_reg",
                             "classif.svm"
                           )
                         )),
  graph_classif = target(
    imputer_classif %>>% filter_classif %>>% polrn_classif,
    transform = map(polrn_classif)
  ),
  glrn_classif = target({
    GraphLearner$new(graph = graph_classif) # get error ---------- it's not transform
    transform = map(graph_classif)
  })
)

learner_plan 

transform = map(graph_classif) should go outside the curly braces.

library(drake)
learner_plan = drake_plan(
  polrn_classif = target(
    fnc_po_learner(list_learners),
    transform = map(
      list_learners = c(
        "classif.ranger",
        "classif.lightgbm",
        "classif.xgboost",
        "classif.log_reg",
        "classif.svm"
      )
    )
  ),
  graph_classif = target(
    imputer_classif %>>% filter_classif %>>% polrn_classif,
    transform = map(polrn_classif)
  ),
  glrn_classif = target({
    GraphLearner$new(graph = graph_classif)
  }, transform = map(graph_classif)) # outside the curly braces
)

plot(learner_plan)

Created on 2021-07-07 by the reprex package (v2.0.0)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM