mlr3中带分支的GraphLearner调优结果如何解读?

How to interpret the tuning result of the GraphLearner with branches in mlr3?

最近我跟着一些教程学习了如何在mlr3中使用GraphLearner。但是我仍然对GraphLearner with branch的调优结果感到困惑。我建立了一个简单的例子,这是我的代码:

# Create a Graph with Branch
graph_branch <- 
  po("branch", c("nop", "pca", "scale"), id = "preprocess_branch") %>>%
  gunion(list(
    po("nop"),
    po("pca", id = "pca1"),
    po("scale") %>>% po("pca", id = "pca2")
    )) %>>%
  po("unbranch", id = "preprocess_unbranch") %>>%
  po("branch", c("classif.kknn", "classif.featureless"), id = "lrn_branch") %>>%
  gunion(list(
    lrn("classif.kknn", predict_type = "prob"),
    lrn("classif.featureless", predict_type = "prob")
    )) %>>%
  po("unbranch", id = "lrn_unbranch")

# Convert a graph to a learner
graph_branch_lrn <- as_learner(graph_branch)
graph_branch_lrn$graph$plot()

# Set the tuning grid
tune_grid <- ParamSet$new(
  list(
  ParamFct$new("preprocess_branch.selection", levels = c("nop", "pca", "scale")),
  ParamInt$new("pca1.rank.", lower = 1, upper = 10),
  ParamInt$new("pca2.rank.", lower = 1, upper = 10),
  ParamFct$new("lrn_branch.selection", levels = c("classif.kknn", "classif.featureless")),
  ParamInt$new("classif.kknn.k", lower = 1, upper = 10)
  ))

# Set the instance
instance_rs <- TuningInstanceSingleCrit$new(
  task = task_train,
  learner = graph_branch_lrn,
  resampling = rsmp("cv", folds = 5),
  measure = msr("classif.auc"),
  search_space = tune_grid,
  terminator = trm("evals", n_evals = 20)
  )

# Random search tuning
tuner_rs <- tnr("random_search")
plan(multisession, workers = 5)
set.seed(100)
tuner_rs$optimize(instance_rs)
plan(sequential)

最佳调优结果为:

# Check the result
instance_rs$result_learner_param_vals

$preprocess_branch.selection
[1] "nop"

$scale.robust
[1] FALSE

$lrn_branch.selection
[1] "classif.kknn"

$classif.featureless.method
[1] "mode"

$pca1.rank.
[1] 9

$pca2.rank.
[1] 9

$classif.kknn.k
[1] 9

我想知道如果它选择了“nop”分支,为什么调优结果是“pca1.rank”。和“pca2.rank”。出现?我以前认为GraphLearner with branch的调优会根据分支选择最好的结果,比如如果选择了“nop”分支,其他分支的参数就不会考虑而出现在流程中。是我对 GraphLearner 调优机制的解释有问题还是代码有问题?

你没有做错任何事;输出只显示 all 超参数的最佳值。并非所有这些都相关 - 在这里,您可以简单地忽略 scalepca1pca2.

的值