View source: R/TreeSurrogate.R
plot.TreeSurrogate | R Documentation |
Plot the response for newdata
of a TreeSurrogate object.
Each plot facet is one leaf node and visualizes the distribution of the
\hat{y} from the machine learning model.
## S3 method for class 'TreeSurrogate' plot(object)
object |
A TreeSurrogate object. |
ggplot2 plot object
TreeSurrogate
library("randomForest") # Fit a Random Forest on the Boston housing data set data("Boston", package = "MASS") rf <- randomForest(medv ~ ., data = Boston, ntree = 50) # Create a model object mod <- Predictor$new(rf, data = Boston[-which(names(Boston) == "medv")]) # Fit a decision tree as a surrogate for the whole random forest dt <- TreeSurrogate$new(mod) # Plot the resulting leaf nodes plot(dt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.