def coverage_error(y_true, y_score, sample_weight=None):
 y_true = check_array(y_true, ensure_2d=False)
 y_score = check_array(y_score, ensure_2d=False)
 check_consistent_length(y_true, y_score, sample_weight)
 y_type = type_of_target(y_true)
 if (y_type != 'multilabel-indicator'):
  raise ValueError('{0} format is not supported'.format(y_type))
 if (y_true.shape != y_score.shape):
  raise ValueError('y_true and y_score have different shape')
 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 ) : y_true = check_array ( y_true , ensure_2d = False ) y_score = check_array ( y_score , ensure_2d = False ) check_consistent_length ( y_true , y_score , sample_weight ) y_type = type_of_target ( y_true ) if ( y_type != 'multilabel-indicator' ) : raise ValueError ( '{0} format is not supported' . format ( y_type ) ) if ( y_true . shape != y_score . shape ) : raise ValueError ( 'y_true and y_score have different shape' ) 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 )
coverage error measure compute how far we need to go through the ranked scores to cover all true labels .