(y_true, y_score, sample_weight=None)
return AUC*1.0/class_num
Compute the micro_auc_score.

    Parameters
    ----------
    y_true : array, shape = [n_samples] or [n_samples, n_classes]
        True binary labels or binary label indicators.

    y_score : array, shape = [n_samples] or [n_samples, n_classes]
        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
    -------
    micro_auc_score : float
Compute the micro_auc_score.
Compute the micro_auc_score .
def micro_auc_score(y_true, y_score, sample_weight=None):
    """
    Compute the micro_auc_score.

    Parameters
    ----------
    y_true : array, shape = [n_samples] or [n_samples, n_classes]
        True binary labels or binary label indicators.

    y_score : array, shape = [n_samples] or [n_samples, n_classes]
        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
    -------
    micro_auc_score : float
    """
    check_consistent_length(y_true, y_score, sample_weight)
    if y_true.shape != y_score.shape:
        raise ValueError("y_true and y_score have different shape")

    # Handle badly formatted array and the degenerate case with one label
    y_type = type_of_target(y_true)
    if (y_type != "multilabel" and
            not (y_type == "binary" and y_true.ndim == 2)):
        raise ValueError("{0} format is not supported".format(y_type))

    test_data_num = y_score.shape[0]
    class_num = y_score.shape[1]
    P = []
    N = []
    labels_size = []
    not_labels_size = []
    AUC = 0
    for i in range(class_num):
        P.append([])
        N.append([])
    
    for i in range(test_data_num):
            for j in range(class_num):
                if y_true[i][j] == 1:
                    P[j].append(i)
                else:
                    N[j].append(i)
    
    for i in range(class_num):
        labels_size.append(len(P[i]))
        not_labels_size.append(len(N[i]))
    
    for i in range(class_num):
        auc = 0
        for j in range(labels_size[i]):
            for k in range(not_labels_size[i]):
                pos = y_score[P[i][j]][i]
                neg = y_score[N[i][k]][i]
                if pos > neg:
                    auc = auc + 1
        AUC = AUC + auc*1.0/(labels_size[i]*not_labels_size[i])
    return AUC*1.0/class_num
def micro_auc_score ( y_true , y_score , sample_weight = None ) : check_consistent_length ( y_true , y_score , sample_weight ) if y_true . shape != y_score . shape : raise ValueError ( "y_true and y_score have different shape" ) # Handle badly formatted array and the degenerate case with one label y_type = type_of_target ( y_true ) if ( y_type != "multilabel" and not ( y_type == "binary" and y_true . ndim == 2 ) ) : raise ValueError ( "{0} format is not supported" . format ( y_type ) ) test_data_num = y_score . shape [ 0 ] class_num = y_score . shape [ 1 ] P = [ ] N = [ ] labels_size = [ ] not_labels_size = [ ] AUC = 0 for i in range ( class_num ) : P . append ( [ ] ) N . append ( [ ] ) for i in range ( test_data_num ) : for j in range ( class_num ) : if y_true [ i ] [ j ] == 1 : P [ j ] . append ( i ) else : N [ j ] . append ( i ) for i in range ( class_num ) : labels_size . append ( len ( P [ i ] ) ) not_labels_size . append ( len ( N [ i ] ) ) for i in range ( class_num ) : auc = 0 for j in range ( labels_size [ i ] ) : for k in range ( not_labels_size [ i ] ) : pos = y_score [ P [ i ] [ j ] ] [ i ] neg = y_score [ N [ i ] [ k ] ] [ i ] if pos > neg : auc = auc + 1 AUC = AUC + auc * 1.0 / ( labels_size [ i ] * not_labels_size [ i ] ) return AUC * 1.0 / class_num