#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