Skip to content

Instantly share code, notes, and snippets.

@highclef93
highclef93 / random-forest.r
Created December 11, 2022 11:54 — forked from ramhiser/random-forest.r
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