-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrocDetector.m
More file actions
33 lines (25 loc) · 1.26 KB
/
Copy pathrocDetector.m
File metadata and controls
33 lines (25 loc) · 1.26 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
function roc = rocDetector(cap, threshold, numTests)
% Convert a cell array of capture history tables to an ROC curve (true
% positive rate, false alarm rate, and duplicate matches).
%
% CAP is a cell array of capture history tables (see captureHistoryTable.m)
% Each capture history table in CAP should correspond to a comparison
% between a 'ground truth' and a test table (e.g. manual annotations and an
% automated acoustic detector).
for i = 1:length(cap)
c = cap{i};
groundTrue = c.detect_t1;
detectTrue = c.detect_t2;
numGroundTrue(i) = sum(groundTrue);% height(ravenTable)-length(ignoreIx);
tTrue = (duration*numGroundTrue(i));
tFalse = tTotal - tTrue;
numTests(i) = tFalse / duration;
duplicateMatches(i,j) = length(c.key) - length(unique(c.key));
truePosRate(i,j) = (sum(groundTrue & detectTrue)-duplicateMatches(i,j))./numGroundTrue(i,j);
falseAlarmRate(i,j) = sum(detectTrue & ~groundTrue)./numTests(i,j);
end
[threshold, sortedIx] = sortrows(threshold(:));
truePosRate = truePosRate(sortedIx,:);
falseAlarmRate = falseAlarmRate(sortedIx,:);
duplicateMatches = duplicateMatches(sortedIx,:);
roc = table(falseAlarmRate,truePosRate,threshold, duplicateMatches);