def fbeta_precision_recall(precision_val, recall_val, beta):
    """
    Fbeta score for a given precision and recall
    :param precision_val: precision score of a certain class
    :param recall_val: recall score of a certain class
    :param beta: beta coefficient
    :return: fbeta score
    """
    beta2 = beta ** 2

    if precision_val + recall_val == 0:
        return 0

    return (1 + beta2) * (precision_val * recall_val) / (beta2 * precision_val + recall_val)