-
Notifications
You must be signed in to change notification settings - Fork 0
/
getConfusionMatrixLatexSumbul.m
138 lines (106 loc) · 4.3 KB
/
getConfusionMatrixLatexSumbul.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
% This function just generates the latex code for the confusion
% matrix in the article.
clear all, close all
rng('shuffle')
r = RGCclass(0);
r.lazyLoad('knownSumbul');
% featuresUsed = { 'dendriticDensity', ...
% 'somaArea', ...
% 'totalDendriticLength', ...
% 'meanTerminalSegmentLength'};
% featSet = 'Best3Set';
% featSet = 'A12Set';
% featSet = 'ManualUncorrSet';
featSet = 'Sumbul4';
switch(featSet)
case 'Sumbul4'
featuresUsed = {'biStratificationDistance', ...
'densityOfBranchPoints', ...
'stratificationDepth', ...
'totalDendriticLength'};
%%% The features below this line were for Rana dataset
case 'Best3Set'
% Best 3 feature set for classification
featuresUsed = { 'fractalDimensionBoxCounting', ...
'somaArea', ...
'meanTerminalSegmentLength' };
case 'A12Set'
% A good 12 feature set for classification??? Dont remember
featuresUsed = {'branchAssymetry', ...
'dendriticDensity', ...
'dendriticDiameter', ...
'dendriticField', ...
'densityOfBranchPoints', ...
'fractalDimensionBoxCounting', ...
'meanBranchAngle', ...
'meanTerminalSegmentLength', ...
'numBranchPoints', ...
'numSegments', ...
'somaArea', ...
'totalDendriticLength' }
case 'ManualUncorrSet'
% Trying to pick uncorrelated features, using at correlation matrix
featuresUsed = { 'numBranchPoints', ...
'meanSegmentLength', ...
'dendriticField', ...
'totalDendriticLength', ...
'somaArea', ...
'biStratificationDistance', ...
'meanBranchAngle', ...
'meanSegmentTortuosity', ...
'stratificationDepth' };
case 'Best5'
% Best 5 feature set, from exhaustive search
featuresUsed = { 'densityOfBranchPoints', ...
'dendriticField', ...
'fractalDimensionBoxCounting', ...
'meanTerminalSegmentLength', ...
'somaArea' };
case 'Best6'
% Best 6 feature set, from exhaustive search
% Redid it with more iterations (20 vs 5), and then DBP changed to NBP
featuresUsed = { 'numberOfBranchPoints', ...
'dendriticField', ...
'fractalDimensionBoxCounting', ...
'meanSegmentTortuosity', ...
'meanTerminalSegmentLength', ...
'somaArea' };
otherwise
fprintf('Unknown featSet: %s', featSet)
keyboard
end
r.setFeatureMat(featuresUsed);
[CM,CMsd] = r.confusionMatrixCrossValidation(5,1000);
disp('\nConfusion matrix with cross validation')
% strHeader = 'C = \\left[ \\begin{array}{ccccc}\n';
strLine = ['\\textbf{%s} & $%.2f \\pm %.2f$ & $%.2f \\pm %.2f$ & $%.2f \\pm %.2f$ & $%.2f \\pm %.2f$ & $%.2f \\pm %.2f$\\\\\n'];
strEnd = '\\end{array} \\right]\n';
strHeader = ['\\begin{table}\\begin{tabular}{llllll}\n' ...
'& \\bf{%s} & \\bf{%s} & \\bf{%s} & \\bf{%s} & \\bf{%s}\\\\\n'...
'\\hline\n'];
strEnd = '\\end{tabular}\\end{table}\n';
fprintf(strHeader, ...
r.RGCtypeName{find(r.RGCtypeID == 1,1)}, ...
r.RGCtypeName{find(r.RGCtypeID == 2,1)}, ...
r.RGCtypeName{find(r.RGCtypeID == 3,1)}, ...
r.RGCtypeName{find(r.RGCtypeID == 4,1)}, ...
r.RGCtypeName{find(r.RGCtypeID == 5,1)})
for i = 1:5
fprintf(strLine, ...
r.RGCtypeName{find(r.RGCtypeID == i,1)}, ...
CM(i,1),CMsd(i,1), ...
CM(i,2),CMsd(i,2), ...
CM(i,3),CMsd(i,3), ...
CM(i,4),CMsd(i,4), ...
CM(i,5),CMsd(i,5))
end
fprintf(strEnd)
truePos = diag(CM)'./sum(CM);
for i = 1:5
fprintf('%s: %.1f %%\n', r.RGCtypeName{find(r.RGCtypeID == i,1)}, ...
truePos(i)*100)
end
disp('\nConfusion matrix generated with leave one out:')
CM2 = r.confusionMatrixLeaveOneOut();
makeLatexTableHeaders(r.RGCuniqueNames, r.RGCuniqueNames, CM2, ...
'%d','Predicted Class','True Class')