www.gusucode.com > stats 源码程序 matlab案例代码 > stats/ViewingAClassificationOrRegressionTreeExample.m

    %% Viewing a Classification or Regression Tree
% This example shows how to view a classification or a regression tree.
% There are two ways to view a tree: |view(tree)| returns a text
% description and |view(tree,'mode','graph')| returns a graphic description
% of the tree.
%%
% Create and view a classification tree.

% Copyright 2015 The MathWorks, Inc.

load fisheriris % load the sample data
ctree = fitctree(meas,species); % create classification tree
view(ctree) % text description
%%
view(ctree,'mode','graph') % graphic description
%%
% Now, create and view a regression tree.
load carsmall % load the sample data, contains Horsepower, Weight, MPG
X = [Horsepower Weight];
rtree = fitrtree(X,MPG,'MinParent',30); % create classification tree
view(rtree) % text description
%%
view(rtree,'mode','graph') % graphic description