Skip to content

Instantly share code, notes, and snippets.

@ramhiser
ramhiser / random-forest.r
Created October 22, 2014 21:57
Plots Variable Importance from Random Forest in R
library(randomForest)
library(dplyr)
library(ggplot2)
set.seed(42)
rf_out <- randomForest(Species ~ ., data=iris)
# Extracts variable importance (Mean Decrease in Gini Index)
# Sorts by variable importance and relevels factors to match ordering