[5] | 1 | %AUCLPC Area Under the Curce Linear Programming Classifier
|
---|
| 2 | %
|
---|
| 3 | % [W,R] = AUCLPC(A,C,rtype, par, unitnorm, usematlab)
|
---|
| 4 | %
|
---|
| 5 | % A Dataset
|
---|
| 6 | % C Trade off parameter, default C = 10
|
---|
| 7 | % W Linear Classifier
|
---|
| 8 | % R Indices of support objects
|
---|
| 9 | %
|
---|
| 10 | % For other parameters see AUCLPM.
|
---|
| 11 | % The classifier optimizes the AUC for two-class problems using AUCLPM.
|
---|
| 12 | % The best threshold for the training set A is found using
|
---|
| 13 | % the class priors. Multi-class problems are solved using the
|
---|
| 14 | % one-against-rest scheme of MCLASSC (MODE = 'single').
|
---|
| 15 | %
|
---|
| 16 | % REFERENCE
|
---|
| 17 | % D.M.J. Tax and C.J. Veenman, Tuning the hyperparameter of an AUC-optimized
|
---|
| 18 | % classifier, Proc. BNAIC 2005, 2005.
|
---|
| 19 | %
|
---|
| 20 | % SEE ALSO
|
---|
| 21 | % DATASETS, MAPPINGS, AUCLPM, MCLASSC
|
---|
| 22 |
|
---|
| 23 | % Copyright: D.M.J. Tax, R.P.W. Duin, r.p.w.duin@prtools.org
|
---|
| 24 | % Faculty EWI, Delft University of Technology
|
---|
| 25 | % P.O. Box 5031, 2600 GA Delft, The Netherlands
|
---|
| 26 |
|
---|
| 27 | function [w,r] = auclpc(a,C, rtype, par, unitnorm, usematlab)
|
---|
| 28 |
|
---|
| 29 | if (nargin < 6)
|
---|
| 30 | usematlab = 0;
|
---|
| 31 | end
|
---|
| 32 | if (nargin < 5)
|
---|
| 33 | unitnorm = 1;
|
---|
| 34 | end
|
---|
| 35 | if (nargin < 4)
|
---|
| 36 | par = 0.25;
|
---|
| 37 | end
|
---|
| 38 | if (nargin < 3)
|
---|
| 39 | rtype = 'subk';
|
---|
| 40 | end
|
---|
| 41 | if (nargin < 2)
|
---|
| 42 | prwarning(3,'Lambda set to ten');
|
---|
| 43 | C = 10;
|
---|
| 44 | end
|
---|
| 45 |
|
---|
| 46 | if nargin < 1 | isempty(a)
|
---|
| 47 | w = mapping(mfilename,{C,rtype,par,unitnorm,usematlab});
|
---|
| 48 | w = setname(w,'AUC_LP');
|
---|
| 49 | return
|
---|
| 50 | end
|
---|
| 51 |
|
---|
| 52 | [m,k,c] = getsize(a);
|
---|
| 53 | if c > 2
|
---|
| 54 | %w = mclassc(a,feval(mfilename));
|
---|
| 55 | w = mclassc(a,auclpc);
|
---|
| 56 | w = setname(w,'AUC_LP');
|
---|
| 57 | N = [];
|
---|
| 58 | for j=1:c
|
---|
| 59 | N = [N w.data{j}.data{1}.data{1}.data];
|
---|
| 60 | end
|
---|
| 61 | r = unique(N);
|
---|
| 62 | return
|
---|
| 63 | end
|
---|
| 64 |
|
---|
| 65 | v = auclpm(a,C,rtype, par, unitnorm, usematlab);
|
---|
| 66 | nlab = getnlab(a);
|
---|
| 67 | p = getprior(a);
|
---|
| 68 | d = +(a*v);
|
---|
| 69 | [dd,J] = sort(d);
|
---|
| 70 | n1 = sum(nlab==1);
|
---|
| 71 | n2 = sum(nlab==2);
|
---|
| 72 | %e = n1-n2;
|
---|
| 73 | %J1 = cumsum(nlab(J) == 1);
|
---|
| 74 | %J2 = n2-cumsum(nlab(J) == 2);
|
---|
| 75 | e1 = p(1)*cumsum(nlab(J) == 1)/n1 + p(2)*(1 - cumsum(nlab(J) == 2)/n2);
|
---|
| 76 | e2 = p(2)*cumsum(nlab(J) == 2)/n2 + p(1)*(1 - cumsum(nlab(J) == 1)/n1);
|
---|
| 77 |
|
---|
| 78 | [min1,k1] = min(e1);
|
---|
| 79 | [min2,k2] = min(e2);
|
---|
| 80 | %if min1 < min2 % NO!! We should assume that AUCLPM gives a proper
|
---|
| 81 | % if k1 == length(d) % and well defined class order: 1 -> -, 2 > +
|
---|
| 82 | % w0 = d(J(k1)) + realmin;
|
---|
| 83 | % else
|
---|
| 84 | % w0 = (d(J(k1))+d(J(k1+1)))/2;
|
---|
| 85 | % end
|
---|
| 86 | % w = v.data.u - v.data.v;
|
---|
| 87 | %else
|
---|
| 88 | if k2 == length(d)
|
---|
| 89 | w0 = d(J(k2)) + realmin;
|
---|
| 90 | else
|
---|
| 91 | w0 = (d(J(k2))+d(J(k2+1)))/2;
|
---|
| 92 | end
|
---|
| 93 | w = v.data.v - v.data.u;
|
---|
| 94 | %end
|
---|
| 95 | %J = find(w~=0);
|
---|
| 96 | prec = 1e-7; % this is really choosing the significant guys
|
---|
| 97 | ss = sum(abs(w));
|
---|
| 98 | J = find(abs(w) > ss*prec);
|
---|
| 99 |
|
---|
| 100 | w = featsel(k,J)*affine(w(J),w0,a(:,J),getlablist(a),k,c);
|
---|
| 101 | w = setout_conv(w,1);
|
---|
| 102 | w = setname(w,'AUC_LP');
|
---|
| 103 | r = J;
|
---|
| 104 |
|
---|
| 105 |
|
---|