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  

Comments

RSS Icon Subscribe to comments
Posted By: liange on June 21, 2011

If possible please keep the snapshot of the end result after execution. I cannot estimate how this will be. SEO Reseller

You need to login to post a comment.