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

    %% View Tree from Boosted Ensemble
%%
% Load the |carsmall| data set.  Consider a model that explains a car's
% fuel economy (|MPG|) using its weight (|Weight|) and number of cylinders
% (|Cylinders|). 
load carsmall
X = [Weight Cylinders];
Y = MPG;
%%
% Boost an ensemble of 100 regression trees using all measurements.
Mdl = fitensemble(X,Y,'LSBoost',100,'Tree');
%%
% |Mdl| is a <docid:stats_ug.bstzmcl-1 |RegressionEnsemble|> model object.
% |Mdl.Trained| stores the ensemble of 100 trained regression trees in a
% 100-by-1 cell array.  That is, each cell in |Mdl.Trained| contains a
% |CompactRegressionTree| model object.
%%
% View a graph of the 10th regression tree in the ensemble.
Tree10 = Mdl.Trained{10};
view(Tree10,'Mode','graph');
%%
% By default, |fitensemble| grows shallow trees for boosted ensembles of
% trees.