GitHunt
LI

Header-only AUROC/ROC-AUC in C++11

= AUROC
Rui LIU (@liurui39660)

Header-only AUROC/ROC-AUC in C++11

== Usage

. Include include/AUROC.hpp
. Call AUROC(label, score, n) and get the result

== Requirement

C++11 and standard libraries

== Arguments

  • 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

== Q&A

[qanda]

How fast is it?::
On my desktop PC, ~1.35s for ~8M records. +
The only sort 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.

Languages

C++100.0%

Contributors

MIT License
Created November 29, 2020
Updated December 5, 2024