Mercurial > hg > camir-aes2014
comparison core/magnatagatune/ranking_from_comparison_trivial.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] = ranking_from_comparison_trivial(comparison, comparison_ids) | |
2 % returns a ranking for each of the compared songs | |
3 % | |
4 % r(idx,1) = all indexes which are similar to clip idx | |
5 % r(idx,2) = all indexes which are dissimilar to clip idx | |
6 % | |
7 % if onlyvalid is set to true, only the transitive hull of | |
8 % clips having sim and dissim values will be output | |
9 | |
10 % --- | |
11 % in comparison, the outlying piece is highlighted. | |
12 % thus, we naively consider that | |
13 % a. both of the remaining pieces are more similar to each other. | |
14 % b. the outlier is dissimilar to both of the other pieces | |
15 % --- | |
16 | |
17 [outsort, outidx] = sort(comparison(:,4:6),2,'ascend'); | |
18 | |
19 r = cell(numel(comparison_ids), 2); | |
20 s = zeros(numel(comparison_ids), 2); % score for rankings | |
21 for i = 1:size(comparison, 1) | |
22 | |
23 % get the three relevant comparison ids | |
24 | |
25 pos = comparison(i, outidx(i,1:3)); | |
26 vals = outsort(i,:); | |
27 | |
28 % --- | |
29 % each of the three clips will be evaluated based on its position | |
30 % the last clip is the potential outlyier | |
31 % --- | |
32 | |
33 % --- | |
34 % usual case: two small values and a last outlie | |
35 % --- | |
36 if vals(2) ~= vals(3) | |
37 | |
38 | |
39 % --- | |
40 % first (most common) clip: | |
41 % the second clip is more similar than the third one | |
42 % --- | |
43 r{pos(1),1} = cat(1, r{pos(1),1}, pos(2)); % similar | |
44 r{pos(1),2} = cat(1, r{pos(1),2}, pos(3)); % dissimilar | |
45 % else | |
46 % | |
47 % % ok, both seem more dissimilar to clip 1 | |
48 % r{pos(1),2} = cat(1, r{pos(1),1}, pos(2)); % both dissimilar | |
49 % r{pos(1),2} = cat (1, r{pos(1),2}, pos(3)); % dissimilar | |
50 end | |
51 | |
52 if vals(3) ~= vals(1) | |
53 % --- | |
54 % the second clip is more similar to the first than | |
55 % the third | |
56 % --- | |
57 r{pos(2),1} = cat(1, r{pos(2),1}, pos(1)); | |
58 r{pos(2),2} = cat(1, r{pos(2),2}, pos(3)); | |
59 | |
60 % --- | |
61 % the third clip is not similar to any of the former | |
62 % NOTE: we avoid this information as it possibly leads | |
63 % to some contradictionary statements | |
64 % --- | |
65 r{pos(3),2} = cat(1, r{pos(3),2}, pos(1)); | |
66 r{pos(3),2} = cat(1, r{pos(3),2}, pos(2)); | |
67 end | |
68 | |
69 | |
70 end | |
71 | |
72 % --- | |
73 % we cleanup r and | |
74 % run basic checks on emptiness and paradox assumptions | |
75 % --- | |
76 valididx = zeros(size(r,1), 1); | |
77 for i = 1:size(r, 1) | |
78 | |
79 % make unique | |
80 r{i,1} = unique(r{i,1}); | |
81 r{i,2} = unique(r{i,2}); | |
82 | |
83 % check | |
84 valididx(i) = ~isempty(r{i,1}) && ~isempty(r{i,2}) && ... | |
85 isempty(intersect(r{i,1}, r{i,2})); | |
86 end | |
87 | |
88 valididx = logical(valididx); | |
89 clip_ids = 1:numel(comparison_ids); | |
90 |