def get_accuracy_f1_precision_recall()

in src/util.py [0:0]


def get_accuracy_f1_precision_recall(gold_labels, pred_labels):
    tp = sum(1 for y, p in zip(gold_labels, pred_labels) if y == 1 and p == 1)
    tn = sum(1 for y, p in zip(gold_labels, pred_labels) if y == 0 and p == 0)
    fp = sum(1 for y, p in zip(gold_labels, pred_labels) if y == 0 and p == 1)
    fn = sum(1 for y, p in zip(gold_labels, pred_labels) if y == 1 and p == 0)
    total = len(gold_labels)
    acc = (tp + tn) / total
    precision = tp / (tp + fp) if (tp + fp) > 0 else 0.0
    recall = tp / (tp + fn) if (tp + fn) > 0 else 0.0
    f1 = 2 * precision * recall / (precision + recall)
    return acc, f1, precision, recall