How to use R Random forests to reduce attributes having no discrete classes?
-
02-10-2019 - |
Question
I want to use Random forests for attribute reduction. One problem I have in my data is that I don't have discrete class - only continuous, which indicates how example differs from 'normal'. This class attribute is a kind of distance from zero to infinity. Is there any way to use Random forest for such data?
Solution
That should be no problem -- RF will just switch to regression mode. Use randomForest
function from the randomForest
package.
To get object similarity with proximity=TRUE
argument, like:
randomForest(Sepal.Length~.,data=iris,proximity=TRUE)$proximity
To get node-purity (Gini-index like) attribute importance:
randomForest(Sepal.Length~.,data=iris)$importance[,"IncNodePurity"]
To get mean MSE increase (accuracy-decrease like) attribute importance:
randomForest(Sepal.Length~.,data=iris,importance=TRUE)$importance[,"%IncMSE"]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow