Mercurial > hg > camir-aes2014
comparison core/magnatagatune/genre_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 out = genre_stats(tagged, names, freqs, childof) | |
2 % out = genre_stats(names, freqs, childof) | |
3 % | |
4 % calculates statistics for genre distributions | |
5 % | |
6 % | |
7 | |
8 % get overall genre frequency and sort accordingly | |
9 allapp = sum(freqs,2); | |
10 allapp = allapp/max(allapp); | |
11 | |
12 [null, idx] = sort(allapp,'descend'); | |
13 | |
14 % get root potential | |
15 rootpot = 1 - sum(childof,2); | |
16 | |
17 figure; | |
18 bar(1:numel(names),[allapp(idx) rootpot(idx)]) | |
19 set(gca,'XTick',1:numel(names)); | |
20 set(gca,'XTickLabel',names(idx)); | |
21 legend('#appearances','root genre possibility'); | |
22 title 'genre statistics sorted by frequency of appearances' | |
23 | |
24 % --- | |
25 % determine genres that include x% of the whole dataset | |
26 % --- | |
27 pctl = 0.98; % 80 percent included | |
28 | |
29 % --- | |
30 % re-sort by appearance and root potential. | |
31 % using the multiplication, we can filter out subgenres | |
32 % --- | |
33 [null, idxrt] = sort(rootpot.*allapp,'descend'); | |
34 | |
35 % iteratively add 'best' genre according to root potential | |
36 gotclips = []; | |
37 numclips = []; | |
38 num_included = 0; | |
39 i = 1; | |
40 while i <= numel(names) && num_included < pctl * length(tagged) | |
41 | |
42 % count clips found for this genre | |
43 fprintf('%s \n', char(names{idxrt(i)})); | |
44 newclips = setdiff(find(tagged(:,idxrt(i)))', gotclips); | |
45 | |
46 gotclips = [gotclips newclips]; | |
47 numclips(i) = numel(newclips); | |
48 | |
49 num_included = num_included + numclips(i); | |
50 i = i + 1; | |
51 end | |
52 | |
53 figure; | |
54 pie(numclips(numclips > 0) / length(tagged)); | |
55 legend(names{idxrt(numclips > 0)}); | |
56 | |
57 out = []; | |
58 |