Rev | Line | |
---|
[5] | 1 | %RBSVC Automaric radial basis SVM
|
---|
| 2 | %
|
---|
| 3 | % W = RBSVC(A,FID)
|
---|
| 4 |
|
---|
| 5 | function w = rbsvc(a,fid)
|
---|
| 6 |
|
---|
| 7 | if nargin < 2, fid = []; end
|
---|
| 8 | if nargin < 1 | isempty(a)
|
---|
| 9 | w = mapping(mfilename,fid);
|
---|
| 10 | return
|
---|
| 11 | end
|
---|
| 12 |
|
---|
| 13 | nu = max(testk(a,1),0.05);
|
---|
| 14 |
|
---|
| 15 | d = sqrt(+distm(a));
|
---|
| 16 | sigmax = min(max(d)); % max: smallest furthest neighboe distance
|
---|
| 17 |
|
---|
| 18 | d = d + 1e100*eye(size(a,1));
|
---|
| 19 | sigmin = max(min(d)); % min: largest nearest neighbor distance
|
---|
| 20 |
|
---|
| 21 | q = (1/sigmin - 1/sigmax)/9;
|
---|
| 22 | sig = [1/sigmax:q:1/sigmin];
|
---|
| 23 | sig = ones(1,length(sig))./[1/sigmax:q:1/sigmin];
|
---|
| 24 | if isempty(sig)
|
---|
| 25 | sigopt = sigmin;
|
---|
| 26 | else
|
---|
| 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')
|
---|
| 41 | end
|
---|
| 42 | w = svc_nu(a,'r',sigopt,nu);
|
---|
| 43 |
|
---|
Note: See
TracBrowser
for help on using the repository browser.