[R] Get (feature, threshold) from Output of rpart() for Stump Tree

Terry Therneau therneau at mayo.edu
Fri May 8 14:05:44 CEST 2009


--- begin included message --
Hi, 
I have a question regarding how to get some partial information
from the output of rpart, which could be used as the first argument to
predict. For example, in my code, I try to learn a stump tree (decision
tree of depth 2):

   "fit        <- rpart(y~bx, weights = w/mean(w), control = cntrl)

--- end inclusion ---

 1. For stump trees, you can use the depth option in rpart.control to get a 
small tree.  You also might want to set maxsurrogate=0 for speed.
 
 2. Try help(rpart.object) for more information on what is contained in the 
returned rpart object.  In your case fit$splits[1,] would contain all that you 
need.
 
 	Terry T.
 	




More information about the R-help mailing list