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

    %% Compute Number of Misclassified Observations
% Find the total number of misclassifications of the Fisher iris data for a
% classification tree.
%%

% Copyright 2015 The MathWorks, Inc.

load fisheriris
tree = fitctree(meas,species);
Ypredict = resubPredict(tree);    % The predictions
Ysame = strcmp(Ypredict,species); % True when ==
sum(~Ysame) % How many are different?