def compute_f1(FP, TP, FN):
  """ Compute the F1 score. The calculation equation can be found at
  http://amida13.isi.uu.nl/?q=node/4.

  Args:
    FP: a list of false positive predictions.
    TP: a list of true positive predictions.
    FN: a list of false negative predictions.

  Return:
    a tuple of (F1, precision, recall).
  """

  precision = len(TP) / (len(TP) + len(FP)) if len(TP) + len(FP) > 0 else 0
  recall = len(TP) / (len(TP) + len(FN)) if len(TP) + len(FN) > 0 else 0
  f1 = 2 * precision * recall / (precision + recall) if (precision + recall) > 0 else 0

  #print (f"TP: {len(TP)}; FP: {len(FP)}; FN: {len(FN)}")
  #print (f"precision: {precision}; recall: {recall}")

  return (f1, precision, recall)