#grow a tree on the Pima Indian dataset
data(Pima.tr, package = "MASS")
ob.tree <- oblique.tree(formula = type~.,
data = Pima.tr,
oblique.splits = "only")
plot(ob.tree);text(ob.tree);title(main="Full Oblique Tree")
#partially trimming
#examine the tree sequence
trim.seq <- trim.oblique.tree( tree = ob.tree)
print(trim.seq);plot(trim.seq)
#examine test error over the trim sequence
data(Pima.te, package = "MASS")
trim.seq <- trim.oblique.tree( tree = ob.tree,
newdata = Pima.te)
print(trim.seq);plot(trim.seq)
#deviance is least when best = 7
p.trimmed <- trim.oblique.tree( tree = ob.tree,
best = 7)
plot(p.trimmed);text(p.trimmed);title(main="Partially Trimmed Tree")
#complete trimming
#examine the tree sequence
trim.seq <- trim.oblique.tree( tree = ob.tree,
trim.depth = "complete")
print(trim.seq);plot(trim.seq)
#examine test error over the trim sequence
data(Pima.te, package = "MASS")
trim.seq <- trim.oblique.tree( tree = ob.tree,
trim.depth = "complete",
newdata = Pima.te)
print(trim.seq);plot(trim.seq)
#deviance is least when best = 9
c.trimmed <- trim.oblique.tree( tree = ob.tree,
best = 9)
plot(c.trimmed);text(c.trimmed);title(main="Completely Trimmed Tree")
Run the code above in your browser using DataLab