node_info_dt {lazy.tree}R Documentation

Display the Definition of the Node

Description

This function displays the definition of the specified nodes.
Japanese help file: node_info_dt_JPH

Usage

node_info_dt(
  obj,
  depth = 99999,
  node = NULL,
  nohist = 0,
  title = "",
  simplify = 1,
  print = 1,
  debug = 0
)

Arguments

obj

The output of DecTree or list of nodes.

depth

The depth

node

The node number
This has priority over depth.

nohist

= 1 not to calculate division history or node definition.

title

The title string

simplify

= 0 NOT to simplify the continuous regressor values.
(Opt for this option when you notice something unusual about the results.)

print

= 1 to output node_info

debug

= 1 to print intermediate info

Value

A list of

NodeInfo

Node       the node number.
PA         the parent number.
N          number of observations in the node.
Score      weighted impurity measure of the node.
ImpMeasure impurity measure of the node (score divided by # of obs)
SplitVar   the splitting variable number of this node
           to be used to divide THIS node.
LR         = "L" if the node is the left node of the parent.
Leaf       = 1 if the node is a leaf node.
Yhat       the predicted value at the leaf nodes
Prob       the predicted probability at the leaf nodes

NodeHist A list of division history of each node.

Depth  the depth level
Parent the parent of the leaf at depth Depth
J      the regressor variable number used to divide Parent
Jn     the name of the regressor J
Ncx    the # of levels of regressor J
LR     = "L" if this leaf node is classified as Left
SW     = 1 if the Left and the Right were switched
Score  obs. weighted impurity score
ImpMesure impurity score (divided by nobs)
Valxj._v_1, Valxj._v_2, ...  The value of the categorical regressor J

and
NodeDef A list of node definition of each node.

Examples

# categorical y, continuous X1 and categorical X2
SQ2 <- matrix(square$class4, 4,, byrow=1)
heatmap( SQ2, Rowv=NA, Colv=NA, reorderfun=NA, symm=1
         , col=c("darkred","darkgreen","orange","lightblue")
         , labRow=LETTERS[1:4], labCol=1:4 )
legend( "left", legend=1:4, pch=1,cex=2, pt.lwd=2, box.lwd=2
        , col=c("darkred","darkgreen","orange","lightblue") )
Xc <- data.frame(x1=square$x1,x2=square$c2)
yc <- as.factor(square$class4)

# specify plot=1 or use plot_dt if the package igraph is installed.
res0 <- DecTree( yc, Xc, maxdepth=4, method=4, print=1, impfuncname="gini"
                 , plot=0, title="square: numerical X1, categorical X2" )
# plot_dt(res0, col_leaf=c("darkred","darkgreen","orange","lightblue","red")
#       , title="square: numerical X1, categorical X2" )

# nodes at depth 2
temp <- node_info_dt( res0, depth=2, title="depth" )
# nodes 4, 15, and 24
temp <- node_info_dt( res0, node=c(8,19,21), title="node" )

# leaf node info of the above tree
info0 <- node_info_dt( res0, depth=99, print=2, title="num X1 and cat X2" )

res1 <- DecTree( yc, data.frame(x1=square$x1,x2=square$x2)
                 , maxdepth=4, method=4, print=1, impfuncname="gini"
                 , plot=0, title="square: numeric X1 and X2" )
# plot_dt( res1, col_leaf=c("darkred","darkgreen","orange","lightblue","red")
#       , title="square: numeric X1 and X2" )
info1 <- node_info_dt( res1, depth=99, print=2, title="num X1 and num X2" )

res2 <- DecTree( yc, data.frame(x1=square$c1,x2=square$c2)
                 , maxdepth=4, method=4, print=1, impfuncname="gini"
                 , plot=0, title="square: categorical X1 and X2" )
# plot_dt( res2, col_leaf=c("darkred","darkgreen","orange","lightblue","red")
#       , title="square: categorical X1 and X2" )
info2 <- node_info_dt( res2, depth=99, print=2, title="cat X1 and cat X2" )



[Package lazy.tree version 0.1.5 ]