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