annotate event_detection/eventDetectionMetrics_eventBased.m @ 10:507300d2ed66 tip

merge
author Dan Stowell <dan.stowell@elec.qmul.ac.uk>
date Thu, 10 Oct 2013 09:18:47 +0100
parents 2c9915c861d8
children
rev   line source
emmanouil@0 1 function [results] = eventDetectionMetrics_eventBased(outputFile,GTFile)
emmanouil@0 2
emmanouil@0 3 % Event-based evaluation for event detection task
emmanouil@0 4 % outputFile: the output of the event detection system
emmanouil@0 5 % GTFile: the ground truth list of events
emmanouil@0 6
emmanouil@0 7 % Load event list from output and ground-truth
emmanouil@0 8 [onset,offset,classNames] = loadEventsList(outputFile);
emmanouil@0 9 [onsetGT,offsetGT,classNamesGT] = loadEventsList(GTFile);
emmanouil@0 10
emmanouil@0 11
emmanouil@0 12 % Total number of detected and reference events
emmanouil@0 13 Ntot = length(onset);
emmanouil@0 14 Nref = length(onsetGT);
emmanouil@0 15
emmanouil@0 16
emmanouil@0 17 % Number of correctly transcribed events, onset within a +/-100 ms range
emmanouil@0 18 Ncorr = 0;
emmanouil@0 19 NcorrOff = 0;
emmanouil@0 20 for j=1:length(onsetGT)
emmanouil@0 21 for i=1:length(onset)
emmanouil@0 22
emmanouil@0 23 if( strcmp(classNames{i},classNamesGT{j}) && (abs(onsetGT(j)-onset(i))<=0.1) )
emmanouil@0 24 Ncorr = Ncorr+1;
emmanouil@0 25
emmanouil@0 26 % If offset within a +/-100 ms range or within 50% of ground-truth event's duration
emmanouil@0 27 if abs(offsetGT(j) - offset(i)) <= max(0.1, 0.5 * (offsetGT(j) - onsetGT(j)))
emmanouil@0 28 NcorrOff = NcorrOff +1;
emmanouil@0 29 end;
emmanouil@0 30
emmanouil@0 31 break; % In order to not evaluate duplicates
emmanouil@0 32
emmanouil@0 33 end;
emmanouil@0 34 end;
emmanouil@0 35
emmanouil@0 36 end;
emmanouil@0 37
emmanouil@0 38
emmanouil@0 39 % Compute onset-only event-based metrics
emmanouil@0 40 Nfp = Ntot-Ncorr;
emmanouil@0 41 Nfn = Nref-Ncorr;
emmanouil@0 42 Nsubs = min(Nfp,Nfn);
emmanouil@0 43 results.Rec = Ncorr/(Nref+eps);
emmanouil@0 44 results.Pre = Ncorr/(Ntot+eps);
emmanouil@0 45 results.F = 2*((results.Pre*results.Rec)/(results.Pre+results.Rec+eps));
emmanouil@0 46 results.AEER= (Nfn+Nfp+Nsubs)/(Nref+eps);
emmanouil@0 47
emmanouil@0 48
emmanouil@0 49 % Compute onset-offset event-based metrics
emmanouil@0 50 NfpOff = Ntot-NcorrOff;
emmanouil@0 51 NfnOff = Nref-NcorrOff;
emmanouil@0 52 NsubsOff = min(NfpOff,NfnOff);
emmanouil@0 53 results.RecOff = NcorrOff/(Nref+eps);
emmanouil@0 54 results.PreOff = NcorrOff/(Ntot+eps);
emmanouil@0 55 results.FOff = 2*((results.PreOff*results.RecOff)/(results.PreOff+results.RecOff+eps));
emmanouil@0 56 results.AEEROff= (NfnOff+NfpOff+NsubsOff)/(Nref+eps);