File Exchange

image thumbnail

Faster ROC-AUC

version (3.43 KB) by Enric Junque de Fortuny
Fast calculation of AUC of an ROC for binary classification problems, written in C++.


Updated 24 Jun 2013

View Version History

View License

AUC = fastAUC(labels,scores,posclass)

Calculates the Area under the ROC curve (AUC) for problems involving two distinct targets (i.e. binary classification problems). Main advantages of using this function are:

Written in C++, it performs much faster than perfcurve (Matlab statistics toolbox). On a benchmark of 20 million instances this function achieves a speed up factor of more than 100 with respect to perfcurve.

Works without needing to install the statistics toolbox.

Please send any questions, comments and/or suggestions by mail.

Cite As

Enric Junque de Fortuny (2021). Faster ROC-AUC (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

dymitr ruta

Its quite fast, well done, but it crashes Matlab if the labels are logical.


When I run install.m, matlab showed the following errors:

Error using mex
~\fastAUC\fastAUC.cpp: In function 'double trapezoidArea(double, double, double, double)':
~\fastAUC\fastAUC.cpp:155:32: error: call of overloaded 'abs(double)' is ambiguous
double base = std::abs(X1-X2);
In file included from C:\Program Files\MATLAB\R2016a/extern/include/matrix.h:23:0,
from ~\fastAUC\fastAUC.cpp:29:
C:/TDM-GCC-64/x86_64-w64-mingw32/include/stdlib.h:329:15: note: candidate: int abs(int)
int __cdecl abs(int _X);
In file included from C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/bits/stl_algo.h:59:0,
from C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/algorithm:62,
from ~\fastAUC\fastAUC.cpp:33:
C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/cstdlib:166:3: note: candidate: long int std::abs(long int)
abs(long __i) { return __builtin_labs(__i); }
C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/cstdlib:174:3: note: candidate: long long int std::abs(long long int)
abs(long long __x) { return __builtin_llabs (__x); }
C:/TDM-GCC-64/lib/gcc/x86_64-w64-mingw32/5.1.0/include/c++/cstdlib:179:3: note: candidate: __int128 std::abs(__int128)
abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }

Windows 8.1
Dev-C++ v.5.7.0

Kimberly Glass


Ryan Smith

Works as described. Thanks!


MATLAB Release Compatibility
Created with R2013a
Compatible with any release
Platform Compatibility
Windows macOS Linux


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!