MLR random forest multi label get feature importance

北战南征 提交于 2020-05-29 09:42:32

问题


I am using multilabel.randomForestSRC learner from mlr package for a multi-label classification problem I would like to return the variables importances

The getFeatureImportance function return this issue :

code:

getFeatureImportance(mod)

Error:

Error in checkLearner(object$learner, props = "featimp") : 
Learner 'multilabel.randomForestSRC' must support properties 'featimp', but does not support featimp'

回答1:


You can use extract the variable importance using randomForestSRC::vimp, using the example from here:

library(mlr)
yeast = getTaskData(yeast.task)
labels = colnames(yeast)[1:14]
yeast.task = makeMultilabelTask(id = "multi", data = yeast, target = labels)
lrn.rfsrc = makeLearner("multilabel.randomForestSRC")
mod2 = train(lrn.rfsrc, yeast.task)

vi =randomForestSRC::vimp(mod2$learner.model)
plot(vi,m.target ="label2")



来源:https://stackoverflow.com/questions/61754110/mlr-random-forest-multi-label-get-feature-importance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!