Calculating Variable Importance with Random Forest

In random forest, you can calculate important variables with IMPORTANCE= TRUE parameter.

R Code : Variable Importance
library(caret)
rfTune <- train(dev[, -1], dev[,1], method = "rf", ntree = 100, importance = TRUE)

MeanDecreaseAccuracy table represents how much removing each variable reduces the accuracy of the model.

Selecting top 10 variables
ImportanceOrder <- order(rfTune$finalModel$importance[,1],decreasing = TRUE)
top10 <- rownames(rfTune$finalModel$importance[ImportanceOrder,])[1:10]
subsetimp <- subset(training, select = top10)
Spread the Word!
Share
Related Posts
About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and Human Resource.

0 Response to "Calculating Variable Importance with Random Forest"

Post a Comment

Next → ← Prev

Looks like you are using an ad blocker!

To continue reading you need to turnoff adblocker and refresh the page. We rely on advertising to help fund our site. Please whitelist us if you enjoy our content.