/AUROC

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

Primary LanguageC++MIT LicenseMIT

AUROC

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

Usage

  1. Include include/AUROC.hpp

  2. 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

  1. How fast is it?

    On my desktop PC, ~1.35s for ~8M records.
    The only sort takes ~80% of the running time.

  2. How accurate is it?

    From tests and my daily usage, the difference with sklearn.metrics.roc_auc_score is mostly less than 1e-15.

  3. Where are the test code and data?

    I didn’t upload them to GitHub.

  4. 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.