1 | %AUCDLPC AUC-LP classifier on dissimilarity data
|
---|
2 | %
|
---|
3 | % [W,R] = AUCLPC(D,C)
|
---|
4 | %
|
---|
5 | % INPUT
|
---|
6 | % D Dissimilarity data
|
---|
7 | % C Trade-off parameter in the LP-optimization, similar to C in the SVM
|
---|
8 | % (optional; default: 10)
|
---|
9 | %
|
---|
10 | % OUTPUT
|
---|
11 | % W Mapping: AUC-LP Classifier
|
---|
12 | % R Object identifiers of support objects
|
---|
13 | %
|
---|
14 | % DEFAULTS
|
---|
15 | % C = 10
|
---|
16 | %
|
---|
17 | % DESCRIPTION
|
---|
18 | % Determines a linear programming classifier for the dissimilarity representation D.
|
---|
19 | % This LP-function is determined for a two-class problem based on the maximization
|
---|
20 | % of the AUC measure (area under the curve) of the corresponding ROC curve.
|
---|
21 | % It calls AUCLPM(D,C,'SUBK',1).
|
---|
22 | %
|
---|
23 | %
|
---|
24 | % SEE ALSO
|
---|
25 | % MAPPINGS, DATASETS, AUCLPC, AUCLPM
|
---|
26 | %
|
---|
27 | % REFERENCE
|
---|
28 | % D.M.J. Tax and C. Veenman, Tuning the hyperparameter of an AUC-optimized classifier,
|
---|
29 | % in: Seventeenth Belgium-Netherlands conference on artificial intelligence, 2005, 224-231.
|
---|
30 |
|
---|
31 | % David Tax, Robert P.W. Duin, Elzbieta Pekalska, ela.pekalska@googlemail.com |
---|
32 | % Faculty of Electrical Engineering, Mathematics and Computer Science,
|
---|
33 | % Delft University of Technology, The Netherlands.
|
---|
34 |
|
---|
35 |
|
---|
36 | function [w,r] = aucdlpc(d,C,usematlab,prec)
|
---|
37 |
|
---|
38 | if nargin < 4, prec = 1e-7; end;
|
---|
39 | if nargin < 3, usematlab = 0; end
|
---|
40 | if nargin < 2 | isempty(C),
|
---|
41 | C = 10;
|
---|
42 | end
|
---|
43 |
|
---|
44 | if nargin < 1 | isempty(d)
|
---|
45 | w = prmapping(mfilename,C);
|
---|
46 | w = setname(w,'AUCDLPC');
|
---|
47 | return
|
---|
48 | end
|
---|
49 |
|
---|
50 |
|
---|
51 | [m,k,c] = getsize(d);
|
---|
52 |
|
---|
53 | if c > 2,
|
---|
54 | % multi-class problem
|
---|
55 |
|
---|
56 | lab = getlab(d);
|
---|
57 | fe = getfeatlab(d);
|
---|
58 | [nlab,nfe,lablist] = renumlab(lab,fe);
|
---|
59 |
|
---|
60 | w = [];
|
---|
61 | N = [];
|
---|
62 | for i=1:c
|
---|
63 | mlab = 2 - (nlab == i);
|
---|
64 | mfe = 2 - (nfe == i);
|
---|
65 | dd = setlabels(d,mlab);
|
---|
66 | dd = setfeatlab(dd,mfe);
|
---|
67 | if ~isempty(d.prior)
|
---|
68 | dd = setprior(dd,[d.prior(i),1-d.prior(i)]');
|
---|
69 | end
|
---|
70 | [v,J]= aucdlpc(dd,C,usematlab,prec);
|
---|
71 | w = [w,setlabels(v(:,1),lablist(i,:))];
|
---|
72 | N = [N; J];
|
---|
73 | end
|
---|
74 | r = unique(N);
|
---|
75 | w = setname(w,'AUCDLPC');
|
---|
76 | return
|
---|
77 |
|
---|
78 | else
|
---|
79 | % two-class problem
|
---|
80 |
|
---|
81 | v = auclpm(d,C,'subk',1,1,usematlab);
|
---|
82 | nlab = getnlab(d);
|
---|
83 | p = getprior(d);
|
---|
84 | q = +(d*v);
|
---|
85 | [qq,J] = sort(q);
|
---|
86 | n1 = sum(nlab == 1);
|
---|
87 | n2 = sum(nlab == 2);
|
---|
88 | % e = n1-n2;
|
---|
89 | % J1 = cumsum(nlab(J) == 1);
|
---|
90 | % J2 = n2-cumsum(nlab(J) == 2);
|
---|
91 | e1 = p(1)*cumsum(nlab(J) == 1)/n1 + p(2)*(1 - cumsum(nlab(J) == 2)/n2);
|
---|
92 | e2 = p(2)*cumsum(nlab(J) == 2)/n2 + p(1)*(1 - cumsum(nlab(J) == 1)/n1);
|
---|
93 |
|
---|
94 | [min1,k1] = min(e1);
|
---|
95 | [min2,k2] = min(e2);
|
---|
96 | % if min1 < min2 % NO!! We should assume that AUCLPM gives a proper
|
---|
97 | % if k1 == length(q) % and well defined class order: 1 -> -, 2 > +
|
---|
98 | % w0 = q(J(k1)) + realmin;
|
---|
99 | % else
|
---|
100 | % w0 = (q(J(k1))+q(J(k1+1)))/2;
|
---|
101 | % end
|
---|
102 | % w = v.data.u - v.data.v;
|
---|
103 | % else
|
---|
104 | if k2 == length(q)
|
---|
105 | w0 = q(J(k2)) + realmin;
|
---|
106 | else
|
---|
107 | w0 = (q(J(k2))+q(J(k2+1)))/2;
|
---|
108 | end
|
---|
109 | w = v.data.v - v.data.u;
|
---|
110 | % end
|
---|
111 |
|
---|
112 | ss = sum(abs(w));
|
---|
113 | J = find(abs(w) >= ss*prec);
|
---|
114 | w = featsel(k,J)*affine(w(J),w0,d(:,J),getlablist(d),k,c);
|
---|
115 | w = setout_conv(w,1);
|
---|
116 | w = setname(w,'AUCDLPC');
|
---|
117 | r = J;
|
---|
118 | end
|
---|
119 | return
|
---|