simSequence
Similarity between 2 sequences (e.g., for beat tracking)
Contents
Syntax
- f=simSequence(computed, gt, tolerance)
- f=simSequence(computed, gt, tolerance, showPlot)
- [f, p, r, accuracy, tpCount, fpCount, fnCount]=simSequence(...)
Description
This function is often used to evaluate the similarity between two time sequences, for instance, beat positions generated from beat tracking of audio music.
f=simSequence(computed, gt, tolerance) returns the F-measure of two sequences (computed, gt) with the given tolerance.
f=simSequence(computed, gt, tolerance, 1) also plots the sequences for visualization.
[f, p, r, accuracy, tpCount, fpCount, fnCount]=simSequence(...) returns more info:
- f: F-measure, equal to 2pr/(p+r) = tp/(tp+(fn+fp)/2)
- p: precision, equal to tp/(tp+fp)
- r: recall, equal to tp/(fp+fn)
- accuracy: equal to tp/(fp+fn+tp)
- tpCount: true-positive (hit) count
- fpCount: false-positive (insertion) count
- fnCount: false-negative (deletion) count
Example
gt=[1 2 3 4 5]; computed=[0.5 1.86 2.1 3.1 4.5 5 6]; tolerance=0.15; [f, p, r, accuracy, tp, fp, fn]=simSequence(computed, gt, tolerance, 1); fprintf('Precision = tp/(tp+fp)=%d/(%d+%d) = %f\n', tp, tp, fp, p); fprintf('Recall = tp/(tp+fn)=%d/(%d+%d) = %f\n', tp, tp, fn, r); fprintf('F-measure = tp/(tp+(fn+fp)/2)=%d/(%d+(%d+%d)/2) = %f\n', tp, tp, fn, fp, f); fprintf('Accuracy = tp/(tp+fn+fp)=%d/(%d+%d+%d) = %f\n', tp, tp, fn, fp, accuracy);
Precision = tp/(tp+fp)=3/(3+4) = 0.428571 Recall = tp/(tp+fn)=3/(3+2) = 0.600000 F-measure = tp/(tp+(fn+fp)/2)=3/(3+(2+4)/2) = 0.500000 Accuracy = tp/(tp+fn+fp)=3/(3+2+4) = 0.333333
![](simSequence_help_01.png)