def _auc(y_true, y_score):
 pos_label = np.unique(y_true)[1]
 pos = y_score[(y_true == pos_label)]
 neg = y_score[(y_true != pos_label)]
 diff_matrix = (pos.reshape(1, (-1)) - neg.reshape((-1), 1))
 n_correct = np.sum((diff_matrix > 0))
 return (n_correct / float((len(pos) * len(neg))))

def _auc ( y_true , y_score ) : pos_label = np . unique ( y_true ) [ 1 ] pos = y_score [ ( y_true == pos_label ) ] neg = y_score [ ( y_true != pos_label ) ] diff_matrix = ( pos . reshape ( 1 , ( - 1 ) ) - neg . reshape ( ( - 1 ) , 1 ) ) n_correct = np . sum ( ( diff_matrix > 0 ) ) return ( n_correct / float ( ( len ( pos ) * len ( neg ) ) ) )
alternative implementation to check for correctness of roc_auc_score .