| plot.pptr | R Documentation |
Visualizes a pptr model. By default, shows a mosaic overview with tree
structure, decision boundaries, and variable importance. Use type
to show individual plots.
## S3 method for class 'pptr'
plot(x, type = NULL, metric = NULL, node = 1L, ...)
x |
A pptr model. |
type |
Character string specifying the plot type. |
metric |
Character string selecting a single importance metric
to plot: |
node |
Integer index of the node for projection plots (1-based, breadth-first
order). Defaults to 1 (root node). Only used when |
... |
Additional arguments passed to the internal plotting function. |
A ggplot2-compatible object (invisibly). The mosaic layout returns
a patchwork object that works with ggplot2::ggsave().
if (requireNamespace("ggplot2", quietly = TRUE) &&
requireNamespace("patchwork", quietly = TRUE)) {
model <- pptr(Species ~ ., data = iris)
plot(model) # mosaic overview
plot(model, type = "structure") # tree structure only
plot(model, type = "importance") # variable importance
plot(model, type = "projection") # projection histogram
plot(model, type = "boundaries") # decision boundaries
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.