
48 CHAPTER 2 Classifiers Based on Cost Function Optimization
Table 2.4 Results for Various Values of C in Example 2.4.1
C = 0.1 C = 0.2 C = 0.5 C = 1 C = 2 C = 20
No.supportvectors8261443731 25
Training error 2.25% 2.00% 2.00% 2.25% 3.25% 2.50%
Test error 3.25% 3.00% 3.25% 3.25% 3.50% 3.50%
Margin 0.9410 0.8219 0.7085 0.6319 0.6047 0.3573
global figt4
figt4=2;
svcplot_book(X1',y1',kernel,kpar1,kpar2,alpha,-w0)
(c) To count the support vectors, type
sup_vec=sum(alpha>0)
(d) To compute the margin, type
marg=2/sqrt(sum(w.ˆ2))
The results of these experiments are shown in Table 2.4. It is readily seen that the margin of the
solution increases as C decreases.