oblique.tree (version 1.1.1)

oblique.tree.prune.nodes: Internal Function that Prunes Oblique Tree Objects

Description

Prunes entire subtrees off objects of class c("oblique.tree","tree").

Usage

oblique.tree.prune.nodes( tree, list.of.node.names.to.prune)

Arguments

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.

Value

An object of class c("oblique.tree","tree") is return.

Details

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.

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")
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")

Run the code above in your browser using DataLab