-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep4_evaluate.m
39 lines (31 loc) · 1.01 KB
/
step4_evaluate.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
createParams;
%% Execute
% Compute precision
files = dir(fullfile(params.rankListPath, '*.txt'));
files = {files.name};
if strfind(params.os, 'win') % Window
exeFile = fullfile(params.groundtruthPath, 'compute_ap.exe');
elseif strfind(params.os, 'mac') % Mac
exeFile = fullfile(params.groundtruthPath, 'compute_ap');
else
exeFile = fullfile(params.groundtruthPath, 'compute_ap');
end
for i = 1:numel(files)
file = files{i};
fprintf('%s\n', file);
output = fullfile(params.apPath, files{i});
dos([exeFile, ' ', fullfile(params.groundtruthPath, files{i}(1:end - 10)), ...
' ', fullfile(params.rankListPath, files{i}), ' >', output]);
end
fprintf('Computed precision!\n');
% Compute average precision
files = dir(fullfile(params.apPath, '*.txt'));
files = {files.name};
p = zeros(numel(files), 1);
for i = 1:numel(files)
file = files{i};
fid = fopen(fullfile(params.apPath, file), 'r');
p(i) = fscanf(fid, '%f');
fclose(fid);
end
fprintf('MAP = %f%%\n', mean(p) * 100);