def auc(actual, posterior):
 r = tied_rank(posterior)
 num_positive = len([0 for x in actual if (x == 1)])
 num_negative = (len(actual) - num_positive)
 sum_positive = sum([r[i] for i in range(len(r)) if (actual[i] == 1)])
 auc = ((sum_positive - ((num_positive * (num_positive + 1)) / 2.0)) / (num_negative * num_positive))
 return auc

def auc ( actual , posterior ) : r = tied_rank ( posterior ) num_positive = len ( [ 0 for x in actual if ( x == 1 ) ] ) num_negative = ( len ( actual ) - num_positive ) sum_positive = sum ( [ r [ i ] for i in range ( len ( r ) ) if ( actual [ i ] == 1 ) ] ) auc = ( ( sum_positive - ( ( num_positive * ( num_positive + 1 ) ) / 2.0 ) ) / ( num_negative * num_positive ) ) return auc
computes the area under the receiver-operater characteristic this function computes the auc error metric for binary classification .