comparison core/magnatagatune/ranking_from_comparison_Stober_diffs.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 [r, valididx, clip_ids, P] = ranking_from_comparison_Stober_diffs(nDatasets, nRuns)
2
3 global globalvars;
4 global comparison;
5 global comparison_ids;
6
7 % ---
8 % get the standard test set
9 % NOTE: we will keep the r and valididx, and just use
10 % the rest of the data for determining the issing edges etc
11 % ---
12 load('comp_SimGraphMulti_SimDataDump', 'G', 'r', 'valididx', 'clip_ids');
13 nData = sum(valididx > 0);
14
15 % ---
16 % initialise the new partition
17 % ---
18 P = cvpartition_alltrain(nData, nDatasets * nRuns);
19
20
21 for i = 1:nDatasets
22
23 % ---
24 % create new Stober graph
25 % ---
26 Gstob = ClipSimGraphStober();
27 Gstob.random_all_constraints_graph;
28 Gdiff = G - ClipSimGraphMulti(Gstob.to_DiGraph());
29
30 % ---
31 % get missing entries in stober similarity
32 % ---
33 idx = find_graph_in_valid(r, comparison_ids(clip_ids),valididx, Gdiff);
34 lostData = sum(idx);
35 if lostData ~= Gdiff.num_edges
36 error ('Inconsistent Data: edges in gdiff could not be found');
37 end
38
39 % ---
40 % save entries in DataPartition (remove from valid sets)
41 % NOTE: this is manhual intervention into Class territory :(
42 % ---
43 for j = 1:nRuns
44 jd = j + (i-1) * nRuns;
45 P.mtraining{jd} = ones(P.N, 1) - idx(valididx)';
46 P.mtest{jd} = ones(P.N, 1) - idx(valididx)';
47 P.TrainSize(jd) = P.N - lostData;
48 P.TestSize(jd) = P.N - lostData;
49 end
50 end
51 end
52
53 % ---
54 % This finds all graphs edges in the ranking
55 % ---
56 function idx = find_graph_in_valid(r, clip_ids, valididx, G)
57
58 idx = zeros(1,size(r,1));
59 for i = find(valididx)
60
61 a = clip_ids(i);
62 b = clip_ids(r{i,1});
63 c = clip_ids(r{i,2});
64 if G.edge(a,b,c) > 0
65 idx(i) = 1;
66 end
67 end
68 end
69