image thumbnail

faster perfcurve (just in case you use FPR and TPR)

version (14.2 KB) by Hanan Shteingart
Did you notice perfcurve is slow? This version of perfcurve is faster


Updated 10 Jun 2013

View License

This version is identical to the one provided by matlab with a small change if "FPR" or "TPR" are used for X and Y.
Instead of using the tedious "arrayfun" I used vector cumsum functions.

Here is a test for comparison
N = 1e5;
score = [rand(N,1); rand(N,1)-1];
label = [ones(N,1); zeros(N,1)];

perfcurve(label, score, 1);
perfcurve2(label, score,1);

Elapsed time is 17.614076 seconds.
Elapsed time is 0.164707 seconds.

I hope you will find it useful.

Cite As

Hanan Shteingart (2021). faster perfcurve (just in case you use FPR and TPR) (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012b
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!