简体   繁体   English

mlr - 无法在 ranger_permutation 过滤器中使用参数“重要性”

[英]mlr - unable to use parameter 'importance' in ranger_permutation filter

When I try to use the filter 'ranger_permutation' and pass some parameters to the filter in makeFilterWrapper, I find that I cannot use the parameter 'importance' as that name is clashing with another parameter, but I cannot understand where or why.当我尝试使用过滤器'ranger_permutation'并将一些参数传递给makeFilterWrapper中的过滤器时,我发现我不能使用参数'importance',因为该名称与另一个参数冲突,但我不明白在哪里或为什么。 I get the following error message when I run the code below:运行以下代码时,我收到以下错误消息:

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

I get this error when using other base learners as well.使用其他基础学习器时,我也会收到此错误。 If I remove the parameter 'importance', the problem goes away, but not if I remove other parameters.如果我删除参数'importance',问题就会消失,但如果我删除其他参数则不会。 Also I can run ranger on its own, not as a filter, with the same parameters.我也可以使用相同的参数单独运行 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.

Created on 2019-09-25 by the reprex package (v0.3.0)reprex package (v0.3.0) 于 2019 年 9 月 25 日创建

When you set fw.method = "ranger_permutation" importance = "permutation" is already set internally.当您设置fw.method = "ranger_permutation" importance = "permutation"已在内部设置。 Therefore when you force importance = "permutation" it is defined two times (duplicated) and the error checking complains.因此,当您强制importance = "permutation"时,它会被定义两次(重复)并且错误检查会抱怨。

This can be seen from the mlr implementation: https://github.com/mlr-org/mlr/blob/master/R/Filter.R makeFilter(name = "ranger_permutation"... has importance = "permutation" already defined.这可以从 mlr 实现中看出: https://github.com/mlr-org/mlr/blob/master/R/Filter.R makeFilter(name = "ranger_permutation"... has importance = "permutation" already defined .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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