Line | |
---|
1 | %GENREPI Generate indices for representation, learning and testing sets |
---|
2 | % |
---|
3 | % [R,L,T] = GENREPI(D,K,M) |
---|
4 | % |
---|
5 | % INPUT |
---|
6 | % D NxN dissimilarity dataset |
---|
7 | % K Number of objects for the representation set R |
---|
8 | % M Number of objects for the learning set L; M >= K |
---|
9 | % |
---|
10 | % OUTPUT |
---|
11 | % R Indices for the representation set |
---|
12 | % L Indices for the learning set |
---|
13 | % T Indices for the test set |
---|
14 | % |
---|
15 | % DESCRIPTION |
---|
16 | % Random selection of M indices for a representation set R and N indices for |
---|
17 | % a learning set L. L contains R (M <= N). Indices of the remaining objects |
---|
18 | % are stored in T. |
---|
19 | % |
---|
20 | % DEFAULT |
---|
21 | % M = N |
---|
22 | % |
---|
23 | |
---|
24 | % Copyright: Robert Duin, r.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 | function [R,L,T] = genrepi(D,k,m) |
---|
31 | if nargin < 3, |
---|
32 | m = k; |
---|
33 | end |
---|
34 | |
---|
35 | [nr,nc,c] = getsize(D); |
---|
36 | if nr ~= nc, |
---|
37 | error('Dissimilarity matrix should be square.'); |
---|
38 | end |
---|
39 | |
---|
40 | if m > nr | k > nr |
---|
41 | error('K and M should not exceed the total number of objects in D.') |
---|
42 | end |
---|
43 | |
---|
44 | if k > m |
---|
45 | error('K should not be larger than M.'); |
---|
46 | end |
---|
47 | |
---|
48 | R = []; |
---|
49 | L = []; |
---|
50 | T = []; |
---|
51 | C = classsizes(D); |
---|
52 | |
---|
53 | for j = 1:c |
---|
54 | J = findnlab(D,j); |
---|
55 | LL = randperm(C(j)); |
---|
56 | LL = LL(1:m); |
---|
57 | RR = LL(1:k); |
---|
58 | R = [R;J(RR)]; |
---|
59 | L = [L;J(LL)]; |
---|
60 | end |
---|
61 | T = setdiff([1:nr]',L); |
---|
62 | |
---|
Note: See
TracBrowser
for help on using the repository browser.