Premium problem140. ROC AUC by Rank Statistic, with Ties

Hard Locked

Given binary labels y (n,) and continuous scores s (n,), return the scalar ROC AUC:

  • use the Mann-Whitney identity (sum_of_positive_ranks - n_pos*(n_pos+1)/2) / (n_pos*n_neg)
  • assign average ranks to tied scores

Input

y = [0 0 1 1]
s = [0.1  0.4  0.35 0.8 ]

Output

0.75

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)