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 | |
---|
31 | function W = drsscc(D,v,N,M,crule) |
---|
32 | |
---|
33 | if nargin < 5, |
---|
34 | crule = votec; |
---|
35 | end |
---|
36 | if nargin < 4, |
---|
37 | M = 11; |
---|
38 | end |
---|
39 | if nargin < 3, |
---|
40 | N = 2; |
---|
41 | end |
---|
42 | if nargin < 2, |
---|
43 | v = nmsc; |
---|
44 | end |
---|
45 | if nargin < 1 | isempty(D) |
---|
46 | W = prmapping('DRSSCC',{v,N,M,crule}); |
---|
47 | return |
---|
48 | end |
---|
49 | |
---|
50 | |
---|
51 | nlab = getnlab(D); |
---|
52 | [m,k] = size(D); |
---|
53 | [flab,flist] = renumlab(getfeat(D)); |
---|
54 | c = size(flist,1); |
---|
55 | |
---|
56 | if length(N) == 1, |
---|
57 | N = N*ones(c,1); |
---|
58 | elseif length(N) ~= c, |
---|
59 | error('N should be either a scalar or a vector with the length C.'); |
---|
60 | else |
---|
61 | ; |
---|
62 | end |
---|
63 | |
---|
64 | W = []; |
---|
65 | for j = 1:M |
---|
66 | R = genreps(flab,N); |
---|
67 | W = [W D*(cmapm(k,R)*v)]; |
---|
68 | end |
---|
69 | W = traincc(D,W,crule); |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | function R = genreps(nlab,N) |
---|
75 | % Generate n objects per class |
---|
76 | c = max(nlab); |
---|
77 | R = []; |
---|
78 | for j = 1:c |
---|
79 | J = find(nlab==j); |
---|
80 | L = randperm(length(J))'; |
---|
81 | R = [R; J(L(1:N(j)))]; |
---|
82 | end |
---|