-
Notifications
You must be signed in to change notification settings - Fork 93
Expand file tree
/
Copy pathevaluateAUC.m
More file actions
102 lines (96 loc) · 3.6 KB
/
evaluateAUC.m
File metadata and controls
102 lines (96 loc) · 3.6 KB
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
function evaluateAUC( methods, outputLocation)
bestRecallFileName= 'best_recall_candidates.mat';
%n=length(methods);
proposalNames = fieldnames(methods);
n = length(proposalNames);
count = 0;
figure;
for i = 1:n
try
data = load(char(fullfile(methods.(char(proposalNames(i))).opts.outputLocation, bestRecallFileName)));
count=count+1;
num_experiments = numel(data.best_candidates);
x = zeros(num_experiments, 1);
y = zeros(num_experiments, 1);
for exp_idx = 1:num_experiments
experiment = data.best_candidates(exp_idx);
[~, ~, auc] = compute_average_recall(experiment.best_candidates.iou);
x(exp_idx) = mean([experiment.image_statistics.num_candidates]);
y(exp_idx) = auc;
end
label=methods.(char(proposalNames(i))).opts.name;
labels(count)=label;
line_style = '-';
if methods.(char(proposalNames(i))).opts.isBaseline
line_style = '--';
end
semilogx(x, y, 'Color', methods.(char(proposalNames(i))).opts.color, 'LineWidth', 1.5, 'LineStyle', line_style);
hold on; grid on;
catch exc
fprintf('Error evaluating %s\n', (char(proposalNames(i))));
msg = exc.message;
fprintf(msg);
fprintf('\n**** Continuing ..****\n');
end
end
xlim([10, 10000]);
ylim([0 1]);
xlabel('# candidates'); ylabel('area under recall');
legend(labels{:}, 'Location', 'SouthEast');
legendshrink(0.5);
legend boxoff;
hei = 10;
wid = 10;
set(gcf, 'Units','centimeters', 'Position',[0 0 wid hei]);
set(gcf, 'PaperPositionMode','auto');
printpdf([outputLocation '/' 'figures/num_candidates_area_under_recall.pdf']);
% fixed threshold
legend_locations = {'SouthEast', 'NorthWest', 'NorthWest'};
thresholds = [0.5 0.7 0.8];
for threshold_i = 1:numel(thresholds)
threshold = thresholds(threshold_i);
figure;
for i = 1:n
try
data = load(char(fullfile(methods.(char(proposalNames(i))).opts.outputLocation, bestRecallFileName)));
num_experiments = numel(data.best_candidates);
x = zeros(num_experiments, 1);
y = zeros(num_experiments, 1);
for exp_idx = 1:num_experiments
experiment = data.best_candidates(exp_idx);
recall = sum(experiment.best_candidates.iou >= threshold) / numel(experiment.best_candidates.iou);
x(exp_idx) = mean([experiment.image_statistics.num_candidates]);
y(exp_idx) = recall;
end
line_style = '-';
if methods.(char(proposalNames(i))).opts.isBaseline
line_style = '--';
end
semilogx(x, y, 'Color', methods.(char(proposalNames(i))).opts.color, 'LineWidth', 1.5, 'LineStyle', line_style);
hold on; grid on;
catch exc
fprintf('Error evaluating %s\n', (char(proposalNames(i))));
msg = exc.message;
fprintf(msg);
fprintf('\n**** Continuing ..****\n');
end
end
xlim([10, 10000]);
ylim([0 1]);
xlabel('# candidates'); ylabel(sprintf('recall at IoU threshold %.1f', threshold));
legend(labels{:}, 'Location', legend_locations{threshold_i});
legendshrink(0.5);
legend boxoff;
% legend(labels, 'Location', 'SouthEast');
hei = 10;
wid = 10;
set(gcf, 'Units','centimeters', 'Position',[0 0 wid hei]);
set(gcf, 'PaperPositionMode','auto');
if(~exist(char(fullfile(outputLocation, ...
'figures')), 'dir'))
mkdir(char(fullfile(outputLocation, ...
'figures')))
end
printpdf(char(fullfile(outputLocation,sprintf('figures/num_candidates_recall_%.1f.pdf',threshold))));
end
end