1 | %LINPROGC Sparce linear programming classifier
|
---|
2 | %
|
---|
3 | % W = LINPROGC(A,N,TYPE,PARAM)
|
---|
4 | % W = A*LINPROGC([],N,TYPE,PARAM)
|
---|
5 | %
|
---|
6 | % INPUT
|
---|
7 | % A Dataset
|
---|
8 | % N Degree of classifier, 1,2,3, ...
|
---|
9 | % TYPE Linear programming option, see below
|
---|
10 | % PARAM Additional parameter
|
---|
11 | %
|
---|
12 | % OUTPUT
|
---|
13 | % W Classifier
|
---|
14 | %
|
---|
15 | % The parameter TYPE stands for the possible LP-machines:
|
---|
16 | % 'SIMPLE' - the most simple formulation; no sparse solution, hence
|
---|
17 | % all features are used.
|
---|
18 | % 'STANDARD' - minimization of the training misclassification errors; no
|
---|
19 | % sparse solution, hence all features are used.
|
---|
20 | % 'C-SPARSE' - a sparse solution (feature selection); a formulation similar
|
---|
21 | % to the LP_1 SVC, adjusted for the purpose of feature selection.
|
---|
22 | % PARAM is a tradeoff parameter, as in the traditional SVC.
|
---|
23 | % Usually, PARAM = 1 or more. Default PARAM = 1.
|
---|
24 | % 'NU-SPARSE' - a sparse solution (feature selection); a formulation similar
|
---|
25 | % to the LP_1 SVC, based on the paper of Graepel, Herbrich, Smola etc
|
---|
26 | % 'Classification on proximity data with LP-machines' adjusted
|
---|
27 | % for the purpose of feature selection.
|
---|
28 | % PARAM is a tradeoff parameter, usually PARAM = 0.05 or 0.1.
|
---|
29 | % It is an upper bound on the misclassfied training objects.
|
---|
30 | % So, for well separable problems, PARAM = 0.01 or PARAM = 0.05.
|
---|
31 | % Default PARAM is the leave-one-out 1-NN error of A.
|
---|
32 | %
|
---|
33 | % DESCRIPTION
|
---|
34 | % A linear programming solution, similar to the LP_1 SVC is found for the
|
---|
35 | % polynomial classifier (degree N, default N=1).
|
---|
36 | % Sparse solutions based on TYPE = C-SPARSE and TYPE = NU-SPARSE reduce the
|
---|
37 | % number of polynomial terms, thereby performing an automatic feature
|
---|
38 | % selection.
|
---|
39 | %
|
---|
40 | % This routine is effectively a wrapper around FSELLPC
|
---|
41 | %
|
---|
42 | % SEE ALSO
|
---|
43 | % MAPPINGS, DATASETS, POLYC, FSELLPC
|
---|
44 |
|
---|
45 | % Elzbieta Pekalska, Robert P.W. Duin, e.pekalska@ewi.tudelft.nl
|
---|
46 | % Faculty of Electrical Engineering, Mathematics and Computer Science,
|
---|
47 | % Delft University of Technology, The Netherlands.
|
---|
48 |
|
---|
49 | function w = linprogc(a,n,type,param)
|
---|
50 | if nargin < 4, param =[]; end
|
---|
51 | if nargin < 3, type = 'standard'; end
|
---|
52 | if nargin < 2, n = 1; end
|
---|
53 | name = [type '-LP'];
|
---|
54 | if nargin < 1 | isempty(a)
|
---|
55 | w = mapping(mfilename,{n,type});
|
---|
56 | w = setname(w,name);
|
---|
57 | return
|
---|
58 | end
|
---|
59 | vs = scalem(a,'variance');
|
---|
60 | b = a*vs;
|
---|
61 | switch type
|
---|
62 | case {'simple', 'Simple', 'SIMPLE'}
|
---|
63 | type = 'Simple';
|
---|
64 | param = 1;
|
---|
65 | case {'standard', 'Standard', 'STANDARD'}
|
---|
66 | type = 'Standard';
|
---|
67 | param = 1;
|
---|
68 | case {'c-sparse', 'C-Sparse', 'c-Sparse'}
|
---|
69 | type = 'c-Sparse';
|
---|
70 | if isempty(param), param = 1; end
|
---|
71 | case {'nu-sparse','nu-Sparse','\nu-Sparse'}
|
---|
72 | type = 'nu-Sparse';
|
---|
73 | if isempty(param), param = testk(b,1); end
|
---|
74 | otherwise
|
---|
75 | error('Wrong Type')
|
---|
76 | end
|
---|
77 | vp = fsellpc([],1,type,param);
|
---|
78 | w = polyc(b,vp,n,1);
|
---|
79 | w = vs*w;
|
---|
80 | name = [type '-LP'];
|
---|
81 | w = setname(w,name);
|
---|
82 | return
|
---|