r语言 - 无法在筛选器中使用参数'importance' ranger_permutation



当我尝试使用过滤器"ranger_permutation"并将一些参数传递给makeFilterWrapper中的过滤器时,我发现我无法使用参数"重要性",因为该名称与另一个参数冲突,但我无法理解在哪里或为什么。运行下面的代码时,我收到以下错误消息:

Error in setHyperPars(learner = wl, ..., par.vals = par.vals): 
Assertion on 'parameter settings' failed: Must have unique names, but element 4 is duplicated

使用其他基本学习者时也收到此错误。如果我删除参数"重要性",问题就会消失,但如果我删除其他参数,问题就不会消失。此外,我可以使用相同的参数自行运行 ranger,而不是作为过滤器运行。

library(survival)
#> Warning: package 'survival' was built under R version 3.5.3
library(mlr)
#> Loading required package: ParamHelpers
data(veteran)
set.seed(24601)
task_id = "VET"
vet.task <- makeSurvTask(id = task_id, data = veteran, target = c("time", "status"))
vet.task <- createDummyFeatures(vet.task)
outer = makeResampleDesc("CV", iters=2, stratify=TRUE)

set.seed(24601, "L'Ecuyer") 
cox.lrn <- makeLearner(cl="surv.coxph", id = "Ranger_Cox", predict.type="response")
filt <- makeFilterWrapper(cox.lrn, fw.method="ranger_permutation", fw.abs=5, cache=TRUE, num.trees=1000, splitrule="maxstat", importance="permutation")
bmr = benchmark(filt, vet.task, outer, list(cindex), show.info = TRUE, models=TRUE, keep.extract=TRUE)      
#> Task: VET, Learner: Ranger_Cox.filtered
#> Resampling: cross-validation
#> Measures:             cindex
#> Error in setHyperPars(learner = wl, ..., par.vals = par.vals): Assertion on 'parameter settings' failed: Must have unique names, but element 4 is duplicated.

创建于 2019-09-25 由 reprex 软件包 (v0.3.0(

当您设置时fw.method = "ranger_permutation"importance = "permutation"已经在内部设置。因此,当您强制importance = "permutation"时,它会定义两次(重复(,并且错误检查会发出抱怨。

这可以从 mlr 实现中看出:https://github.com/mlr-org/mlr/blob/master/R/Filter.RmakeFilter(name = "ranger_permutation"...已经定义了importance = "permutation"

相关内容

  • 没有找到相关文章

最新更新