plot.Treee {LDATree} | R Documentation |
Plot a Treee object
Description
Provide a diagram of the whole tree structure or a scatter/density plot for a specific tree node.
Usage
## S3 method for class 'Treee'
plot(x, data, node = -1, ...)
Arguments
x |
a fitted model object of class |
data |
the original data you used to fit the |
node |
the node index that you are interested in. By default, it is set
to |
... |
further arguments passed to or from other methods. |
Value
For overall tree structure (node = -1
), A figure of class
visNetwork
is drawn. Otherwise, a figure of class ggplot
is drawn.
Overall tree structure
A full tree diagram (via the R package visNetwork) is shown if node
is
not provided (default is -1
). The color shows the most common (plurality)
class inside each node. The size of each terminal node is based on its
relative sample size. Under every node, you see the plurality class, the
fraction of the correctly predicted training sample vs. the node's sample
size, and the node index, respectively. When you click on the node, an
information panel with more details will appear.
Individual plot for each node
The node index and the original training data are required to return a more detailed plot within a specific node. The density plot will be provided when only two levels are left for the response variable in a node (like in a binary classification problem). Samples are projected down to their first linear discriminant scores (LD1). A scatter plot will be provided if a node contains more than two classes. Samples are projected down to their first and second linear discriminant scores.
Examples
fit <- Treee(Species~., data = iris)
# plot the overall tree
plot(fit)
# plot a certain node
plot(fit, iris, node = 1)