source: prextra/rbsvc.m @ 5

Last change on this file since 5 was 5, checked in by bduin, 14 years ago
File size: 907 bytes
Line 
1%RBSVC Automaric radial basis SVM
2%
3%   W = RBSVC(A,FID)
4
5function w = rbsvc(a,fid)
6
7if nargin < 2, fid = []; end
8if nargin < 1 | isempty(a)
9        w = mapping(mfilename,fid);
10        return
11end
12
13nu = max(testk(a,1),0.05);
14
15d = sqrt(+distm(a));
16sigmax = min(max(d)); % max: smallest furthest neighboe distance
17
18d = d + 1e100*eye(size(a,1));
19sigmin = max(min(d)); % min: largest nearest neighbor distance
20
21q = (1/sigmin - 1/sigmax)/9;
22sig = [1/sigmax:q:1/sigmin];
23sig = ones(1,length(sig))./[1/sigmax:q:1/sigmin];
24if isempty(sig)
25        sigopt = sigmin;
26else
27        w = [];
28        errmin = inf;
29        sigopt = 0;
30        prprogress(fid,'     ')
31        for j=1:length(sig)
32                s = sprintf('\b\b\b\b\b%5.0f',j);
33                prprogress(fid,s);
34                err = crossval(a,svc_nu([],'r',sig(j),nu),10,1,fid);
35                if err < errmin
36                        errmin = err;
37                        sigopt = sig(j);
38                end
39        end
40        prprogress(fid,'\b\b\b\b\b')
41end
42w = svc_nu(a,'r',sigopt,nu);
43
Note: See TracBrowser for help on using the repository browser.