def f1(tp, tn, fp, fn):
    """
    Calculates the F1 Score.
    """
    precision = tp / (1.0 * (tp + fp))
    recall = tp / (1.0 * (tp + fn))
    return 2.0 * precision * recall / (precision + recall)