We Recommend

Beginning VB.NET Beginning VB.NET
Visual Basic .NET is the latest version of the most widely used programming language in the world, popular with professional developers and complete beginners alike. This book will teach you Visual Basic .NET from first principles. You'll quickly and easily learn how to write Visual Basic .NET code and create attractive windows and forms for the users of your applications.


Posted By

benjamin on 10/29/09


Tagged


Versions (?)


area under the curve (AUC)


Published in: MatLab 


URL: http://www.myoutsourcedbrain.com/2008/11/receiver-operating-characteristic-roc.html

My implementation corresponding to Tom Fawcett's algorithm 3 in "roc graphs: notes and practical considerations for researchers, " 2004. Please see blog post for explanations and leave comments there.

  1. function auc=areaundercurve(FPR,TPR);
  2. % given true positive rate and false positive rate calculates the area under the curve
  3. % true positive are on the y-axis and false positives on the x-axis
  4. % sum rectangular area between all points
  5. % example: auc=areaundercurve(FPR,TPR);
  6. [x2,inds]=sort(FPR);
  7. x2=[x2,1]; % the trick is in inventing a last point 1,1
  8. y2=TPR(inds);
  9. y2=[y2,1];
  10. xdiff=diff(x2);
  11. xdiff=[x2(1),xdiff];
  12. auc1=sum(y2.*xdiff); % upper point area
  13. auc2=sum([0,y2([1:end-1])].*xdiff); % lower point area
  14. auc=mean([auc1,auc2]);

Report this snippet 

You need to login to post a comment.