-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOVOSTest.m
37 lines (30 loc) · 894 Bytes
/
OVOSTest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
X = loadMNISTImages('t10k-images.idx3-ubyte')';
y = loadMNISTLabels('t10k-labels.idx1-ubyte');
pred = zeros(size(y));
predTable = zeros(size(y,1),10);
for i=0:9
for j=i+1:9
T1name = sprintf('S%d_%dTheta1', i,j);
T2name = sprintf('S%d_%dTheta2', i,j);
T1 = load('OvOS.mat',T1name);
Theta1 = T1.(T1name);
T2 = load('OvOS.mat',T2name);
Theta2 = T2.(T2name);
p = predictSVM(Theta1,Theta2,X);
for k=1:size(p,1)
if (p(k))
predTable(k,i+1) = predTable(k,i+1)+1;
else
predTable(k,j+1) = predTable(k,j+1)+1;
end
end
end
end
cc = predTable;
for i=1:size(pred,1)
k = find(predTable(i,:) == max(predTable(i,:)));
r = rand(length(k),1);
d = k(find(r == max(r)));
pred(i) = d-1;
end
fprintf('Accuracy: %f',mean(y==pred));