Node: Nodes and Splits in an rpart Tree

Description Usage Arguments Details Value Author(s) See Also Examples

Description

The rpart result object has a complex and compact design. This can make practical use tedious for occasional users as it is difficult to figure out how to access some specific information. The function Node() is designed as accessor to the most important properties of a node, being a 'split' or a 'leaf' (aka. 'endnode'). It also serves as base for further convenience functions as e.g. LeafRates().

Usage

1
Node(x, node = NULL, type = c("all", "split", "leaf"), digits = 3)

Arguments

x

fitted model object of class rpart.

node

integer vector, defining the nodes whose details are required.

type

one out of "all" (default), "split", "leaf", where the latter two restrict the result set to splits or end nodes only. Can be abbreviated.

digits

the number of digits for numeric values

Details

Node() returns detailed information for a single node in the tree. It reports all the data in the summary of a node, but with the option to provide a nodelist. The structure of the result is organised as a list.

Value

A list containing:

id

int, id of the node

vname

character, one out of 'leaf' or 'split'

isleaf

logical, TRUE for leaves FALSE else

nobs

integer, number of observation in the node

group

character, the predicted class for the node

ycount

numeric, the number of observation per class in the node

yprob

numeric, the relative frequencies for the each class

nodeprob

the global probability for an observation to fall in the node

complexity

numeric, the complexity parameter for the node

tprint

character, the text to be printed

Author(s)

Andri Signorell <andri@signorell.net>

See Also

LeafRates, Rules

Examples

1
2
3
4
5
6
7
r.rpart <- FitMod(Species ~ ., data=iris, fitfn="rpart")
# return Node nr. 3
Node(r.rpart, node=3)

r.rp <- FitMod(Type ~ ., data = d.glass, fitfn="rpart")
# return all the splits
Node(r.rpart, type="split")

ModTools documentation built on July 26, 2021, 9:06 a.m.