
These functions expect the obj$frame representation of the tree.
Visualize decision tree code#
The key functions are a generic tree:::ee method (I put a triple : which allows you to view the code in R directly) relying on tree:::treepl (graphical display) and tree:::treeco (compute nodes coordinates). Then, there are methods for pretty printing and plotting those objects. classification-where in the later case it will add class-specific probabilities as the last column of the obj$frame (which is a ame). Please note that it will slightly differ depending of the type of task-regression vs. Basically, it is easy to access the tree structure from a tree object, as shown below. The idea would be to convert the output of randomForest::getTree to such an R object, even if it is nonsensical from a statistical point of view. Second (almost as easy) solution: Most of tree-based techniques in R ( tree, rpart, TWIX, etc.) offers a tree-like structure for printing/plotting a single tree. , data=iris, controls=cforest_control(mtry=2, mincriterion=0)). Below is a plot of one tree generated by cforest(Species ~. It seems to run smoothly, as far as I can tell. Then, as reported on this R-help post, you can plot a single member of the list of trees. First (and easiest) solution: If you are not keen to stick with classical RF, as implemented in Andy Liaw's randomForest, you can try the party package which provides a different implementation of the original RF algorithm (use of conditional trees and aggregation scheme based on units weight average).
