diff evaluationtools/getrecall.m @ 1:8973548174c1 tip

adding tools to repo
author christopherh
date Mon, 06 May 2013 14:43:47 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/evaluationtools/getrecall.m	Mon May 06 14:43:47 2013 +0100
@@ -0,0 +1,80 @@
+%GETRECALL get frame-based chord symbol recall
+%
+%[recall, nondictionary] = getrecall(estimates, annotations,cardinality)
+% 
+% params.comparison = 'ov'; 
+% params.cardinality = 3; 
+% params.inversion = 0;
+% params.dictionary = {'X:maj', 'X:min'};
+
+function [recall, nondictionary] = getrecall3(estimates_labfile, annotations_labfile,params)
+
+
+[at1, at2, as] = merge_repeats(annotations_labfile);
+
+[et1, et2, es] = merge_repeats(estimates_labfile);
+
+
+%indeces for E and A
+i = 1;
+j = 1;
+
+ilength = length(et1);
+jlength = length(at1);
+
+% find length in Nt of annotated sequence 
+%alength = length(annotations);
+
+% find length in Nt of estimated sequence 
+%elength = length(estimates);
+
+% use lesser value for evaluation
+%ilength = min(alength,elength);
+
+Nc = 0; % number of successfully matched Nt
+
+Nt = 0; % total number of evaluated Nt
+
+Ne = 0;
+
+seg_start= 0;
+seg_end = 0;
+
+Tc = 0;
+Ti = 0;
+Tt = 0;
+    
+while i <= ilength & j <= jlength
+
+    segstart = max(at1(j), et1(i));
+    segend = min(at2(j), et2(i));
+    
+    [match, success, errormessage] = comparechords2(char(es{i}),char(as{j}), params.comparison, params.cardinality, params.inversion);
+           
+    includeE = indictionary(char(es{i}), params.dictionary, params.comparison, params.cardinality);
+    includeA = indictionary(char(as{j}), params.dictionary, params.comparison, params.cardinality);
+ 
+    seglength = segend-segstart;
+    
+    Tc = Tc + (match * includeE * seglength);
+    
+    Ti = Ti + (includeA * seglength);
+    
+    Tt = Tt + seglength;
+    
+    if at2(j) > segend
+        i = i+1;
+    elseif et2(i) > segend
+        j= j+1;
+    else
+        i = i+1;
+        j = j+1;
+    end
+    
+end
+
+% recall is number of correct matches out of total evaluated Nt
+recall = Tc/Ti;
+
+% percentage of annotations that were non-dictionary chords so ignored
+nondictionary = 1-(Ti/Tt);