Mercurial > hg > mirex-meta-analysis
comparison do_correlation_analyses.m @ 6:e2337cd691b1 tip
Finishing writing the matlab code to replicate all observations made in the article.
Added the article to the repository.
Renamed the two main scripts ("1-get_mirex_estimates.rb" and "2-generate_smith2013_ismir.m") to not have dashes (since this was annoying within Matlab)
Added new Michael Jackson figure.
author | Jordan Smith <jordan.smith@eecs.qmul.ac.uk> |
---|---|
date | Wed, 05 Mar 2014 01:02:26 +0000 |
parents | 92b5a46bc67b |
children |
comparison
equal
deleted
inserted
replaced
5:8d896eec680e | 6:e2337cd691b1 |
---|---|
45 | 45 |
46 % Now we are done making figures. The following sequences of commands generate output to validate some of the statements in the article. | 46 % Now we are done making figures. The following sequences of commands generate output to validate some of the statements in the article. |
47 | 47 |
48 | 48 |
49 | 49 |
50 % Section 3.1: "Does this indicate that the algorithms are better at boundary precision than recall? In fact, the opposite is the case: average bp6 bp.5 was simply consistently worse for most algorithms." | 50 fprintf('Section 3.1: ''Does this indicate that the algorithms are better at boundary precision than recall? In fact, the opposite is the case: average bp6 bp.5 was simply consistently worse for most algorithms.''\n') |
51 % For all algos: | 51 fprintf('For all algos:\n') |
52 mean(median(megadatacube(:,indexing_info(2).manual_set([3 4 7 8]),:),3),1) | 52 mean(median(megadatacube(:,indexing_info(2).manual_set([3 4 7 8]),:),3),1) |
53 % For each algo: | 53 fprintf('For each algo:\n') |
54 mean(megadatacube(:,indexing_info(2).manual_set([3 4 7 8]),:),1) | 54 mean(megadatacube(:,indexing_info(2).manual_set([3 4 7 8]),:),1) |
55 % Recall (the second pair of values) surpass precision (the first pair of values) for most of the algorithm runs. There are two exceptions: algorithms 4 (R a little less than P) and 5 (P much better than R). | 55 fprintf('Recall (the second pair of values) surpass precision (the first pair of values) for most of the algorithm runs. There are two exceptions: algorithms 4 (R a little less than P) and 5 (P much better than R).\n') |
56 | |
57 fprintf('Are the trends qualitatively similar across datasets? (Section 3.1: ''...the findings of this section were consistent across the datasets, albeit with some variation in significance levels.'')\n') | |
58 fprintf('Fig 1a\n') | |
59 fprintf('All the datasets:\n') | |
60 figure(1),[asig pval a a_] = do_correlation(megadatacube, lab_measures, indexing_info(1).manual_set, [1:9], -1, 0, 1, -1, indexing_info(1).labels, 1); | |
61 fprintf('Isophonics et al.:\n') | |
62 figure(2),[asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,1), indexing_info(1).manual_set, [1:9], -1, 0, 1, -1, indexing_info(1).labels, 1); | |
63 fprintf('RWC (AIST):\n') | |
64 figure(3),[asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,3), indexing_info(1).manual_set, [1:9], -1, 0, 1, -1, indexing_info(1).labels, 1); | |
65 fprintf('SALAMI:\n') | |
66 figure(4),[asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,4), indexing_info(1).manual_set, [1:9], -1, 0, 1, -1, indexing_info(1).labels, 1); | |
67 fprintf('Fig 1b\n') | |
68 fprintf('All the datasets:\n') | |
69 figure(1), [asig pval a a_] = do_correlation(megadatacube, lab_measures, indexing_info(1).manual_set, [1:9], -1, 1, 0, -1, indexing_info(1).labels, 1); | |
70 fprintf('Isophonics et al.:\n') | |
71 figure(2), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,1), indexing_info(1).manual_set, [1:9], -1, 1, 0, -1, indexing_info(1).labels, 1); | |
72 fprintf('RWC (AIST):\n') | |
73 figure(3), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,3), indexing_info(1).manual_set, [1:9], -1, 1, 0, -1, indexing_info(1).labels, 1); | |
74 fprintf('SALAMI:\n') | |
75 figure(4), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,4), indexing_info(1).manual_set, [1:9], -1, 1, 0, -1, indexing_info(1).labels, 1); | |
76 fprintf('Fig 2a\n') | |
77 fprintf('All the datasets:\n') | |
78 figure(1), [asig pval a a_] = do_correlation(megadatacube, seg_measures, indexing_info(2).manual_set, [1:9], -1, 0, 1, -1, indexing_info(2).labels, 1); | |
79 fprintf('Isophonics et al.:\n') | |
80 figure(2), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,1), indexing_info(2).manual_set, [1:9], -1, 0, 1, -1, indexing_info(2).labels, 1); | |
81 fprintf('RWC (INRIA):\n') | |
82 figure(3), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,2), indexing_info(2).manual_set, [1:9], -1, 0, 1, -1, indexing_info(2).labels, 1); | |
83 fprintf('RWC (AIST):\n') | |
84 figure(4), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,3), indexing_info(2).manual_set, [1:9], -1, 0, 1, -1, indexing_info(2).labels, 1); | |
85 fprintf('SALAMI:\n') | |
86 figure(5), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,4), indexing_info(2).manual_set, [1:9], -1, 0, 1, -1, indexing_info(2).labels, 1); | |
87 fprintf('Fig 2b\n') | |
88 fprintf('All the datasets:\n') | |
89 figure(1), [asig pval a a_] = do_correlation(megadatacube, seg_measures, indexing_info(2).manual_set, [1:9], -1, 1, 0, -1, indexing_info(2).labels, 1); | |
90 fprintf('Isophonics et al.:\n') | |
91 figure(2), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,1), indexing_info(2).manual_set, [1:9], -1, 1, 0, -1, indexing_info(2).labels, 1); | |
92 fprintf('RWC (INRIA):\n') | |
93 figure(3), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,2), indexing_info(2).manual_set, [1:9], -1, 1, 0, -1, indexing_info(2).labels, 1); | |
94 fprintf('RWC (AIST):\n') | |
95 figure(4), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,3), indexing_info(2).manual_set, [1:9], -1, 1, 0, -1, indexing_info(2).labels, 1); | |
96 fprintf('SALAMI:\n') | |
97 figure(5), [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,4), indexing_info(2).manual_set, [1:9], -1, 1, 0, -1, indexing_info(2).labels, 1); | |
56 | 98 |
57 | 99 |
58 % Are the trends qualitatively similar across datasets? (Section 3.1: "...the findings of this section were consistent across the datasets, albeit with some variation in significance levels.") | 100 fprintf('Section 3.2: ''While the middle half of the values of nsa [number of segments in annotation] ranges from 7 to 13 segments, the middle values for nse [number of segments for estimated description] for most algorithms range from 11 to 20 segments. The two exceptions are MHRAF and OYZS [algorithms 4 and 5], for which both msle and nse match the distributions seen in the annotations.''\n') |
59 % % % Fig 1a | |
60 % All the datasets: | |
61 figure,[asig pval a a_] = do_correlation(megadatacube, lab_measures, indexing_info(1).manual_set, [1:9], -1, 0, 1, -1, indexing_info(1).labels, 1); | |
62 % Isophonics et al.: | |
63 figure,[asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,1), indexing_info(1).manual_set, [1:9], -1, 0, 1, -1, indexing_info(1).labels, 1); | |
64 % RWC (AIST): | |
65 figure,[asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,3), indexing_info(1).manual_set, [1:9], -1, 0, 1, -1, indexing_info(1).labels, 1); | |
66 % SALAMI: | |
67 figure,[asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,4), indexing_info(1).manual_set, [1:9], -1, 0, 1, -1, indexing_info(1).labels, 1); | |
68 % % % Fig 1b | |
69 % All the datasets: | |
70 figure, [asig pval a a_] = do_correlation(megadatacube, lab_measures, indexing_info(1).manual_set, [1:9], -1, 1, 0, -1, indexing_info(1).labels, 1); | |
71 % Isophonics et al.: | |
72 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,1), indexing_info(1).manual_set, [1:9], -1, 1, 0, -1, indexing_info(1).labels, 1); | |
73 % RWC (AIST): | |
74 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,3), indexing_info(1).manual_set, [1:9], -1, 1, 0, -1, indexing_info(1).labels, 1); | |
75 % SALAMI: | |
76 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,4), indexing_info(1).manual_set, [1:9], -1, 1, 0, -1, indexing_info(1).labels, 1); | |
77 % % % Fig 2a | |
78 % All the datasets: | |
79 figure, [asig pval a a_] = do_correlation(megadatacube, seg_measures, indexing_info(2).manual_set, [1:9], -1, 0, 1, -1, indexing_info(2).labels, 1); | |
80 % Isophonics et al.: | |
81 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,1), indexing_info(2).manual_set, [1:9], -1, 0, 1, -1, indexing_info(2).labels, 1); | |
82 % RWC (INRIA): | |
83 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,2), indexing_info(2).manual_set, [1:9], -1, 0, 1, -1, indexing_info(2).labels, 1); | |
84 % RWC (AIST): | |
85 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,3), indexing_info(2).manual_set, [1:9], -1, 0, 1, -1, indexing_info(2).labels, 1); | |
86 % SALAMI: | |
87 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,4), indexing_info(2).manual_set, [1:9], -1, 0, 1, -1, indexing_info(2).labels, 1); | |
88 % % % Fig 2b | |
89 % All the datasets: | |
90 figure, [asig pval a a_] = do_correlation(megadatacube, seg_measures, indexing_info(2).manual_set, [1:9], -1, 1, 0, -1, indexing_info(2).labels, 1); | |
91 % Isophonics et al.: | |
92 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,1), indexing_info(2).manual_set, [1:9], -1, 1, 0, -1, indexing_info(2).labels, 1); | |
93 % RWC (INRIA): | |
94 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,2), indexing_info(2).manual_set, [1:9], -1, 1, 0, -1, indexing_info(2).labels, 1); | |
95 % RWC (AIST): | |
96 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,3), indexing_info(2).manual_set, [1:9], -1, 1, 0, -1, indexing_info(2).labels, 1); | |
97 % SALAMI: | |
98 figure, [asig pval a a_] = do_correlation(megadatacube, ismember(mirex_dset_origin,4), indexing_info(2).manual_set, [1:9], -1, 1, 0, -1, indexing_info(2).labels, 1); | |
99 | 101 |
100 | 102 fprintf('Index 17 gives the number of segments in the annotation; 21 gives the number of segments in the estimated description of the algorithm.\n') |
101 % Section 3.2: "While the middle half of the values of nsa [number of segments in annotation] ranges from 7 and 13 segments, the middle values for nse [number of segments for estimated description] for most algorithms range from 11 to 20 segments. The two exceptions are MHRAF and OYZS [algorithms 4 and 5], for which both msle and nse match the distributions seen in the annotations." | 103 fprintf('Boxplot shows general trend of overestimating number of segments.\n') |
102 | |
103 % Index 17 gives the number of segments in the annotation; 21 gives the number of segments in the estimated description of the algorithm. | |
104 % Boxplot shows general trend of overestimating number of segments. | |
105 H = boxplot(megadatacube(:,[17 21],:)) | 104 H = boxplot(megadatacube(:,[17 21],:)) |
106 % Take the middle half of the data for annotated and estimated segments. Look at the range. | 105 fprintf('Take the middle half of the data for annotated and estimated segments. Look at the range.\n') |
107 | 106 |
108 tmp = sort(megadatacube(:,17,:)); | 107 tmp = sort(megadatacube(:,17,:)); |
109 tmp = sort(tmp(:)); | 108 tmp = sort(tmp(:)); |
110 tmp(round(length(tmp)/4)), tmp(3*round(length(tmp)/4)) | 109 tmp(round(length(tmp)/4)), tmp(3*round(length(tmp)/4)) |
111 % The middle half of the annotated descriptions have 7 to 13 segments. | 110 fprintf('The middle half of the annotated descriptions have 7 to 13 segments.\n') |
112 | 111 |
113 tmp2 = sort(megadatacube(:,21,:)); | 112 tmp2 = sort(megadatacube(:,21,:)); |
114 [tmp2(round(length(tmp2)/4),:,:), tmp2(round(length(tmp2)*3/4),:,:)] | 113 [tmp2(round(length(tmp2)/4),:,:), tmp2(round(length(tmp2)*3/4),:,:)] |
115 % Setting aside algorithms 4 and 5, the others all have middle ranges of roughly 11 to 24. | 114 fprintf('Setting aside algorithms 4 and 5, the others all have middle ranges of roughly 11 to 24.\n') |
116 tmp2 = sort(tmp2(:)); | 115 tmp2 = sort(tmp2(:)); |
117 tmp2(round(length(tmp2)/4)), tmp2(3*round(length(tmp2)/4)) | 116 tmp2(round(length(tmp2)/4)), tmp2(3*round(length(tmp2)/4)) |
118 % Averaging the other algorithms together, the middle range is exactly 10 to 20. | 117 fprintf('Averaging the other algorithms together, the middle range is exactly 10 to 20.\n') |
119 | 118 |
120 | 119 |
120 % Of all the songs that have been pinpointed in one dataset or another, sort them by pw_f, and look at the best and worst performing songs. | |
121 % PW_F is the 3rd element of the megadatacube. | |
122 % Take the mean PW_F across all the algorithms. | |
123 tmp = mean(megadatacube(:,3,:),3); | |
124 % Now we will rank by song, and look at the origin of the top and bottom PW_Fs. | |
121 | 125 |
122 | 126 find(mirex_dset_origin==1) |
123 | |
124 do blah | |
125 % % % % % % % % % % % % The rest of this is still under construction, so I have inserted an error in the previous line to halt the script. | |
126 | |
127 % % % % % % % % % % % ENd OF REAL WORK AREA % % % % % % % % % % % % % | |
128 | |
129 | |
130 | 127 |
131 % Look at best 10 and worst 10 songs in each dataset, according to PW_F metric. | 128 % Look at best 10 and worst 10 songs in each dataset, according to PW_F metric. |
132 % Average results across algorithms for this one. | 129 % Average results across algorithms for this one. |
130 | |
131 % First, we will not let the fact that many versions of some algorithms exist skew the results. | |
132 % So, we replace algo no. 3 with the mean of algos 1, 2, 3 and 9 (KSP1, KSP2, KSP3, and SP1) | |
133 tmp_datacube = datacube; | |
134 tmp_datacube(:,:,3) = mean(tmp_datacube(:,:,[1:3,9]),3); | |
135 % And replace algo 7 with algos 7 and 8 (SMGA1 and SMGA2) | |
136 tmp_datacube(:,:,7) = mean(tmp_datacube(:,:,7:8),3); | |
137 % Now there are just 5 unique algorithms: | |
133 unique_algorithms = [3 4 5 6 7]; | 138 unique_algorithms = [3 4 5 6 7]; |
134 tmp = datacube; | 139 % Let TMP be the average performance across the algorithms of the main set of metrics (those in DATACUBE) for all the songs in the first dataset, i.e., Isophonics and Beatles. |
135 tmp(:,:,3) = mean(tmp(:,:,[1:3,9]),3); | 140 tmp_dc_results = mean(tmp_datacube(mirex_dset_origin==1,:,unique_algorithms),3); |
136 tmp(:,:,7) = mean(tmp(:,:,7:8),3); | 141 % Sort the algorithms in decreasing order of the third metric (which is PW_F) |
137 tmp = mean(tmp(mirex_dset_origin==1,:,unique_algorithms),3); | 142 [tmp_dc_results order] = sortrows(tmp_dc_results,-3); |
138 [tmp1 order] = sortrows(tmp,-3); | 143 % order1 = lab_measures(order); |
139 order1 = lab_measures(order); | 144 pub_songids = mir2pub(order); % These are the matched IDs of the songs |
140 pub_songids = mir2pub(order); | 145 values = tmp_dc_results((pub_songids>0),3); % We want the match to be >0 --- i.e., we only care about positively identified songs |
141 values = tmp1((pub_songids>0),3); | 146 % Now scoop up all the filenames of the songs. |
142 filenames = {}; | 147 filenames = {}; |
143 for i=1:length(pub_songids), | 148 for i=1:length(pub_songids), |
144 if pub_songids(i)>0, | 149 if pub_songids(i)>0, |
145 filenames{end+1} = public_truth(pub_songids(i)).file; | 150 filenames{end+1} = public_truth(pub_songids(i)).file; |
146 end | 151 end |
147 end | 152 end |
148 | 153 |
149 mirid = pub2mir(336); | |
150 make_structure_image(mirid, miranns, MD, mirdset, X, MR) | |
151 saveas(gcf,'./plots/MJ_dont_care.jpg') | |
152 make_structure_image(121, miranns, MD, mirdset, X, MR) | |
153 saveas(gcf,'./plots/play_the_game.jpg') | |
154 | 154 |
155 % Plot difficulty by album: | 155 fprintf('Section 4: ''The piece with the highest median pwf is The Beatles'' ''''Her Majesty''''...''\n') |
156 fprintf('''The next-best Beatles song, ''''I Will'''', is an instance where both the states and sequences hypotheses apply well...''\n') | |
157 fprintf('(Note: due to a change in the script, the song ''''Her Majesty'''' is no longer identified properly, and hence does not show up here in the results. Instead, the top two songs are ''''I Will'''' and ''''Penny Lane''''.') | |
158 fprintf('%f, %s\n',tmp_dc_results(1,3),filenames{1}) | |
159 fprintf('%f, %s\n',tmp_dc_results(2,3),filenames{2}) | |
156 | 160 |
161 fprintf('Section 4: ''At the bottom is Jackson''s ''''They Don''t Care About Us''''.''\n') | |
162 fprintf('%f, %s\n',tmp_dc_results(end,3),filenames{end}) | |
157 | 163 |
158 genres = {}; | 164 fprintf('Section 4: ''Conspicuously, 17 of the easiest 20 songs (again, with respect to pwf) are Beatles tunes, while only 2 of the most difficult 20 songs are---the rest being Michael Jackson, Queen and Carole King songs.''\n') |
159 subgenres = {}; | 165 fprintf('The easiest 20 songs:\n') |
160 issalami = zeros(length(filenames),1); | 166 for i=1:20, |
161 for i=1:length(filenames), | 167 fprintf('%s\n',filenames{i}) |
162 file = filenames{i}; | 168 end |
163 if strfind(file,'SALAMI_data'), | 169 fprintf('The hardest 20 songs:\n') |
164 issalami(i)=1; | 170 for i=1:20, |
165 salami_id = file(79:85); | 171 fprintf('%s\n',filenames{end+1-i}) |
166 salami_id = salami_id(1:strfind(salami_id,'/')-1); | 172 end |
167 salami_row = find(aaux.metadata{1}==str2num(salami_id)); | 173 |
168 genres{end+1} = cell2mat(aaux.metadata{15}(salami_row)); | 174 values = tmp_dc_results(:,3); |
169 subgenres{end+1} = cell2mat(aaux.metadata{16}(salami_row)); | 175 values = values(pub_songids>0); |
176 groups = public_dset_origin(pub_songids(pub_songids>0),:); | |
177 artists = zeros(size(values)); | |
178 for i=1:length(values), | |
179 if groups(i,1)~=2, | |
180 artists(i) = 4; % Beatles | |
181 else | |
182 artists(i) = groups(i,2); | |
170 end | 183 end |
171 end | 184 end |
172 gs = grp2idx(genres); | 185 % Kruskal-Wallis test: |
173 subgs = grp2idx(subgenres); | 186 fprintf('Section 5: ''Taking the median pwf across the algorithms and comparing this value for the 274 annotations identified as one of these four artists, a Kruskal-Wallis test confirms that the groups differ.''\n') |
174 boxplot(values(find(issalami)),transpose(genres)) | 187 [P, anovatab, stats] = kruskalwallis(values, artists); |
175 axis([0.5 5.5 0 1]) | 188 fprintf('Section 5: ''A multiple comparison test reveals that pwf is significantly greater for the Beatles group than the three others.''\n') |
176 saveas(gcf,'salami_breakdown.png') | 189 multcompare(stats) |
177 boxplot(values(find(issalami)),transpose(subgenres),'colors',cmap(round(gs*63/6),:),'orientation','horizontal') | 190 fprintf('Note: in the version created for the article, the Zweick songs were not identified, and these sentences refer to 4 artists when in fact these comparisons refer to 5 artists.\n') |
178 | 191 |
179 [tmp1 tmp2] = hist(subgs,max(subgs)-1); | 192 % Create composite structure diagram for Michael Jackon song: |
180 tmp1 = find(tmp1>5); % do these subgenres only | 193 make_structure_image(pub2mir(pub_songids(end)),mirex_truth, mirex_output, mirex_results, mirex_dset_origin) |
181 tmp1 = ismember(subgs,tmp1); | |
182 tmp2 = find(issalami); | |
183 boxplot(values(tmp2(tmp1)),transpose(subgenres(tmp1)),'colors',cmap(round(gs(tmp1)*63/6),:),'orientation','horizontal') | |
184 | |
185 | |
186 | |
187 | |
188 | |
189 % Look at scatter plots so that we can qualitatively attribute the correlations to things (e.g., low-precision variance). | |
190 tmpcube = mean(datacube,3); | |
191 for i=1:4, | |
192 for j=i+1:5, | |
193 subplot(5,5,i+(j-1)*5) | |
194 scatter(tmpcube(:,i),tmpcube(:,j),'x') | |
195 end | |
196 end | |
197 | |
198 | |
199 | |
200 | |
201 | |
202 | |
203 | |
204 | |
205 | |
206 | |
207 | |
208 | |
209 | |
210 | |
211 clf,imagesc(a.*(abs(a)>.7)) | |
212 set(gca,'XTickLabel',[],'XTick',(1:50)-.5) | |
213 set(gca,'YTickLabel',s,'YTick',(1:50)) | |
214 t = text((1:50)-.5,51*ones(1,50),s); | |
215 set(t,'HorizontalAlignment','right','VerticalAlignment','top', 'Rotation',90); | |
216 hold on | |
217 for i=1:9, | |
218 plot([0 50],[i*5 i*5],'w') | |
219 plot([i*5 i*5],[0 50],'w') | |
220 end | |
221 | |
222 % a = corr([datacube(1:300,:,1) newcube(1:300,:,1) newmetriccube(1:300,:,1)]); | |
223 | |
224 a = corr([datacube(lab_measures,:,1) newcube(lab_measures,:,1) newmetriccube(lab_measures,:,1)]); | |
225 b = corr([datacube(seg_measures,:,1) newcube(seg_measures,:,1) newmetriccube(seg_measures,:,1)]); | |
226 | |
227 % Look at label measures only in this case. | |
228 imagesc(sortrows(transpose(sortrows((abs(a)>0.7))))) | |
229 [t1 t2] = (sortrows(transpose(sortrows((abs(a)>0.7))))); | |
230 | |
231 | |
232 b = zeros(size(a)); | |
233 for j=[3,4,5,6,7,9], | |
234 b = b+corr([datacube(:,:,j) newcube(:,:,j) newmetriccube(:,:,j)]); | |
235 end | |
236 b=b/6; | |
237 | |
238 | |
239 % Look at correlations among all figures, but pay attention to pvalues too. | |
240 % Only plot those less than 0.05, with conservative bonferroni correction. | |
241 megadatacube_l = [datacube(lab_measures,:,:) newcube(lab_measures,:,:) newmetriccube(lab_measures,:,:)]; | |
242 megadatacube_s = [datacube(seg_measures,:,:) newcube(seg_measures,:,:) newmetriccube(seg_measures,:,:)]; | |
243 % megadatacube_l = median(megadatacube_l(:,use_these_labels,:),3); | |
244 % megadatacube_s = median(megadatacube_s(:,use_these_segs,:),3); | |
245 | |
246 | |
247 | |
248 megadatacube_all = median(megadatacube_l(:,[use_these_labels use_these_segs use_these_extras],:),3); | |
249 megadatacube_all(:,16:17) = 1 - megadatacube_all(:,16:17); | |
250 [al pval] = corr(megadatacube_all); | |
251 m = length(al)*(length(al)-1)/2; | |
252 imagesc(al.*((pval*m)<0.05)) | |
253 al_ = al.*((pval*m)<0.05); | |
254 al_ = tril(al_ .* (abs(al_)>.5)); | |
255 imagesc(al_) | |
256 for i=1:length(al_), | |
257 for j=1:length(al_), | |
258 if (al_(i,j)~=0) & (i~=j), | |
259 text(j-.35,i,num2str(al_(i,j),2)) | |
260 end | |
261 end | |
262 end | |
263 % [bl pvbl] = corr(megadatacube_all,'type','Kendall'); | |
264 m = length(bl)*(length(bl)-1)/2; | |
265 imagesc(bl.*((pvbl*m)<0.05)) | |
266 bl_ = bl.*((pvbl*m)<0.05); | |
267 bl_ = tril(bl_) % .* (abs(bl_)>.0)); | |
268 imagesc(bl_) | |
269 for i=1:length(bl_), | |
270 for j=1:length(bl_), | |
271 if (bl_(i,j)~=0) & (i~=j), | |
272 text(j-.35,i,num2str(bl_(i,j),2)) | |
273 end | |
274 end | |
275 end | |
276 | |
277 % Or, we could do this: Take all the computed Kendall taus, i.e., the non-diagonal elements of bl. | |
278 taus = bl(find(bl<1)); | |
279 taus = taus-mean(taus); | |
280 taus = taus/std(taus); | |
281 P = normcdf(-abs(taus)); | |
282 ind = find(P<=0.05); | |
283 taus = bl(find(bl<1)); | |
284 taus(ind) | |
285 | |
286 c = colormap; | |
287 c(32,:) = [1 1 1]; | |
288 c(31,:) = [1 1 1]; | |
289 c = min(1,c*1.6); | |
290 colormap(c) | |
291 set(gca,'XTickLabel',[],'XTick',(1:length(al_))-.4) | |
292 set(gca,'YTickLabel',s([use_these_labels use_these_segs use_these_extras]),'YTick',(1:length(al_))) | |
293 t = text((1:length(al_))-.3,(length(al_)+1)*ones(1,length(al_))+.3,s([use_these_labels use_these_segs use_these_extras])); | |
294 set(t,'HorizontalAlignment','right','VerticalAlignment','top', 'Rotation',90); | |
295 axis([0 31 0 31]) | |
296 saveas(gcf,'./plots/all_correlations.jpg') | |
297 | |
298 s = {'S_o','S_u','pw_f','pw_p','pw_r','rand','bf1','bp1','br1','bf6','bp6','br6','mt2c','mc2t','ds','len','nsa','nla','msla','nspla','nse','nle','msle','nsple','ob','ol','pw_f_x','pw_p_x','pw_r_x','K','asp','acp','I_AE_x','H_EA_x','H_AE_x','S_o_x','S_u_x','rand','mt2c_x','mc2t_x','m','f','d_ae_x','d_ea_x','b_f1_x','b_p1_x','b_r1_x','b_f6_x','b_p6_x','b_r6_x'}; | |
299 s_type = [1,2,3,1,2,3,6,4,5,6,4,5,4,5, 7,7,7,7,7,7,7,7,7,7,7,7,3,1,2,3,2,1,3,1,2,1,2, 3,4,5,5,4,7,7,3,1,2,3,1,2]; | |
300 megadatacube_s(:,40:41,:) = 1 - megadatacube_s(:,40:41,:); | |
301 megadatacube_s(:,51,:) = 2*megadatacube_s(:,38,:).*megadatacube_s(:,39,:)./(megadatacube_s(:,38,:)+megadatacube_s(:,39,:)); | |
302 % This makes a new 51st metric which is a combination of m and f. | |
303 s_type(51) = 6; | |
304 s{51} = 'mf'; | |
305 | |
306 | |
307 % [a pval] = corr(median([datacube(lab_measures,:,1) newcube(lab_measures,:,1) newmetriccube(lab_measures,:,1)],3)); | |
308 [a pval] = corr(mean(megadatacube_l,3)); | |
309 m = length(a)*(length(a)-1)/2; | |
310 imagesc(a.*((pval*m)<0.05)) | |
311 a_ = a.*((pval*m)<0.05); | |
312 c = colormap; | |
313 c(32,:) = [1 1 1]; | |
314 colormap(c) | |
315 | |
316 % I want to make a claim about song length correlating to the algorithms or not. Let us make sure it is valid across all algorithms, and is not just applicable to the median: | |
317 for j=1:9, | |
318 a = corr([datacube(lab_measures,:,j) newcube(lab_measures,:,j) newmetriccube(lab_measures,:,j)]); | |
319 a(16,[17 19 21 23]) | |
320 end | |
321 | |
322 % BoxPlot of the number of segments in each algorithm output | |
323 boxplot(reshape(newcube(:,7,:),[length(newcube),9,1])) | |
324 | |
325 | |
326 | |
327 | |
328 | |
329 | |
330 | |
331 | |
332 | |
333 | |
334 | |
335 | |
336 | |
337 | |
338 | |
339 | |
340 | |
341 | |
342 | |
343 | |
344 | |
345 | |
346 | |
347 | |
348 | |
349 | |
350 | |
351 | |
352 | |
353 | |
354 | |
355 | |
356 | |
357 | |
358 | |
359 | |
360 | |
361 | |
362 | |
363 | |
364 | |
365 | |
366 | |
367 | |
368 | |
369 | |
370 | |
371 | |
372 % Now again, we will want to run the correlation study by taking medians across algorithms (do the metrics rank the songs the same way?) and medians across songs (do the metrics rank the algorithms the same way?). | |
373 | |
374 % Take the label metrics only, take median across songs: | |
375 % tmpcube = median(megadatacube_l(:,sind_manual1,:),1); | |
376 % tmpcube = transpose(reshape(tmpcube,size(tmpcube,2),size(tmpcube,3))); | |
377 % [a pval] = corr(tmpcube,'type','Kendall'); | |
378 % m = length(a)*(length(a)-1)/2; | |
379 % a.*((pval*m)<0.05); % This is the matrix of values that are significant. | |
380 % Alternatively, we can plot all the metrics, treat them as random normal variables, and select only those that stand out. | |
381 | |
382 | |
383 | |
384 % [asig pval a] = do_correlation(megadatacube, songs, metrics, algos, algo_groups, merge_algos (1 = do, 0 = do not), merge_songs, merge_dsets, metric_labels) | |
385 [asig pval a] = do_correlation(megadatacube, lab_measures, sind_manual1, [1:9], -1, 0, 1, -1, s_manual1) | |
386 [asig pval a] = do_correlation(megadatacube, lab_measures, [use_these_labels use_these_segs], [1:9], -1, 0, 1, -1, s([use_these_labels use_these_segs])) | |
387 | |
388 [asig pval a] = do_correlation(megadatacube, lab_measures, [1:12], [1:9], -1, 0, 1, -1, s(1:12)) | |
389 | |
390 | |
391 [a pval] = corr(megadatacube_l(:,:,1),'type','Kendall'); | |
392 | |
393 | |
394 | |
395 % Take the label metrics only, take median across algorithms: | |
396 tmpcube = median(megadatacube_l(:,sind_manual1,:),3); | |
397 [a pval] = corr(tmpcube); %,'type','Kendall'); | |
398 m = length(a)*(length(a)-1)/2; | |
399 a.*((pval*m)<0.05); % This is the matrix of values that are significant. | |
400 % However, with so many data points (over 1400) it is very easy to be significant... | |
401 | |
402 | |
403 | |
404 | |
405 imagesc(a.*((pval*m)<0.05)) | |
406 al_ = al.*((pval*m)<0.05); | |
407 al_ = tril(al_ .* (abs(al_)>.5)); | |
408 imagesc(al_) | |
409 for i=1:length(al_), | |
410 for j=1:length(al_), | |
411 if (al_(i,j)~=0) & (i~=j), | |
412 text(j-.35,i,num2str(al_(i,j),2)) | |
413 end | |
414 end | |
415 end | |
416 | |
417 | |
418 clf,imagesc(a.*(abs(a)>.7)) | |
419 set(gca,'XTickLabel',[],'XTick',(1:50)-.5) | |
420 set(gca,'YTickLabel',s,'YTick',(1:50)) | |
421 t = text((1:50)-.5,51*ones(1,50),s); | |
422 set(t,'HorizontalAlignment','right','VerticalAlignment','top', 'Rotation',90); | |
423 hold on | |
424 for i=1:9, | |
425 plot([0 50],[i*5 i*5],'w') | |
426 plot([i*5 i*5],[0 50],'w') | |
427 end | |
428 | |
429 % a = corr([datacube(1:300,:,1) newcube(1:300,:,1) extracube(1:300,:,1)]); | |
430 | |
431 a = corr([datacube(lab_measures,:,1) newcube(lab_measures,:,1) extracube(lab_measures,:,1)]); | |
432 b = corr([datacube(seg_measures,:,1) newcube(seg_measures,:,1) extracube(seg_measures,:,1)]); | |
433 | |
434 % Look at label measures only in this case. | |
435 imagesc(sortrows(transpose(sortrows((abs(a)>0.7))))) | |
436 [t1 t2] = (sortrows(transpose(sortrows((abs(a)>0.7))))); | |
437 | |
438 | |
439 b = zeros(size(a)); | |
440 for j=[3,4,5,6,7,9], | |
441 b = b+corr([datacube(:,:,j) newcube(:,:,j) extracube(:,:,j)]); | |
442 end | |
443 b=b/6; | |
444 | |
445 | |
446 % Look at correlations among all figures, but pay attention to pvalues too. | |
447 % Only plot those less than 0.05, with conservative bonferroni correction. | |
448 megadatacube_l = [datacube(lab_measures,:,:) newcube(lab_measures,:,:) extracube(lab_measures,:,:)]; | |
449 megadatacube_s = [datacube(seg_measures,:,:) newcube(seg_measures,:,:) extracube(seg_measures,:,:)]; | |
450 % megadatacube_l = median(megadatacube_l(:,use_these_labels,:),3); | |
451 % megadatacube_s = median(megadatacube_s(:,use_these_segs,:),3); | |
452 | |
453 | |
454 | |
455 megadatacube_all = median(megadatacube_l(:,[use_these_labels use_these_segs use_these_extras],:),3); | |
456 megadatacube_all(:,16:17) = 1 - megadatacube_all(:,16:17); | |
457 [al pval] = corr(megadatacube_all); | |
458 m = length(al)*(length(al)-1)/2; | |
459 imagesc(al.*((pval*m)<0.05)) | |
460 al_ = al.*((pval*m)<0.05); | |
461 al_ = tril(al_ .* (abs(al_)>.5)); | |
462 imagesc(al_) | |
463 for i=1:length(al_), | |
464 for j=1:length(al_), | |
465 if (al_(i,j)~=0) & (i~=j), | |
466 text(j-.35,i,num2str(al_(i,j),2)) | |
467 end | |
468 end | |
469 end | |
470 % [bl pvbl] = corr(megadatacube_all,'type','Kendall'); | |
471 m = length(bl)*(length(bl)-1)/2; | |
472 imagesc(bl.*((pvbl*m)<0.05)) | |
473 bl_ = bl.*((pvbl*m)<0.05); | |
474 bl_ = tril(bl_) % .* (abs(bl_)>.0)); | |
475 imagesc(bl_) | |
476 for i=1:length(bl_), | |
477 for j=1:length(bl_), | |
478 if (bl_(i,j)~=0) & (i~=j), | |
479 text(j-.35,i,num2str(bl_(i,j),2)) | |
480 end | |
481 end | |
482 end | |
483 | |
484 % Or, we could do this: Take all the computed Kendall taus, i.e., the non-diagonal elements of bl. | |
485 taus = bl(find(bl<1)); | |
486 taus = taus-mean(taus); | |
487 taus = taus/std(taus); | |
488 P = normcdf(-abs(taus)); | |
489 ind = find(P<=0.05); | |
490 taus = bl(find(bl<1)); | |
491 taus(ind) | |
492 | |
493 c = colormap; | |
494 c(32,:) = [1 1 1]; | |
495 c(31,:) = [1 1 1]; | |
496 c = min(1,c*1.6); | |
497 colormap(c) | |
498 set(gca,'XTickLabel',[],'XTick',(1:length(al_))-.4) | |
499 set(gca,'YTickLabel',s([use_these_labels use_these_segs use_these_extras]),'YTick',(1:length(al_))) | |
500 t = text((1:length(al_))-.3,(length(al_)+1)*ones(1,length(al_))+.3,s([use_these_labels use_these_segs use_these_extras])); | |
501 set(t,'HorizontalAlignment','right','VerticalAlignment','top', 'Rotation',90); | |
502 axis([0 31 0 31]) | |
503 saveas(gcf,'./plots/all_correlations.jpg') | |
504 | |
505 s = {'S_o','S_u','pw_f','pw_p','pw_r','rand','bf1','bp1','br1','bf6','bp6','br6','mt2c','mc2t','ds','len','nsa','nla','msla','nspla','nse','nle','msle','nsple','ob','ol','pw_f_x','pw_p_x','pw_r_x','K','asp','acp','I_AE_x','H_EA_x','H_AE_x','S_o_x','S_u_x','rand','mt2c_x','mc2t_x','m','f','d_ae_x','d_ea_x','b_f1_x','b_p1_x','b_r1_x','b_f6_x','b_p6_x','b_r6_x'}; | |
506 s_type = [1,2,3,1,2,3,6,4,5,6,4,5,4,5, 7,7,7,7,7,7,7,7,7,7,7,7,3,1,2,3,2,1,3,1,2,1,2, 3,4,5,5,4,7,7,3,1,2,3,1,2]; | |
507 megadatacube_s(:,38:39,:) = 1 - megadatacube_s(:,38:39,:); | |
508 megadatacube_s(:,51,:) = 2*megadatacube_s(:,38,:).*megadatacube_s(:,39,:)./(megadatacube_s(:,38,:)+megadatacube_s(:,39,:)); | |
509 % This makes a new 51st metric which is a combination of m and f. | |
510 s_type(51) = 6; | |
511 s{51} = 'mf'; | |
512 | |
513 | |
514 % [a pval] = corr(median([datacube(lab_measures,:,1) newcube(lab_measures,:,1) extracube(lab_measures,:,1)],3)); | |
515 [a pval] = corr(mean(megadatacube_l,3)); | |
516 m = length(a)*(length(a)-1)/2; | |
517 imagesc(a.*((pval*m)<0.05)) | |
518 a_ = a.*((pval*m)<0.05); | |
519 c = colormap; | |
520 c(32,:) = [1 1 1]; | |
521 colormap(c) | |
522 | |
523 % I want to make a claim about song length correlating to the algorithms or not. Let us make sure it is valid across all algorithms, and is not just applicable to the median: | |
524 for j=1:9, | |
525 a = corr([datacube(lab_measures,:,j) newcube(lab_measures,:,j) extracube(lab_measures,:,j)]); | |
526 a(16,[17 19 21 23]) | |
527 end | |
528 | |
529 % BoxPlot of the number of segments in each algorithm output | |
530 boxplot(reshape(newcube(:,7,:),[length(newcube),9,1])) | |
531 | |
532 % Look at best 10 and worst 10 songs in each dataset, according to PW_F metric. | |
533 % Average results across algorithms for this one. | |
534 unique_algorithms = [3 4 5 6 7]; | |
535 tmp = datacube; | |
536 tmp(:,:,3) = mean(tmp(:,:,[1:3,9]),3); | |
537 tmp(:,:,7) = mean(tmp(:,:,7:8),3); | |
538 tmp = mean(tmp(lab_measures,:,unique_algorithms),3); | |
539 [tmp1 order] = sortrows(tmp,-3); | |
540 order1 = lab_measures(order); | |
541 pub_songids = X.mir2pub(order1); | |
542 values = tmp1((pub_songids>0),3); | |
543 filenames = {}; | |
544 for i=1:length(pub_songids), | |
545 if pub_songids(i)>0, | |
546 filenames{end+1} = public_truth(pub_songids(i)).file; | |
547 end | |
548 end | |
549 | |
550 mirid = pub2mir(336); | |
551 make_structure_image(mirid, mirex_truth, mirex_output, mirex_dset_origin, X, mirex_results) | |
552 saveas(gcf,'./plots/MJ_dont_care.jpg') | 194 saveas(gcf,'./plots/MJ_dont_care.jpg') |
553 make_structure_image(121, mirex_truth, mirex_output, mirex_dset_origin, X, mirex_results) | |
554 saveas(gcf,'./plots/play_the_game.jpg') | |
555 | |
556 % Plot difficulty by album: | |
557 | |
558 | |
559 genres = {}; | |
560 subgenres = {}; | |
561 issalami = zeros(length(filenames),1); | |
562 for i=1:length(filenames), | |
563 file = filenames{i}; | |
564 if strfind(file,'SALAMI_data'), | |
565 issalami(i)=1; | |
566 salami_id = file(79:85); | |
567 salami_id = salami_id(1:strfind(salami_id,'/')-1); | |
568 salami_row = find(aaux.metadata{1}==str2num(salami_id)); | |
569 genres{end+1} = cell2mat(aaux.metadata{15}(salami_row)); | |
570 subgenres{end+1} = cell2mat(aaux.metadata{16}(salami_row)); | |
571 end | |
572 end | |
573 gs = grp2idx(genres); | |
574 subgs = grp2idx(subgenres); | |
575 boxplot(values(find(issalami)),transpose(genres)) | |
576 axis([0.5 5.5 0 1]) | |
577 saveas(gcf,'salami_breakdown.png') | |
578 boxplot(values(find(issalami)),transpose(subgenres),'colors',cmap(round(gs*63/6),:),'orientation','horizontal') | |
579 | |
580 [tmp1 tmp2] = hist(subgs,max(subgs)-1); | |
581 tmp1 = find(tmp1>5); % do these subgenres only | |
582 tmp1 = ismember(subgs,tmp1); | |
583 tmp2 = find(issalami); | |
584 boxplot(values(tmp2(tmp1)),transpose(subgenres(tmp1)),'colors',cmap(round(gs(tmp1)*63/6),:),'orientation','horizontal') |