source: prextra/lpsvc.m @ 154

Last change on this file since 154 was 5, checked in by bduin, 14 years ago
File size: 1.9 KB
Line 
1%LPSVC Sparse linear programming classifier according to Mangasarian
2%
3%   [W,E] = LPSVC(A,N,PoARAM)
4%   W     = A*LPSVC([],N,PARAM)
5%
6% INPUT
7%   A     Dataset
8%   N     N-fold cross-validationocedure
9%         N = 1: no cross-validation
10%         N = size A: leave-one-out pr
11%   PARAM Linear programming option
12%         -1 Easy
13%         0  Hard (default)
14%         Otherwise: nu
15%
16% OUTPUT
17%   W     Classifier
18%   E     Internal error estimate
19%
20% DESCRIPTION
21% This routine calls LPSVM by Fung and Mangasarian. If you use it, please
22% refer to the below paper.
23%
24% REFERENCE
25% G.M. Fung and O.L. Mangasarian, A Feature Selection Newton Method for
26% Support Vector Machine Classification, Computational Optimization and
27% Aplications, vol. 28, 2004, 185-202.
28%
29% SEE ALSO
30% MAPPINGS, DATASETS, LINPROGC
31
32% Elzbieta Pekalska, Robert P.W. Duin, e.pekalska@ewi.tudelft.nl
33% Faculty of Electrical Engineering, Mathematics and Computer Science,
34% Delft University of Technology, The Netherlands.
35
36function [w,J] = lpsvm(a,n,param)
37if nargin < 3, param =0; end
38if nargin < 2, n =  1; end
39name = 'LPSVC';
40if nargin < 1 | isempty(a)
41        w = mapping(mfilename,{n,param});
42        w = setname(w,name);
43        return
44end
45islabtype(a,'crisp');
46isvaldset(a,1,2); % at least 1 object per class, 2 classes
47[m,k,c] = getsize(a);
48nlab = getnlab(a);     
49        % The SVC is basically a 2-class classifier. More classes are
50        % handled by mclassc.
51if c == 2   % two-class classifier
52        y = 3 - 2*nlab;
53        [v,v0,ea,et] = lpsvm(+a,y,n,param);
54        J = find(v~=0);
55        if isempty(J)
56                prwarning(1,'No features found. Fisher classifier is trained.')
57                wf = featsel(k,1:k);
58                w = wf*fisherc(a);
59        else
60                wf = featsel(k,J);
61                flab = getfeatlab(a);
62                w = wf*affine(v(J),-v0,flab(J,:),getlablist(a),length(J),c);
63                w = cnormc(w,a);
64        end
65       
66else
67       
68        [w,J] = mclassc(a,mapping(mfilename,{n,param}));
69               
70end
71
72
73
74
75
76
77
Note: See TracBrowser for help on using the repository browser.