Mercurial > hg > camir-aes2014
comparison core/magnatagatune/sim_from_comparison_UNfair_components.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function [partBinTrn, partBinTst, partBinNoTrn] = sim_from_comparison_UNfair_components(comparison, comparison_ids, k, trainpart, filename) | |
2 % | |
3 % FOR ISMIR 2012 | |
4 % | |
5 % creates a cross-validation partitioning of the | |
6 % similarity data in "multiG", NOT PRESERVING the | |
7 % connected components in it during partitioning | |
8 | |
9 % --- | |
10 % get the similarity multigraph and remove cycles | |
11 % --- | |
12 cprint(2, 'creating graph') | |
13 % Gm = ClipSimGraphMulti(comparison, comparison_ids); | |
14 % Gm.remove_cycles_length2; | |
15 cprint(2, 'loading Multigraph for Similarity Constraints') | |
16 load('comp_SimGraphMulti.mat', 'G'); | |
17 | |
18 | |
19 % get similarity data | |
20 [weights, a, b, c] = G.similarities(); | |
21 | |
22 % --- | |
23 % We randomise the constraint succession | |
24 % --- | |
25 datPermu = randperm(numel(a)); | |
26 a = a(datPermu); | |
27 b = b(datPermu); | |
28 c = c(datPermu); | |
29 weights = weights(datPermu); | |
30 | |
31 % --- | |
32 % NOTE: we try the easy route: partition the graphs | |
33 % and look at which constraints balance we end up with | |
34 % --- | |
35 P = cvpartition(numel(a), 'k', k); | |
36 | |
37 % --- | |
38 % here we export similarity test sets | |
39 % --- | |
40 cprint(2, 'export test similarity') | |
41 partBinTst = {}; | |
42 for i = 1:P.NumTestSets % test runs | |
43 | |
44 partBinTst{i} = [a(P.test(i))' b(P.test(i))' c(P.test(i))' weights(P.test(i))]; | |
45 end | |
46 | |
47 | |
48 % --- | |
49 % Note: This uses a "truly" increasing training set | |
50 % to do the partial training partition | |
51 % --- | |
52 cprint(2, 'export train similarity') | |
53 for m = 1:numel(trainpart) | |
54 | |
55 % save test indices | |
56 Ptrain(m) = cvpartition_trunctrain_incsubsets(P, trainpart(m)); | |
57 end | |
58 | |
59 % --- | |
60 % here we export similarity training sets | |
61 % --- | |
62 partBinTrn = {}; | |
63 for i = 1:P.NumTestSets % train runs | |
64 | |
65 for m = 1:numel(trainpart) % increasing training sets | |
66 | |
67 % get training indices | |
68 idxB = Ptrain(m).training(i); | |
69 | |
70 % save into cell | |
71 partBinTrn{i,m} = [a(idxB)' b(idxB)' c(idxB)' weights(idxB)]; | |
72 end | |
73 end | |
74 | |
75 partBinNoTrn = {}; | |
76 for i = 1:P.NumTestSets % train runs | |
77 | |
78 for m = 1:numel(trainpart) % increasing training sets | |
79 | |
80 % get training indices | |
81 idxB = ~Ptrain(m).training(i) & ~Ptrain(m).test(i); | |
82 | |
83 % save into cell | |
84 partBinNoTrn{i,m} = [a(idxB)' b(idxB)' c(idxB)' weights(idxB)]; | |
85 end | |
86 end | |
87 | |
88 if nargin == 5 | |
89 save(filename, 'partBinTrn', 'partBinTst', 'partBinNoTrn') | |
90 end | |
91 end |