source: distools/pe_libsvc.m @ 10

Last change on this file since 10 was 10, checked in by bduin, 14 years ago
File size: 1.6 KB
RevLine 
[10]1%PE_LIBSVC LIBSVC for PE spaces
2%
3%    W = PE_LIBSVC(A,C)
4
5% INPUT
6%   A         Pseudo-Euclidean Dataset
7%   C       Trade_off parameter in the support vector classifier.
8%           Default C = 1;
9
10% OUTPUT
11%   W       Mapping: Support Vector Classifier
12%   J       Object idences of support objects. Can be also obtained as W{4}
13%
14% DESCRIPTION 
15% Computation of the linear LIBSVC classifier for the Pseudo-Euclidean
16% dataset A.  Note that testsets should be defined in the same PE space
17% as A.
18%
19% Warning: class prior probabilities in A are neglected.
20%
21% EXAMPLE
22% trainset = gendatm;
23% testset = gendatm;
24% Dtrain = trainset*proxm(trainset,'m',1);
25% Dtest  = testset*proxm(testset,'m',1);
26% w = pe_em(Dtrain);
27% Xtrain = Dtrain*w;
28% Xtest = Dtest*w;
29% v = pe_libsvc(Xtrain);
30% Xtest*v*testc
31%
32% SEE ALSO
33% MAPPINGS, DATASETS, KNNC, PE_EM
34
35% R.P.W. Duin, r.p.w.duin@prtools.org
36% Faculty EWI, Delft University of Technology
37% P.O. Box 5031, 2600 GA Delft, The Netherlands
38
39function w = pe_libsvc(a,c)
40
41  if nargin < 2, c = 1; end
42
43        if nargin == 0 | isempty(a)
44                w = mapping(mfilename,'untrained',{c});
45                w = setname(w,'PE LIBSVC');
46               
47        elseif ~ismapping(c) % training
48               
49                if ~ispe_dataset(a)
50                        prwarning(1,'Dataset is Euclidean')
51                        w = libsvc(a,[],c);
52                else
53                        ktrain = pe_kernelm(a,a)
54                        v = libsvc(ktrain,0);
55                        w = mapping(mfilename,'trained',{v,a},getlablist(a),size(a,2),getsize(a,3));
56                end
57               
58        else % execution, testset is in a, trained mapping is in c
59               
60                w = getdata(c,1);
61                trainset = getdata(c,2);
62                ktest = pe_kernelm(a,trainset);
63                w = ktest*w;
64   
65  end
66               
67return
Note: See TracBrowser for help on using the repository browser.