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

    %% Monitor Training of an SVM Classifier
%%
% Load the |ionosphere| data set.

% Copyright 2015 The MathWorks, Inc.

load ionosphere
%%
% Train an SVM classifier. For illustration, specify that the optimization
% routine uses at most 100 iterations. Monitor the algorithm specifying
% that the software prints diagnostic inofrmation every |50| iterations.
SVMModel = fitcsvm(X,Y,'IterationLimit',100,'Verbose',1,'NumPrint',50);
%%
% The software prints an iterative display to the Command Window.  The
% printout indicates that the optimization routine has not converged onto a
% solution.
%%
% Estimate the resubstitution loss of the partially trained SVM classifier.
partialLoss = resubLoss(SVMModel)
%%
% The training sample misclassification error is approximately 11%.
%%
% Resume training the classifier for another |1500| iterations.  Specify
% that the software print diagnostic information every |250| iterations.
UpdatedSVMModel = resume(SVMModel,1500,'NumPrint',250)
%%
% The software resumes at iteration |1000|, and uses the same verbosity
% level as you set when you trained the model using |fitcsvm|.  The
% printout indicates that the algorithm converged.  Therefore,
% |UpdatedSVMModel| is a fully trained |ClassificationSVM| classifier.
updatedLoss = resubLoss(UpdatedSVMModel)
%%
% The trainig sample misclassification error of the fully trained
% classifier is approximately 8%.