source: distools/dismatsel.m @ 71

Last change on this file since 71 was 10, checked in by bduin, 14 years ago
File size: 1.3 KB
Line 
1%DISMATSEL Forward selection and combination of dissimilarity datasets
2%
3%               [D,L,E] = DISMATSEL(C)
4%
5% C is a cell array of labeled datasets being square dissimilarity
6% matrices. In a forward selection the best of them according to the
7% leave-one-out nearest neighbor error (NNE) are selected and summed.
8% L contains the ranked set of indices of selected matrices. E stores the
9% error and D is the sum of the best subset.
10%
11% SEE ALSO
12% DATASETS, NNE
13
14% Copyright: R.P.W. Duin, r.p.w.duin@prtools.org
15% Faculty EWI, Delft University of Technology
16% P.O. Box 5031, 2600 GA Delft, The Netherlands
17
18function [d_final,L,E] = dismatsel(c,nmax)
19
20if ~iscell(c) | ~isdataset(c{1})
21        error('Cell array of dissimilarity matrices expected')
22end
23
24n = length(c);
25if nargin < 2, nmax = n; end
26for j=1:n
27        c{j} = abs(c{j});
28        c{j} = setfeatlab(c{j},getlabels(c{j}));
29        c{j} = c{j}*disnorm(c{j});
30end
31L = zeros(1,nmax);
32J = [1:n];
33E = zeros(1,nmax);
34d = zeros(size(c{1}));
35emin_total = 1;
36for j=1:nmax
37        emin = 1;
38        for i=J
39                e = nne(c{i}+d);
40                if e < emin
41                        L(j) = i;
42                        emin = e;
43                end
44        end
45        d = c{L(j)}+d;
46        if nargin < 2 % do not allow multiple choices
47                J(J==L(j)) = [];
48        end
49        E(j) = emin;
50        if emin < emin_total
51                emin_total = emin;
52                d_final = d;
53        end
54end
55
56               
57
58
59
60
61
Note: See TracBrowser for help on using the repository browser.