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

    %% Determine the Resubstitution Loss of ECOC Models
%%
% Load Fisher's iris data set.

% Copyright 2015 The MathWorks, Inc.

load fisheriris
X = meas;
Y = species;
%%
% Train an ECOC model using SVM binary classifiers. It is good practice to
% standardize the predictors and define the class order. Specify to
% standardize the predictors using an SVM template.
t = templateSVM('Standardize',1);
classOrder = unique(Y)
Mdl = fitcecoc(X,Y,'Learners',t,'ClassNames',classOrder);
%%
% |t| is an SVM template object. The software uses default values for empty
% options in |t| during training. |Mdl| is a |ClassificationECOC| model.
%%
% Estimate the resubstitution loss (i.e., the in-sample classification
% error).
L = resubLoss(Mdl)
%%
% The ECOC model misclassifies 2.67% of the training sample irises.