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

    %% Estimate In-Sample Classification Margins of SVM Classifiers
%%
% Load the |ionosphere| data set.

% Copyright 2015 The MathWorks, Inc.

load ionosphere
%%
% Train an SVM classifier. It is good practice to specify the class order
% and standardize the data.
SVMModel = fitcsvm(X,Y,'ClassNames',{'b','g'},'Standardize',true);
%%
% |SVMModel| is a |ClassificationSVM| classifier. The negative class is
% |'b'| and the positive class is |'g'|.
%%
% Estimate the in-sample classification margins.
m = resubMargin(SVMModel);
m(10:20)
%%
% An observation margin is the observed (true) class score minus the maximum
% false class score among all scores in the respective class.  Classifiers
% that yield relatively large margins are desirable.