source: prextra/auclpc.m @ 118

Last change on this file since 118 was 5, checked in by bduin, 14 years ago
File size: 2.6 KB
Line 
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
27function [w,r] = auclpc(a,C, rtype, par, unitnorm, usematlab)
28
29if (nargin < 6)
30        usematlab = 0;
31end
32if (nargin < 5)
33        unitnorm = 1;
34end
35if (nargin < 4)
36        par = 0.25;
37end
38if (nargin < 3)
39        rtype = 'subk';
40end
41if (nargin < 2)
42        prwarning(3,'Lambda set to ten');
43        C = 10;
44end
45
46if nargin < 1 | isempty(a)
47    w = mapping(mfilename,{C,rtype,par,unitnorm,usematlab});
48    w = setname(w,'AUC_LP');
49    return
50end
51
52[m,k,c] = getsize(a);
53if 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
63end
64
65v = auclpm(a,C,rtype, par, unitnorm, usematlab);
66nlab = getnlab(a);
67p = getprior(a);
68d = +(a*v);
69[dd,J] = sort(d);
70n1 = sum(nlab==1);
71n2 = sum(nlab==2);
72%e = n1-n2;
73%J1 = cumsum(nlab(J) == 1);
74%J2 = n2-cumsum(nlab(J) == 2);
75e1 = p(1)*cumsum(nlab(J) == 1)/n1 + p(2)*(1 - cumsum(nlab(J) == 2)/n2);
76e2 = 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);
96prec = 1e-7;   % this is really choosing the significant guys
97ss = sum(abs(w));
98J  = find(abs(w) > ss*prec);
99
100w = featsel(k,J)*affine(w(J),w0,a(:,J),getlablist(a),k,c);
101w = setout_conv(w,1);
102w = setname(w,'AUC_LP');
103r = J;
104   
105   
Note: See TracBrowser for help on using the repository browser.