MATLAB: Visualize a tree and splitting point in TreeBagger

classificationrandom foresttreetreebagger

Hi, Suppose I fit a TreeBagger with 2 column predictor variables X:
B = TreeBagger(1,X,y, 'Method','classification','NVarToSample',1,'oobpred','on')
I want to visualize any tree that I choose, and the splitting values. How can I do that? Thanks!

Best Answer

doc TreeBagger and take a look at the Trees property. For example, to see the first tree
view(B.Trees{1})