-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyseExhaustiveFeatureSearchHoxd10split.m
250 lines (185 loc) · 7.52 KB
/
analyseExhaustiveFeatureSearchHoxd10split.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
close all, clear all
data = load('RESULTS/ExhaustiveFeatureSearch-Hoxd10-split-NaiveBayes-20.mat');
[~,bestIdx] = sort(data.corrFracMean,'descend');
% Show top 10
for i = 1:10
bi = bestIdx(i);
fprintf('%d. %.1f +/- %.1f % :', ...
i, 100*data.corrFracMean(bi), ...
100*data.corrFracSD(bi))
for j = 1:numel(data.featureListIdx{bi})
fprintf('%s ', data.allFeatureNames{data.featureListIdx{bi}(j)})
end
fprintf('\n')
end
% Show best N feature set
bestNfeatureSets = {};
bestNfeatureSetsMean = [];
bestNfeatureSetsSTD = [];
nFeatures = zeros(numel(data.featureListIdx),1);
for i = 1:numel(data.featureListIdx)
nFeatures(i) = numel(data.featureListIdx{i});
end
nFeaturesMax = max(nFeatures);
meanPerf = zeros(nFeaturesMax,1);
medianPerf = zeros(nFeaturesMax,1);
topPerf = zeros(nFeaturesMax,1);
for i = 1:nFeaturesMax
nFeatIdx = find(nFeatures == i);
bi = find(ismember(bestIdx,nFeatIdx));
nFeatBestIdx = bestIdx(bi(1));
bestNfeatureSets{i} = data.featureListIdx{nFeatBestIdx};
bestNfeatureSetsMean(i) = data.corrFracMean(nFeatBestIdx);
bestNfeatureSetsSTD(i) = data.corrFracSD(nFeatBestIdx);
fprintf('%d (%d features). %.1f +/- %.1f % :', ...
bi(1), i, 100*data.corrFracMean(nFeatBestIdx), ...
100*data.corrFracSD(nFeatBestIdx))
for j = 1:numel(data.featureListIdx{nFeatBestIdx})
fprintf('%s ', data.allFeatureNames{data.featureListIdx{nFeatBestIdx}(j)})
end
fprintf('\n')
meanPerf(i) = mean(data.corrFracMean(nFeatIdx));
medianPerf(i) = median(data.corrFracMean(nFeatIdx));
% topPerf(i) = prctile(data.corrFracMean(nFeatIdx),99);
topPerf(i) = max(data.corrFracMean(nFeatIdx));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Had forgotten to add this one when we were running earlier
data.featureNameDisplay('dendriticDiameter') = 'Dendritic Diameter';
data.featureNameDisplayShort = containers.Map();
data.featureNameDisplayShort('stratificationDepth') = 'SD';
data.featureNameDisplayShort('biStratificationDistance') = 'BD';
data.featureNameDisplayShort('dendriticField') = 'DA';
data.featureNameDisplayShort('densityOfBranchPoints') = 'DBP';
data.featureNameDisplayShort('somaArea') = 'SA';
data.featureNameDisplayShort('numBranchPoints') = 'NBP';
data.featureNameDisplayShort('numSegments') = 'NS';
data.featureNameDisplayShort('totalDendriticLength') = 'TDL';
data.featureNameDisplayShort('meanSegmentLength') = 'MSL';
data.featureNameDisplayShort('meanTerminalSegmentLength') = 'MTSL';
data.featureNameDisplayShort('meanSegmentTortuosity') = 'MST';
data.featureNameDisplayShort('meanBranchAngle') = 'MBA';
data.featureNameDisplayShort('dendriticDensity') = 'DD';
data.featureNameDisplayShort('fractalDimensionBoxCounting') = 'FDBC';
data.featureNameDisplayShort('stratificationDepthScaled') = 'SDS';
data.featureNameDisplayShort('dendriticVAChT') = 'DVAChT';
data.featureNameDisplayShort('branchAssymetry') = 'BA';
data.featureNameDisplayShort('numLeaves') = 'NL';
data.featureNameDisplayShort('dendriticDiameter') = 'DDi';
fid = fopen('RESULTS/ExhaustiveSearchLatex-Hoxd10-split.tex','w');
% Number of features,
fprintf(fid,'\\begin{sidewaystable}\n');
fprintf(fid,'\\begin{tabular}{cc%s}\n',repmat('l',1,numel(bestNfeatureSets)));
for i = 1:numel(data.allFeatureNames)
allFeaturesShortOrig{i} = data.featureNameDisplayShort(data.allFeatureNames{i});
end
[allFeaturesShort,alphabeticIdx] = sort(allFeaturesShortOrig);
headerStr = [];
for i = 1:numel(allFeaturesShort)
headerStr = sprintf('%s & %s', headerStr, allFeaturesShort{i});
end
fprintf(fid,'Number of features & Performance %s\\\\\n', headerStr);
fprintf(fid,'\\hline\n');
for i = 1:numel(bestNfeatureSets)
featureMask = zeros(1,numel(bestNfeatureSets));
featureMask(bestNfeatureSets{i}) = 1;
featureMaskSorted = featureMask(alphabeticIdx);
featureStr = [];
for j = 1:numel(featureMaskSorted);
if(featureMaskSorted(j))
featureStr = sprintf('%s & $\\bullet$', featureStr);
else
featureStr = sprintf('%s & ', featureStr);
end
end
fprintf(fid,'%d & $%.1f \\pm %.1f\\,\\%%$ %s\\\\\n', ...
i, bestNfeatureSetsMean(i)*100, bestNfeatureSetsSTD(i)*100, ...
featureStr);
end
fprintf(fid,'\\hline\n');
fprintf(fid,'\\end{tabular}\n');
captionStr = sprintf('%s (%s)', ...
data.featureNameDisplay(data.allFeatureNames{alphabeticIdx(1)}), ...
data.featureNameDisplayShort(data.allFeatureNames{alphabeticIdx(1)}));
for i = 2:numel(alphabeticIdx)
captionStr = sprintf('%s, %s (%s)', ...
captionStr, ...
data.featureNameDisplay(data.allFeatureNames{alphabeticIdx(i)}), ...
data.featureNameDisplayShort(data.allFeatureNames{alphabeticIdx(i)}));
end
fprintf(fid, '\\caption{%s}\n', captionStr);
fprintf(fid,'\\end{sidewaystable}\n');
fclose(fid);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Also write a CSV file
csvRowHeader = num2cell(1:numel(bestNfeatureSets));
for i = 1:numel(csvRowHeader)
csvRowHeader{i} = num2str(csvRowHeader{i});
end
fid = fopen('RESULTS/ExhaustiveFeatureSearchPick-Hoxd10-split.csv','w');
fprintf(fid, 'No.,Performance');
for i = 1:numel(allFeaturesShort)
fprintf(fid,', %s', allFeaturesShort{i});
end
fprintf(fid,'\n');
for i = 1:numel(bestNfeatureSets)
fprintf(fid,'%d, %.1f +/- %.1f', i, ...
bestNfeatureSetsMean(i)*100, ...
bestNfeatureSetsSTD(i)*100);
featureMask = zeros(1,numel(bestNfeatureSets));
featureMask(bestNfeatureSets{i}) = 1;
featureMaskSorted = featureMask(alphabeticIdx);
for j = 1:numel(featureMaskSorted)
if(featureMaskSorted(j))
fprintf(fid,',+');
else
fprintf(fid,', ');
end
end
fprintf(fid,'\n');
end
fclose(fid);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plot the number of features versus the performance
figure
hold on
x = kron(nFeatures,ones(1,data.nRep));
xr = x + (1-2*rand(size(x)))*0.35;
plot(xr,data.corrFrac*100,'.','color',[1 1 1]*0.8)
plot(nFeatures,data.corrFracMean*100,'k.')
plot(1:nFeaturesMax,medianPerf*100,'r-','linewidth',2)
axis([0 nFeaturesMax+0.5 0 100])
xlabel('No.','fontsize',24)
ylabel('Performance (%)','fontsize',24)
set(gca,'fontsize',20)
saveas(gcf,'FIGS/ExhaustiveFeatureSearch-Hoxd10-split-performance-overview.pdf','pdf')
figure
hold on
x = kron(nFeatures,ones(1,data.nRep));
xr = x + kron(ones(size(nFeatures)),linspace(-0.4,0.4,data.nRep));
p = plot(transpose(xr),transpose(sort(data.corrFrac,2,'descend')*100), ...
'-','color',[1 1 1]*0.8,'markersize',4);
for i = 1:numel(p)
set(p(i),'color',[1 1 1]*(0.6+0.3*rand(1)))
end
plot(nFeatures,data.corrFracMean*100,'k.')
plot(1:nFeaturesMax,medianPerf*100,'r-','linewidth',2)
% plot(1:nFeaturesMax,topPerf*100,'r-','linewidth',2)
axis([0 nFeaturesMax+0.5 0 100])
xlabel('Number of features','fontsize',24)
ylabel('Performance (%)','fontsize',24)
set(gca,'fontsize',20)
axis([0 15.5 0 100])
saveas(gcf,'FIGS/ExhaustiveFeatureSearch-Hoxd10-split-performance-overview-alt.pdf','pdf')
bestNfeatureSetsName = {};
for i = 1:numel(bestNfeatureSets)
bestNfeatureSetsName{i} = data.allFeatureNames(bestNfeatureSets{i});
end
dataIdx = data.dataIdx;
save('RESULTS/exhaustiveSearchResultsSummary-Hoxd10-split.mat', ...
'bestNfeatureSets', ...
'bestNfeatureSetsMean', ...
'bestNfeatureSetsName', ...
'bestNfeatureSetsSTD', ...
'allFeaturesShort', ...
'dataIdx')