-
Notifications
You must be signed in to change notification settings - Fork 0
/
runExhaustiveFeatureSearchSumbul.m
99 lines (68 loc) · 2.23 KB
/
runExhaustiveFeatureSearchSumbul.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
% This file writes N list of features that the workers can then process
% Analyse the data with analyseExhaustiveFeatureSearchSumbul.m
close all, clear all
tic
rng('shuffle')
r = RGCclass(0);
r.lazyLoad('knownSumbul'); % Mat file generated by classifySumbul.m
assert(all(all(~isnan(r.featureMat))))
nWorkers = 4;
nFolds = 5;
nRep = 1 %25;
featureIdx = r.getSubsetOfFeatures();
for i = 1:nWorkers
workList{i} = {};
end
for i = 1:numel(featureIdx)
workerID = mod(i-1,nWorkers) + 1;
workList{workerID}{end+1} = featureIdx{i};
end
% Create the folds, use multiple times
dataIdx = ceil(nFolds * rand(numel(r.RGC),nRep));
parfor i = 1:nWorkers
rLoop = RGCclass(0);
rLoop.lazyLoad('knownSumbul');
assert(all(all(~isnan(r.featureMat))));
correctFrac{i} = zeros(numel(workList{i}),nRep);
correctFracMean{i} = zeros(numel(workList{i}),1);
correctFracSD{i} = zeros(numel(workList{i}),1);
for j = 1:numel(workList{i});
if(mod(j,100) == 0)
fprintf('Worker %d: %d/%d\n', i, j, numel(workList{i}))
end
featureList = rLoop.allFeatureNames(workList{i}{j});
rLoop.setFeatureMat(featureList);
[correctFracMean{i}(j),correctFracSD{i}(j), correctFrac{i}(j,:), ...
classifiedAsID{i}(:,:,j),corrFlag{i}(:,:,j)] = ...
rLoop.benchmark(nRep,dataIdx);
end
end
corrFrac = [];
corrFracMean = [];
corrFracSD = [];
predictedID = [];
featureListIdx = {};
for i = 1:nWorkers
corrFrac = [corrFrac; correctFrac{i}];
corrFracMean = [corrFracMean; correctFracMean{i}];
corrFracSD = [corrFracSD; correctFracSD{i}];
predictedID = cat(3,predictedID,classifiedAsID{i});
for j = 1:numel(workList{i})
featureListIdx{end+1} = workList{i}{j};
end
end
allFeatureNames = r.allFeatureNames;
classifierMethod = r.classifierMethod;
featureNameDisplay = r.featureNameDisplay;
RGCtypeID = r.RGCtypeID;
RGCtypeName = r.RGCtypeName;
fName = sprintf('RESULTS/ExhaustiveFeatureSearch-Sumbul-NaiveBayes-%d.mat',nRep);
fprintf('Saving to %s\n', fName)
save(fName, ...
'corrFrac','corrFracMean','corrFracSD', ...
'featureNameDisplay', ...
'RGCtypeID', 'RGCtypeName', ...
'allFeatureNames','classifierMethod', ...
'featureListIdx', 'predictedID', ...
'nFolds','nRep','dataIdx')
toc