Description Usage Arguments Value Methods (by class) Examples
Takes a classification/regression tree (usually a list) and returns a
tibble::tibble()
with a row for each node including the set of additive
rules necessary to identify it. Furthermore, node characteristics and fit
details are described. Check https://github.com/bakaburg1/tidytrees for a
more detailed explanation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ## S3 method for class 'party'
tidy_tree(
tree,
rule_as_text = TRUE,
eval_ready = FALSE,
simplify_rules = FALSE,
add_estimates = TRUE,
add_interval = FALSE,
interval_level = 0.95,
est_fun = tidytrees::get_pred_estimates
)
## S3 method for class 'rpart'
tidy_tree(
tree,
rule_as_text = TRUE,
eval_ready = FALSE,
simplify_rules = FALSE,
add_estimates = TRUE,
add_interval = FALSE,
interval_level = 0.95,
est_fun = tidytrees::get_pred_estimates
)
tidy_tree(
tree,
rule_as_text = TRUE,
eval_ready = FALSE,
simplify_rules = FALSE,
add_estimates = TRUE,
add_interval = FALSE,
interval_level = 0.95,
est_fun = tidytrees::get_pred_estimates
)
|
tree |
A tree object. |
rule_as_text |
Whether to represent the rules as a string or a vector. |
eval_ready |
Converts the rules into R compatible logical expressions
ready to use for data filtering purposes. If |
simplify_rules |
Keep the minimal set of conditions to identify a node in the tree. |
add_estimates |
Add predicted values at each node, as computed by the
function passed to |
add_interval |
Logical indicating whether or not to include an
estimation interval, as computed by |
interval_level |
The interval level to use for the estimation interval
if |
est_fun |
Function to estimate node predictions and intervals. Must
expose three mandatory arguments: |
... |
Method specific arguments. Not used at the moment. |
A tibble with a row for each node with its identifying rule, the node
id (as stored in the tree object), the number of observations related to
the node, whether the node is terminal (a leaf), and the node depth. The
depth is counted starting from the children of the root node which are
considered at depth 1. The root node is ignored in the output. If
add_estimates = TRUE
, prediction estimates (optionally with intervals)
are added to each node, as defined by the function passed to the est_fun
argument.
party
: Turns a classification/regression tree produced by
partykit::ctree()
into a tidy tibble. Also trees of class
XML::XMLNode
and RWeka::Weka_tree
can be processed after conversion
with partykit::as.party()
(but results have not been tested yet).
rpart
: Turn a classification/regression tree produced by
rpart::rpart()
into a tidy tibble. At the moment, only the anova
and
class
methods are fully supported: other methods may work but users need
to ensure that the fit details are correct.
1 2 3 4 5 6 7 8 9 10 11 12 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.