0

请问如何GraphLearner$new在 r-drake 中使用函数进行转换。以下代码:

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 
4

1 回答 1

1

transform = map(graph_classif)应该在花括号之外。

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)

reprex 包于 2021-07-07 创建 (v2.0.0 )

于 2021-07-07T10:15:01.350 回答