def first_n_target_proportion_R(reference_patterns, estimated_patterns, n=5):
    """First n target proportion establishment recall metric.

    This metric is similar is similar to the establishment FPR score, but it
    only takes into account the first n estimated patterns and it only
    outputs the Recall value of it.

    Examples
    --------
    >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt")
    >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt")
    >>> R = mir_eval.pattern.first_n_target_proportion_R(
    ...                                 ref_patterns, est_patterns, n=5)

    Parameters
    ----------
    reference_patterns : list
        The reference patterns in the format returned by
        :func:`mir_eval.io.load_patterns()`
    estimated_patterns : list
        The estimated patterns in the same format
    n : int
        Number of patterns to consider from the estimated results, in
        the order they appear in the matrix.
        (Default value = 5)

    Returns
    -------
    recall : float
        The first n target proportion Recall.

    """

    validate(reference_patterns, estimated_patterns)
    # If no patterns were provided, metric is zero
    if _n_onset_midi(reference_patterns) == 0 or \
       _n_onset_midi(estimated_patterns) == 0:
        return 0., 0., 0.

    # Get only the first n patterns from the estimated results
    fn_est_patterns = estimated_patterns[:min(len(estimated_patterns), n)]

    F, P, R = establishment_FPR(reference_patterns, fn_est_patterns)
    return R
def first_n_target_proportion_R ( reference_patterns , estimated_patterns , n = 5 ) : validate ( reference_patterns , estimated_patterns ) if _n_onset_midi ( reference_patterns ) == 0 or _n_onset_midi ( estimated_patterns ) == 0 : return 0. , 0. , 0. fn_est_patterns = estimated_patterns [ : min ( len ( estimated_patterns ) , n ) ] F , P , R = establishment_FPR ( reference_patterns , fn_est_patterns ) return R
First n target proportion establishment recall metric.

    This metric is similar is similar to the establishment FPR score, but it
    only takes into account the first n estimated patterns and it only
    outputs the Recall value of it.

    Examples
    --------
    >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt")
    >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt")
    >>> R = mir_eval.pattern.first_n_target_proportion_R(
    ...                                 ref_patterns, est_patterns, n=5)

    Parameters
    ----------
    reference_patterns : list
        The reference patterns in the format returned by
        :func:`mir_eval.io.load_patterns()`
    estimated_patterns : list
        The estimated patterns in the same format
    n : int
        Number of patterns to consider from the estimated results, in
        the order they appear in the matrix.
        (Default value = 5)

    Returns
    -------
    recall : float
        The first n target proportion Recall.