Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -71,6 +71,38 @@ def onset_diffs(ltru, lexp, eps): · 70 unmodified lines | |||
| 71 | # return list of diffs | 71 | # return list of diffs |
| 72 | return l | 72 | return l |
| 73 | 73 | ||
| 74 | def onset_rocloc(ltru, lexp, eps): | ||
| 75 | """ compute differences between two lists | ||
| 76 | orig = hits + missed + merged | ||
| 77 | expc = hits + bad + doubled | ||
| 78 | returns orig, missed, merged, expc, bad, doubled | ||
| 79 | """ | ||
| 80 | orig, expc = len(ltru), len(lexp) | ||
| 81 | l = [] | ||
| 82 | mean = 0 | ||
| 83 | # if lexp is empty | ||
| 84 | if expc == 0 : return orig,orig,0,0,0,0,l,mean | ||
| 85 | missed, bad, doubled, merged = 0, 0, 0, 0 | ||
| 86 | # find missed and doubled ones first | ||
| 87 | for x in ltru: | ||
| 88 | correspond = 0 | ||
| 89 | for y in lexp: | ||
| 90 | if abs(x-y) <= eps: correspond += 1 | ||
| 91 | if correspond == 0: missed += 1 | ||
| 92 | elif correspond > 1: doubled += correspond - 1 | ||
| 93 | # then look for bad and merged ones | ||
| 94 | for y in lexp: | ||
| 95 | correspond = 0 | ||
| 96 | for x in ltru: | ||
| 97 | if abs(x-y) <= eps: | ||
| 98 | correspond += 1 | ||
| 99 | l.append(y-x) | ||
| 100 | if correspond == 0: bad += 1 | ||
| 101 | elif correspond > 1: merged += correspond - 1 | ||
| 102 | # check consistancy of the results | ||
| 103 | assert ( orig - missed - merged == expc - bad - doubled) | ||
| 104 | return orig, missed, merged, expc, bad, doubled, l, sum(l)/float(max(len(l),1)) | ||
| 105 | |||
| 74 | def notes_roc (la, lb, eps): | 106 | def notes_roc (la, lb, eps): |
| 75 | from numarray import transpose, add, resize | 107 | from numarray import transpose, add, resize |
| 76 | """ creates a matrix of size len(la)*len(lb) then look for hit and miss | 108 | """ creates a matrix of size len(la)*len(lb) then look for hit and miss |