in data_annotation_platform/app/main/demo.py [0:0]
def metrics(true_cp, user_cp, k=5):
true_cp = [int(x) for x in true_cp]
user_cp = [int(x) for x in user_cp]
correct = []
window = []
incorrect = []
rem_true = list(true_cp)
for cp in user_cp:
if cp in rem_true:
correct.append(cp)
rem_true.remove(cp)
user_cp = [x for x in user_cp if not x in correct]
for cp in user_cp:
to_delete = []
for y in rem_true:
if abs(cp - y) < k:
window.append(cp)
to_delete.append(y)
break
for y in to_delete:
rem_true.remove(y)
user_cp = [x for x in user_cp if not x in window]
for cp in user_cp:
incorrect.append(cp)
n_correct = len(correct)
n_window = len(window)
n_fp = len(incorrect)
n_fn = len(rem_true)
return n_correct, n_window, n_fp, n_fn