2
$\begingroup$

I want to assess the importance of variables in my model using the Importance() function of R RandomForest package. I have a binary response variable / class and binary feature values.

mytree.rf <- randomForest(class ~ ., data=mydata, ntree=1500,keep.forest=FALSE,importance=TRUE)
importance(mytree.rf)

The output matrix contains the MeanDecreaseAccuracy and MeanDecreaseGini. I understand those two.

My problem is with two other columns in the output. One simply says "TRUE" the other one "FALSE". Neither in the documentation nor online I was able to find an answer what those values are and how they are calculated...

Can anyone help me out?

Cheers

Edit 1: Thanks to Davids answer I realized TRUE and FALSE are my class "names". I still don't understand how the value given in the matrix is calculated though... Can anyone help with that?

Edit 2: Thanks to David again, it turns out the answer is in the documentation. But it cannot be found in the chapter about the importance() function, but rather in the description of objects of class randomForest. Importance is one of these objects.

[...] a matrix with nclass + 2 (for classification) or two (for regression) columns. For classification, the first nclass columns are the class-specific measures computed as mean descrease in accuracy. The nclass + 1st column is the mean descrease in accuracy over all classes. The last column is the mean decrease in Gini index.

$\endgroup$
1
$\begingroup$

I don't see any columns like that. Here's a simple example:

library(randomForest)
data(iris)
iris.rf <- randomForest(Species ~ ., data=iris, importance=TRUE)
colnames(importance(iris.rf))

# [1] "setosa"               "versicolor"          
# [3] "virginica"            "MeanDecreaseAccuracy"
# [5] "MeanDecreaseGini" 

If you're seeing columns named "TRUE" and "FALSE" in the matrix returned by importance, my best guess is that those are the names of columns in your training data.

$\endgroup$
  • $\begingroup$ Thank you! You're absolutely right. TRUE and FALSE are my class "names". I still don't understand how the value is calculated though. Any idea about that? (I have some negative values in the column so it can't be the OOB error.) $\endgroup$ – AutoMiner Feb 9 '18 at 12:10
  • $\begingroup$ From the docs: "a matrix with nclass + 2 (for classification) or two (for regression) columns. For classification, the first nclass columns are the class-specific measures computed as mean descrease in accuracy. The nclass + 1st column is the mean descrease in accuracy over all classes. The last column is the mean decrease in Gini index." $\endgroup$ – David Marx Feb 10 '18 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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