| oblique.tree.prune.nodes {oblique.tree} | R Documentation |
Prunes entire subtrees off objects of class c("oblique.tree","tree").
oblique.tree.prune.nodes(
tree,
list.of.node.names.to.prune)
tree |
Fitted model object of class oblique.tree. This is assumed to be the result of some function that produces an object with the same named components as that returned by oblique.tree. |
list.of.node.names.to.prune |
A list containing subtrees that are to be pruned. Each subtree is represented by a vector of its node names starting from its root to its the last node. |
The data structure representing objects of class c("oblique.tree","tree") need to be carefully manipulated to reflect the pruning of nodes. Rows of tree$frame are removed and tree$frame$var, tree$frame$splits, tree$where, tree$y tree$details need to be updated.
An object of class c("oblique.tree","tree") is return.
A. Truong
#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")
plot(ob.tree);title(main="Oblique Tree")
#prune 1 subtree
plot( oblique.tree:::oblique.tree.prune.nodes(
tree = ob.tree,
list.of.node.names.to.prune = list(c(5,10,11,22,23,46,47,94,95))
)
);title(main="Prune one Subtree")