Created
June 24, 2014 16:26
-
-
Save KrisKusano/3e5608324b58a5ca21a0 to your computer and use it in GitHub Desktop.
compute AUC for Kaggle Competition results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function auc = AUC(pred, act) | |
%% compute the AUC for Kaggle competitions | |
% auc = AUC(pred, act) returns the AUC value on [0, 1]. pred is the predicted | |
% class membership, {0, 1}, and act is the actual class membership, also {0, 1} | |
% | |
% Sources: | |
% http://link.springer.com/article/10.1023%2FA%3A1010920819831 | |
% http://www.kaggle.com/c/SemiSupervisedFeatureLearning/forums/t/919/auc-implementation/6130 | |
% | |
% Kristofer D. Kusano - 6/24/14 | |
% check | |
assert(all(size(pred) == size(act)),... | |
'size of pred and act must be equal') | |
assert(range(pred) == 1,... | |
'pred must be 0 or 1') | |
assert(range(act) == 1,... | |
'act must be 0 or 1') | |
% compute AUC | |
r = tiedrank(pred); | |
auc = (sum(r(act == 1)) - sum(act == 1)*(sum(act == 1) + 1) / 2) / .... | |
(sum(act == 1) * sum(act == 0)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment