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