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

    %% Estimate In-Sample Classification Margins 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 in-sample classification margins. Display the distribution
% of the margins using a boxplot.
m = resubMargin(Mdl);

figure;
boxplot(m);
title 'In-Sample Margins'
%%
% An observation margin is the positive-class, negated loss minus the
% maximum negative-class, negated loss.  Classifiers that yield
% relatively large margins are desirable.