简体   繁体   中英

How to visualize trees and splitting values in Matlab's TreeBagger

I'm new to TreeBagger in Matlab. I devised 2 simple cases to learn TreeBagger (Random forest). Suppose the independent variable is z:

First case: 1 variable:

z = {'hi';'hi';'hi';'hi';'hi';'hi';'low';'low';'low';'low';'low';'low'};

and the predictor variables is x, and y:

x = [1 1 1 1 2 1 2 2 2 2 1 2];

Second Case: 2 variables

Same as before but with an additional variable y:

y = [1 1 1 2 1 1 2 1 2 2 1 2];

Solving for Case 1:

b = TreeBagger(1,x,y, 'Method','classification','NVarToSample',1,'oobpred','on');

What I want:

Case 1&2: Visualize the classification tree used (I chose one), and also to see the splitting threshold...

Somebody told me the answer. You can view the Tree 1 typing:

view(B.Trees{1})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM