
50 CHAPTER 2 Classifiers Based on Cost Function Optimization
tol=0.001;
steps=100000;
eps=10ˆ(-10);
method=1;
for i=1:c
[alpha(:,i), w0(i), w(i,:), evals, stp, glob] =...
SMO2(X1', z1(i,:)', kernel, kpar1, kpar2, C,...
tol, steps, eps, method)
marg(i)=2/sqrt(sum(w(i,:).
2
)) % Margin
%Counting the number of support vectors
sup_vec(i)=sum(alpha(:,i)>0)
end
To estimate the classification error rate based on X
2
, type
[vali,class_est]=max(w*X2-w0'*ones(1,N2));
err_svm=sum(class_est
~
=y2)/N2
The classification error in this case turns out to be 5.00%. For comparison, we mention that the
Bayesian classification error is 3.33%. (Explain why the latter value is different