-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeSVMcomparison.m
117 lines (75 loc) · 3.01 KB
/
makeSVMcomparison.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
close all, clear all
data = load('RESULTS/exhaustiveSearchResultsSummary.mat');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
parfor i = 1:numel(data.bestNfeatureSetsName)
fprintf('SVM Feature scan: %d/%d\n', i, numel(data.bestNfeatureSetsName))
r = RGCclass(0);
r.lazyLoad();
r.classifierMethod = 'SVM';
% r.verbose = 1;
r.setFeatureMat(data.bestNfeatureSetsName{i});
[SVMcorrectFracMean(i),SVMcorrectFracSD(i), SVMcorrectFrac(i,:), ...
SVMclassifiedAsID(:,:,i),SVMcorrFlag(:,:,i)] = ...
r.benchmark(size(data.dataIdx,2),data.dataIdx);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
parfor i = 1:numel(data.bestNfeatureSetsName)
fprintf('BAGS Feature scan: %d/%d\n', i, numel(data.bestNfeatureSetsName))
r = RGCclass(0);
r.lazyLoad();
r.classifierMethod = 'Bags';
% r.verbose = 1;
r.setFeatureMat(data.bestNfeatureSetsName{i});
[BAGScorrectFracMean(i),BAGScorrectFracSD(i), BAGScorrectFrac(i,:), ...
BAGSclassifiedAsID(:,:,i),BAGScorrFlag(:,:,i)] = ...
r.benchmark(size(data.dataIdx,2),data.dataIdx);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i = 1:numel(data.bestNfeatureSetsName)
nFeat(i) = numel(data.bestNfeatureSetsName{i});
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
colours = [27,158,119;
217,95,2;
117,112,179]/255;
save('RESULTS/methodcomparison.mat','nFeat','data', ...
'SVMcorrectFracMean', 'SVMcorrectFracSD', ...
'BAGScorrectFracMean', 'BAGScorrectFracSD', ...
'colours');
figure
pNB = errorbar(nFeat,100*data.bestNfeatureSetsMean,100*data.bestNfeatureSetsSTD, ...
'-', 'linewidth', 1, 'color', colours(2,:));
hold on
pSVM = errorbar(nFeat,100*SVMcorrectFracMean,100*SVMcorrectFracSD, ...
'-', 'linewidth', 1, 'color', colours(1,:));
pBAGS = errorbar(nFeat,100*BAGScorrectFracMean,100*BAGScorrectFracSD, ...
'-', 'linewidth', 1, 'color', colours(3,:));
xlabel('Number of Features','fontsize',12)
ylabel('Performance (%)','fontsize',12)
set(gca,'fontsize',10)
set(gca,'xminortick','off')
set(gca,'yminortick','off')
set(gca,'xtick',1:1:15)
set(gca,'ytick',0:10:100)
set(gca,'xticklabel', {'1','','','','5', ...
'','','','','10', ...
'','','','','15'});
set(gca,'yticklabel', {'0','','','','','50', ...
'','','','','100'});
legend([pNB(1) pSVM(1),pBAGS(1)], 'Naive Bayes', 'SVM', 'Bagging', 'location', 'east')
box off
axis([0 15.5 0 100])
% Add random chance line
a = axis();
r = RGCclass(0);
r.lazyLoad();
Pcorrect = r.getRandomChance();
hold on
plot(a(1:2),100*Pcorrect*[1 1],'b--','linewidth',1)
set(gcf,'paperunits','centimeters')
set(gcf,'units','centimeters')
set(gcf,'papersize',[8 8])
set(gcf,'paperposition',[0 0 8 8])
% saveas(gcf,'FIGS/SVM-NaiveBayes-comparison.pdf','pdf')
printA4('FIGS/SVM-NaiveBayes-comparison.eps')
save('SVMcomparisonSavedState.mat')