www.gusucode.com > stats 源码程序 matlab案例代码 > stats/ResumeTrainingAnSVMClassifierExample.m
%% Resume Training an SVM Classifier % If you trained an SVM classifier, and the solver failed to converge onto % a solution, then you can resume training the classifier without having to % restart the entire learning process. %% % Load the |ionosphere| data set. % Copyright 2015 The MathWorks, Inc. load ionosphere rng(1); % For reproducibility %% % Train an SVM classifier. For illustration, specify that the optimization % routine uses at most 50 iterations. SVMModel = fitcsvm(X,Y,'IterationLimit',50); DidConverge = SVMModel.ConvergenceInfo.Converged Reason = SVMModel.ConvergenceInfo.ReasonForConvergence %% % |DidConverge = 0| indicates that the optimization routine did not % converge onto a solution. |Reason| states the reaon why the routine did % not converge. Therefore, |SVMModel| is a partially trained, SVM % classifier. %% % Resume training the SVM classifier for another |1500| iterations. UpdatedSVMModel = resume(SVMModel,1500); DidConverge = UpdatedSVMModel.ConvergenceInfo.Converged Reason = UpdatedSVMModel.ConvergenceInfo.ReasonForConvergence %% % |DidConverge| indicates that the optimization routine converged onto a % solution. |Reason| indicates that the gradient difference % (|DeltaGradient|) reached its tolerance level (|DelatGradientTolerance|). % Therefore, |SVMModel| is a fully trained SVM classifier.