0
$\begingroup$

Let's say I'm using a random forest in a true/false classification problem.

When I produce a score for an observation is it possible to get some sort of metric of variable importance for that particular score?

I'd imagine this would be based on the observation's leaf locations across the ensemble.

$\endgroup$

1 Answer 1

1
$\begingroup$

Had you tried the importance function of the randomForest package? For example:

x <- randomForest(Species ~ ., data=iris, importance=TRUE,
             proximity=TRUE)
importance(x, type = 2)
# MeanDecreaseGini
# Sepal.Length         9.223181
# Sepal.Width          2.418925
# Petal.Length        40.900372
# Petal.Width         46.665629
$\endgroup$
5
  • $\begingroup$ That gives the importance for the overall model. My problem is, once you start scoring individual instances, can you get some measure of feature importance by instance? I thought I read somewhere that this might be possible with an alternating decision tree, but can't find the reference anymore. $\endgroup$
    – Luke
    Commented Dec 16, 2013 at 19:21
  • $\begingroup$ how so? Why couldn't you base importance on an observations path through the tree? $\endgroup$
    – Luke
    Commented Mar 7, 2014 at 0:57
  • $\begingroup$ True, but what about an aggregation of the values derived from the paths followed by an observation? $\endgroup$
    – Luke
    Commented Mar 7, 2014 at 1:20
  • $\begingroup$ @Luke somehow, you want to figure out which variables played the most important roles in generating the prediction for a given observation? $\endgroup$
    – Antoine
    Commented Aug 17, 2015 at 9:38
  • $\begingroup$ Yeah. That's what I'm looking for. $\endgroup$
    – Luke
    Commented Aug 17, 2015 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.