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

    %% Create a Classification Template with Surrogate Splits  
% Create a decision tree template with surrogate splits, and use the template
% to train an ensemble using sample data.   

% Copyright 2015 The MathWorks, Inc.


%%
% Load Fisher's iris data set.
load fisheriris

%% 
% Create a decision tree template with surrogate splits. 
t = templateTree('Surrogate','on')
%%
% All options of the template object are empty except for |Surrogate|. When
% you pass |t| to the training function, the software fills in the empty
% options with their respective default values.
%% 
% Specify |t| as a weak learner for a classification ensemble. 
Mdl = fitensemble(meas,species,'AdaBoostM2',100,t)   
%%
% Display the in-sample (resubstitution) misclassification error.
L = resubLoss(Mdl)