def calculate_f1(recall, precision):
    """
    :param recall: float
    :param precision: float
    :return: float
        F1
    """
    if recall + precision == 0:
        f1 = 0
    else:
        f1 = 2 * ((recall * precision) / (
                recall + precision))
    return f1