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

    %% Estimate the Resubstitution Loss of a Boosting Ensemble
% Estimate the resubstitution loss of a trained, boosting classification
% ensemble of decision trees.
%%
% Load the |ionosphere| data set.

% Copyright 2015 The MathWorks, Inc.

load ionosphere;
%%
% Train a decision tree ensemble using AdaBoost, 100 learning cycles, and
% the entire data set.
ClassTreeEns = fitensemble(X,Y,'AdaBoostM1',100,'Tree');
%%
% |ClassTreeEns| is a trained |ClassificationEnsemble| ensemble classifier.
%%
% Determine the cumulative resubstitution losses (i.e., the
% cumulative misclassification error of the labels in the training data).
rsLoss = resubLoss(ClassTreeEns,'Mode','Cumulative');
%%
% |rsLoss| is a 100-by-1 vector, where element _k_ contains the
% resubstition loss after the first _k_ learning cycles.
%%
% Plot the cumulative resubstitution loss over the number of learning
% cycles.
plot(rsLoss);
xlabel('Number of Learning Cycles');
ylabel('Resubstitution Loss');
%%
% In general, as the number of decision trees in the trained classification
% ensemble increases, the resubstitution loss decreases.
%%
% A decrease in resubstitution loss might indicate that the software
% trained the ensemble sensibly.  However, you cannot infer the predictive
% power of the ensemble by this decrease. To measure the predictive
% power of an ensemble, estimate the generalization error by:
%
% # Randomly partitioning the data into training and cross-validation sets.
% Do this by specifying |'holdout',holdoutProportion| when you train the
% ensemble using |fitensemble|.
% # Passing the trained ensemble to |kfoldLoss|, which estimates the
% generalization error.