[5] | 1 | %AUC Area-Under-the-Curve error estimator
|
---|
| 2 | %
|
---|
| 3 | % E = AUC(A,W)
|
---|
| 4 | % E = AUC(A*W)
|
---|
| 5 | % E = A*W*AUC
|
---|
| 6 | %
|
---|
| 7 | % Returns the ROC area_under_the_curve error
|
---|
| 8 | % for the test set A on the classifier W.
|
---|
| 9 | %
|
---|
| 10 | % Two class problems only
|
---|
| 11 |
|
---|
| 12 | % Copyright: R.P.W. Duin, r.p.w.duin@prtools.org
|
---|
| 13 | % Faculty EWI, Delft University of Technology
|
---|
| 14 | % P.O. Box 5031, 2600 GA Delft, The Netherlands
|
---|
| 15 |
|
---|
| 16 | function e = auc(a,w)
|
---|
| 17 |
|
---|
| 18 | if nargin == 0 | isempty(a)
|
---|
| 19 | e = mapping('auc','fixed');
|
---|
| 20 | return;
|
---|
| 21 | end
|
---|
| 22 |
|
---|
| 23 | if nargin == 1, d = a*classc; end
|
---|
| 24 | if nargin == 2, d = a*w*classc; end
|
---|
| 25 |
|
---|
| 26 | m = size(d,1);
|
---|
| 27 | c = getsize(d,3);
|
---|
| 28 | if c ~= 2
|
---|
| 29 | error('Routine implemented for two-class problems only')
|
---|
| 30 | end
|
---|
| 31 |
|
---|
| 32 | nlab = getnlab(d);
|
---|
| 33 | s = +d; s = sort(s(:));
|
---|
| 34 | thr = [s' 1];
|
---|
| 35 |
|
---|
| 36 | e1 = []; e2 = [];
|
---|
| 37 |
|
---|
| 38 | % NLAB_OUT will be one where B is larger than THR.
|
---|
| 39 | I = matchlablist(d.lablist,d.featlab); % Correct possible changes class orders
|
---|
| 40 |
|
---|
| 41 | nlab_out = (repmat(+d(:,I(1)),1,m*c+1) > repmat(thr,m,1));
|
---|
| 42 |
|
---|
| 43 | % ERRS will be 1 where the numeric label is unequal to NLAB_OUT
|
---|
| 44 | % (i.e., where errors occur).
|
---|
| 45 | errs = (repmat((nlab==1),1,m*c+1) ~= nlab_out);
|
---|
| 46 |
|
---|
| 47 | % Split the cases where ERRS = 1 into cases for CLAS (E1) and all
|
---|
| 48 | % other classes (E2).
|
---|
| 49 |
|
---|
| 50 | e1 = mean(errs(find(nlab==1),:),1);
|
---|
| 51 | e2 = mean(errs(find(nlab~=1),:),1);
|
---|
| 52 |
|
---|
| 53 | J = [1:m*c];
|
---|
| 54 | e = (e1(J+1)-e1(J))*(e2(J) + e2(J+1))'/2; |
---|