Create a data frame that sums up a CART tree obtained with the function in the rpart package
calcul_cart(cart, data)
| cart | an rpart object |
|---|---|
| data | the data used to create the rpart object. It must be a data frame |
tableau a data frame that sums up the CARt tree:
- node_name_cart: node number
- parent: ancestor of the node
- depth: depth of the node
- var: name of the splitting variables
- threshold: splitting value
- n: number of obsevations in the node
- pred: label of the node
- n_case: number of observation with "Y=1" in the node
- n_noncase: number of observation with "Y=0" in the node
- prob = P[Y=1|N]: empirical probability that in the node an observation belongs to the label "Y=1"
- sens: direction for the decision rule. Observation with "x<threshold" are sent to the left node and observations with "x>=threshold" are sent to the right node.
WARNING: the option 'control=rpart.control(maxsurrogate=0, maxcompte=0)' must be used in the function rpart when building the rpart object. Otherwise the result returned by the function may be incorrect