clc, clear
a0=[8.35 23.53 7.51 8.62 17.42 10.00 1.04 11.21
9.25 23.75 6.61 9.19 17.77 10.48 1.72 10.51
8.19 30.50 4.72 9.78 16.28 7.60 2.52 10.32
7.73 29.20 5.42 9.43 19.29 8.49 2.52 10.00
9.42 27.93 8.20 8.14 16.17 9.42 1.55 9.76
9.16 27.98 9.01 9.32 15.99 9.10 1.82 11.35
10.06 28.64 10.52 10.05 16.18 8.39 1.96 10.81
9.09 28.12 7.40 9.62 17.26 11.12 2.49 12.65
9.41 28.20 5.77 10.80 16.36 11.56 1.53 12.17
8.70 28.12 7.21 10.53 19.45 13.30 1.66 11.96
6.93 29.85 4.54 9.49 16.62 10.65 1.88 13.61
8.67 36.05 7.31 7.75 16.67 11.68 2.38 12.88
9.98 37.69 7.01 8.94 16.15 11.08 0.83 11.67
6.77 38.69 6.01 8.82 14.79 11.44 1.74 13.23
8.14 37.75 9.61 8.49 13.15 9.76 1.28 11.28
7.67 35.71 8.04 8.31 15.13 7.76 1.41 13.25
7.90 39.77 8.49 12.94 19.27 11.05 2.04 13.29
7.18 40.91 7.32 8.94 17.60 12.75 1.14 14.80
8.82 33.70 7.59 10.98 18.82 14.73 1.78 10.10
6.25 35.02 4.72 6.28 10.03 7.15 1.93 10.39
10.60 52.41 7.70 9.98 12.53 11.70 2.31 14.69
7.27 52.65 3.84 9.16 13.03 15.26 1.98 14.57
13.45 55.85 5.50 7.45 9.55 9.52 2.21 16.30
10.85 44.68 7.32 14.51 17.13 12.08 1.26 11.57
7.21 45.79 7.66 10.36 16.56 12.86 2.25 11.69
7.68 50.37 11.35 13.30 19.25 14.59 2.75 14.87
7.78 48.44 8.00 20.51 22.12 15.73 1.15 16.61
7.94 39.65 20.97 20.82 22.52 12.41 1.75 7.90
8.28 64.34 8.00 22.22 20.06 15.12 0.72 22.89
12.47 76.39 5.52 11.24 14.52 22.00 5.46 25.50
];
a=a0'; b0=a(:,[1:27]); dd0=a(:,[28:end]);
[b,ps]=mapstd(b0);
dd=mapstd('apply',dd0,ps);
group=[ones(20,1); 2*ones(7,1)];
s=svmtrain(b',group)
sv_index=s.SupportVectorIndices
beta=s.Alpha
bb=s.Bias
mean_and_std_trans=s.ScaleData
check=svmclassify(s,b')
err_rate=1-sum(group==check)/length(group)
solution=svmclassify(s,dd')
s =
SupportVectors: [7x8 double]
Alpha: [7x1 double]
Bias: 1.0268
KernelFunction: @linear_kernel
KernelFunctionArgs: {}
GroupNames: [27x1 double]
SupportVectorIndices: [7x1 double]
ScaleData: [1x1 struct]
FigureHandles: []
sv_index =
14
15
17
19
24
25
27
beta =
0.4695
0.0477
0.6750
0.5978
-0.4235
-1.2909
-0.0757
bb =
1.0268
mean_and_std_trans =
shift: [1x8 double]
scaleFactor: [1.0000 1 1 1.0000 1.0000 1 1.0000 1]
check =
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
2
2
2
2
2
2
err_rate =
0
solution =
2
2
2