Learn R Programming

iml (version 0.6.0)

plot.TreeSurrogate: Plot Tree Surrogate

Description

Plot the response for newdata of a TreeSurrogate object. Each plot facet is one leaf node and visualises the distribution of the \(\hat{y}\) from the machine learning model.

Usage

# S3 method for TreeSurrogate
plot(object)

Arguments

object

A TreeSurrogate R6 object

Value

ggplot2 plot object

See Also

TreeSurrogate

Examples

Run this code
# NOT RUN {
if (require("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) 
}
# }

Run the code above in your browser using DataLab