source: distools/drsscc.m @ 126

Last change on this file since 126 was 79, checked in by bduin, 11 years ago
File size: 1.4 KB
Line 
1%DRSSCC Dissimilarity-based Random Subspace Combining Classifier
2%
3%       W = DRSSCC(D,V,N,M,CRULE)
4%
5% INPUT
6%   D           NxK Dissimilarity dataset
7%       V               Base untrained classifier
8%       N               Desired number of representation objects per class
9%       M               Number of base classifiers to be generated
10%       CRULE Combining rule
11%
12% OUTPUT
13%   W           Trained classifier
14%
15% DESCRIPTION
16%
17% DEFAULT
18%       V               = NMSC
19%       N               = 2
20%       M               = 11
21%       CRULE = VOTEC   
22%
23
24% Copyright: R.P.W. Duin, duin@ieee.org and
25% Elzbieta Pekalska, ela.pekalska@googlemail.com
26% Faculty EWI, Delft University of Technology and
27% School of Computer Science, University of Manchester
28
29
30
31function W = drsscc(D,v,N,M,crule)
32
33if nargin < 5,
34        crule = votec;
35end
36if nargin < 4,
37        M = 11;
38end
39if nargin < 3,
40        N = 2;
41end
42if nargin < 2,
43        v = nmsc;
44end
45if nargin < 1 | isempty(D)
46  W = prmapping('DRSSCC',{v,N,M,crule});
47  return
48end
49
50
51nlab   = getnlab(D);
52[m,k]  = size(D);
53[flab,flist] = renumlab(getfeat(D));
54c = size(flist,1);
55
56if length(N) == 1,
57        N = N*ones(c,1);
58elseif length(N) ~= c, 
59        error('N should be either a scalar or a vector with the length C.');
60else
61        ;       
62end     
63
64W = [];
65for j = 1:M
66  R = genreps(flab,N);
67  W = [W D*(cmapm(k,R)*v)];
68end
69W = traincc(D,W,crule);
70
71
72
73       
74function R = genreps(nlab,N)
75% Generate n objects per class
76c = max(nlab);
77R = [];
78for j = 1:c
79  J = find(nlab==j);
80  L = randperm(length(J))';
81  R = [R; J(L(1:N(j)))];
82end
Note: See TracBrowser for help on using the repository browser.