www.gusucode.com > stats 源码程序 matlab案例代码 > stats/CreateSVMTemplateForECOCMulticlassLearningExample.m
%% Create an SVM Template for ECOC Multiclass Learning % Create a nondefault SVM template for use in % <docid:stats_ug.bue3oc9 fitcecoc>. %% % Load Fisher's iris data set. % Copyright 2015 The MathWorks, Inc. load fisheriris %% % Create a template for SVM binary classifiers, and specify to use a % Gaussian kernel function. t = templateSVM('KernelFunction','gaussian') %% % All properties of the template object are empty except for % |DistributionNames|, |Method|, and |Type|. When trained on, % the software fills in the empty properties with their respective default % values. %% % Specify |t| as a binary learner for an ECOC multiclass model. Mdl = fitcecoc(meas,species,'Learners',t); %% % |Mdl| is a |ClassificationECOC| multiclass classifier. By default, the % software trains |Mdl| using the one-versus-one coding design. %% % Display the in-sample (resubstitution) misclassification error. L = resubLoss(Mdl,'LossFun','classiferror')