Гармоническое среднее в функции питона?

У меня есть 2 функции, которые выдают точность и напоминают оценки, мне нужно сделать функцию среднего гармонического, определенную в той же библиотеке, которая использует эти две оценки. Функции выглядят так:

вот функции:

def precision(ref, hyp):
    """Calculates precision.
    Args:
    - ref: a list of 0's and 1's extracted from a reference file
    - hyp: a list of 0's and 1's extracted from a hypothesis file
    Returns:
    - A floating point number indicating the precision of the hypothesis
    """
    (n, np, ntp) = (len(ref), 0.0, 0.0)
    for i in range(n):
            if bool(hyp[i]):
                    np += 1
                    if bool(ref[i]):
                            ntp += 1
    return ntp/np

def recall(ref, hyp):
    """Calculates recall.
    Args:
    - ref: a list of 0's and 1's extracted from a reference file
    - hyp: a list of 0's and 1's extracted from a hypothesis file
    Returns:
    - A floating point number indicating the recall rate of the hypothesis
    """
    (n, nt, ntp) = (len(ref), 0.0, 0.0)
    for i in range(n):
            if bool(ref[i]):
                    nt += 1
                    if bool(hyp[i]):
                            ntp += 1
    return ntp/nt

Как бы выглядела функция гармонического среднего? Все, что у меня есть, это, но я знаю, что это неправильно:

def F1(precision, recall):
    (2*precision*recall)/(precision+recall)

Ответы на вопрос(2)

Ваш ответ на вопрос