source: prextra/linprogc.m @ 147

Last change on this file since 147 was 5, checked in by bduin, 14 years ago
File size: 2.9 KB
Line 
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
49function w = linprogc(a,n,type,param)
50if nargin < 4, param =[]; end
51if nargin < 3, type = 'standard'; end
52if nargin < 2, n =  1; end
53name = [type '-LP'];
54if nargin < 1 | isempty(a)
55        w = mapping(mfilename,{n,type});
56        w = setname(w,name);
57        return
58end
59vs = scalem(a,'variance');
60b = a*vs;
61switch 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')
76end
77vp = fsellpc([],1,type,param);
78w = polyc(b,vp,n,1);
79w = vs*w;
80name = [type '-LP'];
81w = setname(w,name);
82return
Note: See TracBrowser for help on using the repository browser.