Mercurial > hg > camir-aes2014
comparison core/magnatagatune/sim_from_comparison_naive.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 [sim, dissim, confidence] = sim_from_comparison_naive(comparison, comparison_ids, symmetrical) | |
2 % | |
3 % [sim, dissim, confidence] = sim_from_comparison_naive(comparison) | |
4 % | |
5 % derives symmetric, absolute similarity measurements | |
6 % from relative magnatagatune comparisons | |
7 % naive implementation for first tests of the ITML algorithm | |
8 % | |
9 | |
10 % reindex comparison for more simple evaluation | |
11 % makro_prepare_comparison | |
12 | |
13 % --- | |
14 % analyse the number of comparisons for each pair of songs | |
15 % --- | |
16 [num_compares] = get_comparison_stats(comparison, comparison_ids); | |
17 | |
18 % --- | |
19 % in comparison, the outlying piece is highlighted. | |
20 % thus, we naively consider that | |
21 % a. both of the remaining pieces are more similar to each other. | |
22 % b. the outlier is dissimilar to both of the other pieces | |
23 % --- | |
24 [outsort, outidx] = sort(comparison(:,4:6),2,'ascend'); | |
25 | |
26 % --- | |
27 % similarity of the two non-outliers a, b | |
28 % they are similar if both of them have scores way smaller | |
29 % than the outlier c: | |
30 % score (a,b) = 1 - (max(a,b)/c) | |
31 % | |
32 % dissimilarity: clip b is considered more different to clip c than | |
33 % a, as clip a seems to share some properties with both songs | |
34 % dissim(b,c) = 0.5 + b/(2c) | |
35 % --- | |
36 | |
37 sim = sparse(numel(comparison_ids),numel(comparison_ids)); | |
38 dissim = sparse(numel(comparison_ids),numel(comparison_ids)); | |
39 for i = 1:size(comparison,1) | |
40 | |
41 % get the outlier votes | |
42 simpair = comparison(i,outidx(i,1:2)); | |
43 c = comparison(i,outidx(i,3)); | |
44 | |
45 % we want a triangular similarity matrix | |
46 [simpair, simidx] = sort(simpair); | |
47 outsort(i,1:2) = outsort(i,simidx); | |
48 | |
49 % --- | |
50 % save the distance between the second biggest vote and the max vote. | |
51 % NOTE: we bias the vote by dividing through the number of total | |
52 % comparisons for the particular pair of clips | |
53 % --- | |
54 sim(simpair(1), simpair(2)) = sim(simpair(1), simpair(2)) + ... | |
55 (1 - outsort(i,2) / outsort(i,3)) * (1 / num_compares(simpair(1),simpair(2))); | |
56 | |
57 dissim(simpair(1:2), c) = 0.5 + (outsort(i,1:2) ./ (2 * outsort(i,3))); | |
58 end | |
59 | |
60 % --- | |
61 % mirror to make matrix symmetrical | |
62 % --- | |
63 if nargin == 3 && symmetrical | |
64 sim = sim + sim'; | |
65 dissim = dissim + dissim'; | |
66 end | |
67 | |
68 % --- | |
69 % TODO: use number of votes and std or similar to | |
70 % rate the confidence for each similarity mesurement | |
71 % --- | |
72 confidence = []; | |
73 |