oblique.tree (version 1.1.1)

tree.impurity: Internal Function that Determines the Impurity of a Subtree

Description

Determines the impurity of a subtree.

Usage

tree.impurity(
	yprob, 
	number.of.observations.at.leaves, 
	leaf.classes, 
	impurity.measure = c("deviance","misclass"))

Arguments

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.

Value

  • The impurity of the subtree.

Details

$$R_\alpha(T) = R(T) + \alpha size(T)$$ When pruning and trimming trees, $R(T)$ must be evaluated. Extracted arguments from oblique.tree objects is easiest.

References

Ripley, B. D. (1996). Pattern Recognition and Neural Networks. Cambridge University Press, Cambridge. Chapter 7.

See Also

oblique.tree.

Examples

Run this code
#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")

Run the code above in your browser using DataLab