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

    %% Create a Naive Bayes Template for ECOC Multiclass Learning
% Create a nondefault naive Bayes 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 naive Bayes binary classifiers, and specify kernel
% distributions for all predictors.
t = templateNaiveBayes('DistributionNames','kernel')
%%
% All properties of the template object are empty except for
% |DistributionNames|, |Method|, and |Type|. When you pass |t| to the
% training function, 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);
%%
% 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')