Header-only AUROC/ROC-AUC in C++11
-
T1
,T2
: Type of array elements, should be a numerical type -
label
: Array of ground truth labels, 0 is negative, 1 is positive -
score
: Array of predicted scores, can be any real finite number -
n
: Number of elements in the array, I assume it’s correct -
Return: AUROC/ROC-AUC score, range [0.0, 1.0]; or NaN if inputs are problematic
-
How fast is it?
On my desktop PC, ~1.35s for ~8M records.
The onlysort
takes ~80% of the running time. -
How accurate is it?
From tests and my daily usage, the difference with
sklearn.metrics.roc_auc_score
is mostly less than 1e-15. -
Where are the test code and data?
I didn’t upload them to GitHub.
-
Why not using plain C?
qsort
array index might be very tedious.
Otherwise, C11 is required for the additional argument passed to the comparison function.