def f_score(recall, precision, beta=1):
    """
    Computes the F-score given the recall, precision,
    and an optional beta. The default beta will compute
    the harmonic mean of the recall and precision without
    bias toward either.

    :param recall
        The recall ratio, [0, 1]
    
    :param precision
        The precision ratio, [0, 1]
    
    :param beta
        The weight of precision with respect to recall.
    
    :return
        <float:f-score>
    """
    if precision == 0 or recall == 0:
        return 0
    beta_2 = beta * beta
    return (1 + beta_2) * precision * recall / (beta_2 * precision + recall)