Mercurial > hg > camir-aes2014
comparison core/magnatagatune/get_comparison_stats.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 [num_compares] = get_comparison_stats() | |
2 % [num_compares] = get_comparison_stats() | |
3 % | |
4 % - retrieves number of comparisons for each pair of data clips | |
5 % - extracts genre associations and statistics | |
6 | |
7 global db_magnaclips; | |
8 global comparison; | |
9 global comparison_ids; | |
10 | |
11 num_compares = sparse(numel(comparison_ids), numel(comparison_ids)); | |
12 | |
13 for i = 1:size(comparison,1) | |
14 abc = sort(comparison(i,1:3)); | |
15 a = abc(1); | |
16 b = abc(2); | |
17 c = abc(3); | |
18 num_compares(a,b) = num_compares(a,b) +1; | |
19 num_compares(b,c) = num_compares(b,c) +1; | |
20 num_compares(a,c) = num_compares(a,c) +1; | |
21 end | |
22 | |
23 % --- | |
24 % check for repeated pairs | |
25 % --- | |
26 % [i,j] = ind2sub(size(num_compares), find(num_compares > 1)) | |
27 % num = 300; | |
28 % a = find((comparison(:,1) == i(num) | comparison(:,2) == i(num) | comparison(:,3) == i(num))...) | |
29 % & (comparison(:,1) == j(num) | comparison(:,2) == j(num) | comparison(:,3) == j(num))) | |
30 % | |
31 % comparison(a,:) | |
32 | |
33 | |
34 % ------------------------------------------------------------ | |
35 % compare genre frequency | |
36 % --- | |
37 clips = MTTClip(comparison_ids); | |
38 | |
39 % comparison genres | |
40 [genres, scores, gid] = clips.genres(); | |
41 | |
42 % all genres | |
43 [genres2, scores2, gid2] = db_magnaclips.genredb.stats; | |
44 | |
45 % --- | |
46 % plot top genres | |
47 % --- | |
48 | |
49 figure; | |
50 bar(scores(1:20)) | |
51 set(gca, 'XTick',1:20,'XTickLabel',genres(1:20)) | |
52 | |
53 figure; | |
54 subplot(2,1,1) | |
55 bar(scores(1:10) / max(scores)) | |
56 set(gca, 'XTickLabel',genres) | |
57 title 'comparison subset' | |
58 | |
59 subplot(2,1,2) | |
60 bar(scores2(1:10) / max(scores2)) | |
61 set(gca, 'XTickLabel',genres2,'FontSize', 8) | |
62 title 'Full MTT data set' | |
63 | |
64 % --- | |
65 % evaluate differences in distribution for all genres | |
66 % shown are changes in relation to the whole database(genres2) | |
67 % ( relative to the summed tags ) | |
68 % --- | |
69 genrediff = zeros(numel(genres2),1); | |
70 for i=1:numel(genres2) | |
71 | |
72 % mgen = strcellfind(genres, genres2(i)); | |
73 mgen = find(gid == gid2(i)); | |
74 | |
75 if ~isempty(mgen) | |
76 % genrediff(i,1) = scores(mgen)/sum(scores) - scores2(i)/sum(scores2); | |
77 genrediff(i,1) = 1 - ( (scores2(i)/sum(scores2)) / (scores(mgen)/sum(scores))); | |
78 | |
79 else | |
80 % genrediff(i) = inf; | |
81 error 'genre ids not consistent' | |
82 end | |
83 end | |
84 genrediff = genrediff * 100; | |
85 | |
86 % visualise difference | |
87 figure | |
88 bar(genrediff); | |
89 set(gca, 'XTick',1:44,'XTickLabel',genres2) | |
90 axis([0 45 -200 100]); | |
91 title 'relative loss for each genre considering comparison as an excerpt from MTT' | |
92 ylabel 'loss(%)' | |
93 | |
94 % --- | |
95 % get distinc genre music sets: | |
96 % we try the following sets of 'similar' genre tags | |
97 % --- | |
98 cgdb = db_magnaclips.genredb.subset(clips.id); | |
99 | |
100 cids = cgdb.owner({'Classical', 'Baroque'}, 'or'); | |
101 cgdb = cgdb.exclude(cids); | |
102 | |
103 eids = cgdb.owner({'Electronica', 'New Age', 'Ambient'}, 'or'); | |
104 cgdb = cgdb.exclude(eids); | |
105 | |
106 rids = cgdb.owner({'Rock', 'Alt Rock', 'Hard Rock', 'Metal'}, 'or'); | |
107 cgdb = cgdb.exclude(rids); | |
108 | |
109 % get reverse indexing for comparisons | |
110 rev_compid = sparse(comparison_ids, 1, 1:numel(comparison_ids)); | |
111 | |
112 % 8 triples entirely classical | |
113 cfit = get_comparison_linfits(comparison, rev_compid(cids)); | |
114 | |
115 % 43 triples entirely electronic | |
116 efit = get_comparison_linfits(comparison, rev_compid(eids)); | |
117 | |
118 % 6 triples entirely rock | |
119 rfit = get_comparison_linfits(comparison, rev_compid(rids)); | |
120 | |
121 cgdb.stats | |
122 | |
123 end | |
124 % this function returns for each comparison line | |
125 % the num. of appearance of given selection of clip ids | |
126 function out = get_comparison_linfits(comparison, goodset) | |
127 | |
128 out = zeros(1, size(comparison,1)); | |
129 % for each line | |
130 for i = 1:size(comparison,1) | |
131 | |
132 out(i) = numel(intersect(comparison(i,1:3), goodset')); | |
133 end | |
134 end | |
135 | |
136 |