The area under the ROC curve equals the probability that a randomly chosen positive example scores higher than a randomly chosen negative one, with ties counting one half. That is the Mann-Whitney U statistic divided by the number of pairs. If R_pos is the sum of the positives' ranks (ascending, ties averaged), then
AUC = (R_pos - n_pos (n_pos + 1) / 2) / (n_pos * n_neg).
Implement auc_rank(scores, labels) with labels in {0, 1}. Return the AUC as a float.
scores and labels are 1-D arrays of equal length.labels holds only 0 and 1. Otherwise raise ValueError.ValueError.Rank the scores ascending. Average the ranks of tied scores, then sum the ranks of the positive examples.
No results yet
Run your code to check it against the examples, or submit to run every test.