(y_true, y_score, sample_weight=None)
return np.average(coverage, weights=sample_weight)
Coverage error measure.
    Compute how far we need to go through the ranked scores to cover all
    true labels. The best value is equal to the average number
    of labels in ``y_true`` per sample.

    Ties in ``y_scores`` are broken by giving maximal rank that would have
    been assigned to all tied values.

    Parameters
    ----------
    y_true : array, shape = [n_samples, n_labels]
        True binary labels in binary indicator format.

    y_score : array, shape = [n_samples, n_labels]
        Target scores, can either be probability estimates of the positive
        class, confidence values, or non-thresholded measure of decisions
        (as returned by "decision_function" on some classifiers).

    sample_weight : array-like of shape = [n_samples], optional
        Sample weights.

    Returns
    -------
    coverage_error : float
Coverage error measure.
    Compute how far we need to go through the ranked scores to cover all
    true labels. The best value is equal to the average number
    of labels in ``y_true`` per sample.
Coverage error measure . Compute how far we need to go through the ranked scores to cover all true labels . The best value is equal to the average number of labels in y_true per sample .
def coverage_error(y_true, y_score, sample_weight=None):
    """Coverage error measure.
    Compute how far we need to go through the ranked scores to cover all
    true labels. The best value is equal to the average number
    of labels in ``y_true`` per sample.

    Ties in ``y_scores`` are broken by giving maximal rank that would have
    been assigned to all tied values.

    Parameters
    ----------
    y_true : array, shape = [n_samples, n_labels]
        True binary labels in binary indicator format.

    y_score : array, shape = [n_samples, n_labels]
        Target scores, can either be probability estimates of the positive
        class, confidence values, or non-thresholded measure of decisions
        (as returned by "decision_function" on some classifiers).

    sample_weight : array-like of shape = [n_samples], optional
        Sample weights.

    Returns
    -------
    coverage_error : float
    """
    check_consistent_length(y_true, y_score, sample_weight)
    y_type = type_of_target(y_true)
    if y_type != "multilabel":
        raise ValueError("{0} format is not supported".format(y_type))
    y_score_mask = np.ma.masked_array(y_score, mask=np.logical_not(y_true))
    y_min_relevant = y_score_mask.min(axis=1).reshape((-1, 1))
    coverage = (y_score >= y_min_relevant).sum(axis=1)
    coverage = coverage.filled(0)
    return np.average(coverage, weights=sample_weight)
def coverage_error ( y_true , y_score , sample_weight = None ) : check_consistent_length ( y_true , y_score , sample_weight ) y_type = type_of_target ( y_true ) if y_type != "multilabel" : raise ValueError ( "{0} format is not supported" . format ( y_type ) ) y_score_mask = np . ma . masked_array ( y_score , mask = np . logical_not ( y_true ) ) y_min_relevant = y_score_mask . min ( axis = 1 ) . reshape ( ( - 1 , 1 ) ) coverage = ( y_score >= y_min_relevant ) . sum ( axis = 1 ) coverage = coverage . filled ( 0 ) return np . average ( coverage , weights = sample_weight )