area under the curve (AUC)


/ Published in: MatLab
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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]);

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.