alejandro_hagan
alejandro_hagan

Reputation: 1003

How to visualize random forest model output in R?

Is there anyway to visualize a random forest output in R? I read a article that talks about the export_graphviz library in python that uses an output's n_estimators parameter to export the decision tree in a DOT format which then is used to generate a graphical representation of the decision tree.

Do we have anything like this in R?

Upvotes: 2

Views: 3619

Answers (1)

Emmanuel Hamel
Emmanuel Hamel

Reputation: 2213

Maybe you can consider something like

library(randomForest)
library(reprtree)

model <- randomForest(Species ~ ., data = iris, importance = TRUE, ntree = 500, mtry = 2, do.trace = 100)

reprtree:::plot.getTree(model)

(see https://stats.stackexchange.com/questions/41443/how-to-actually-plot-a-sample-tree-from-randomforestgettree)

Upvotes: 2

Related Questions