2

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'
Mathilde
  • 23
  • 4
  • 1
    Welcome to SO. Please make your question reproducible: include a minimal dataset in the form of an object for example if a data frame as df <- data.frame(…) where … is your variables and values or use dput(head(df)). Include the code you have tried and set out your expected answer. Check out [mre] and [ask] – Peter May 12 '20 at 15:13
  • 1
    As the error tells you. There is no method in mlr for `multilabel.randomForestSRC` that extracts the feature importance. – jakob-r May 12 '20 at 16:09

1 Answers1

2

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")

enter image description here

StupidWolf
  • 45,075
  • 17
  • 40
  • 72