tree.impurity {oblique.tree} | R Documentation |
Determines the impurity of a subtree.
tree.impurity( yprob, number.of.observations.at.leaves, leaf.classes, impurity.measure = c("deviance","misclass"))
yprob |
A matrix of predicted class probabilities of leaves of the subtree considered in order of tree-growth (left to right). |
number.of.observations.at.leaves |
A vector denoting the number of observations at each of these leaves. |
leaf.classes |
A vector denoting the classes associated to these leaves. |
impurity.measure |
Character string denoting the measure of node heterogeneity to be used to guide cost-complexity pruning/trimming. |
R_α(T) = R(T) + α size(T)
When pruning and trimming trees, R(T) must be evaluated. Extracted arguments from oblique.tree
objects is easiest.
The impurity of the subtree.
A. Truong
Ripley, B. D. (1996). Pattern Recognition and Neural Networks. Cambridge University Press, Cambridge. Chapter 7.
#grow a tree on the Pima Indian dataset data(Pima.tr, package = "MASS") ob.tree <- oblique.tree(formula = type~., data = Pima.tr, oblique.splits = "on") #deviance of entire tree subtree.leaves <- ob.tree$frame$var == "<leaf>" oblique.tree:::tree.impurity( yprob = ob.tree$frame$yprob[subtree.leaves,,drop=FALSE], number.of.observations.at.leaves = ob.tree$frame$n[subtree.leaves], leaf.classes = ob.tree$frame$yval[subtree.leaves], impurity.measure = "deviance")