% Macro used for preparing the blog post http://www.37steps.com/4536/eu-song-contest/ % PRTools version 5.1.1 has been used\ % % Bob Duin, 14 May 2014 % load the data prdownload('http://37steps.com/data/examples/eu_song_2014.mat'); load eu_song_2014 % extract labels: feature labels are the countries of the songs % object labels afre the voting countries flab = getfeatlab(x); olab = getlabels(x); % correct for naste underscore olab(olab=='_') = '-'; x = setlabels(x,olab); % rank objects by alphabetic label order [dummy,R] = sortrows(olab); x = x(R,:); olab = olab(R,:); % get rid of existing figures delfigs % correct for 0 points of native song for j=1:size(x,2) flabj = flab(j,:); n = findlabels(x,flabj); x(n,j) = 12; end x = x*normm; % normalize vectors to unit legth (L1) % compute Hellinger distances d = x*proxm(x,'g'); % PCA scatterplot figure; g = x*(pcam*mapex); scattern(g,0,[0 0 0]); marksize(1); text(+g(:,1),+g(:,2),olab,'HorizontalAlignment','center'); fontsize(16) % MDS scatterplot computed from dissimilarity representation figure; g = d*(sammonm*mapex); scattern(g,0,[0 0 0]); marksize(1); text(+g(:,1),+g(:,2),olab,'HorizontalAlignment','center'); fontsize(16) % manual rotation needed for alignment with pca % hierarchical clustering c = hclust(d,'c'); L = c(1,:); % object order % find 5 neighbors for every object neighbors = cell(size(d,1),6); for j=1:size(d,1) [dd,R] = sort(+d(j,:)); fprintf('