rmultilabel-classificationmlr

MLR random forest multi label get feature importance


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'

Solution

  • 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