1
$\begingroup$

When using random forests in R I came across the following situation:

    library(randomForest)
    set.seed(42)
    data(iris)
    rf_noImportance <- randomForest(Species~.,data=iris,ntree=100,importance=F)
    print(table(predict(rf_noImportance),iris$Species))

Output:

            setosa versicolor virginica
 setosa         50          0         0
 versicolor      0         47         3
 virginica       0          3        47

and

    library(randomForest)
    set.seed(42)
    data(iris)  
    rf_importance <- randomForest(Species~.,data=iris,ntree=100,importance=T)
    print(table(predict(rf_importance),iris$Species))

Output:

            setosa versicolor virginica
 setosa         50          0         0
 versicolor      0         47         4
 virginica       0          3        46

In the first example I set importance = FALSE and in the second example TRUE. From my understanding this should not affect the resulting prediction. There's also no indication for that behavior in the documentation.

According to this cross-validated post the importance flag should not influence the predictions, but it clearly does in the example above.

So why is the importance parameter of the randomForest method influencing the performance of the model?

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.