% % Written by: % -- % John L. Weatherwax 2005-08-14 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; drawnow; clc; clear; addpath( '../../Code/eda_data' ); addpath( '../../Code/eda_toolbox' ); addpath( '../Chapter1' ); % Example 8.4 [X,clabs] = load_iris(1,0,1); % Get the hierarchical clustering. Y = pdist(X); Z = linkage(Y,'complete'); dendrogram(Z); % Example 8.7 % Applies Ling's method to interpoint distance matrix. n = size(X,1); data = X; % Randomly reorder the data and view the % interpoint distance matrix as an image. data = data(randperm(n),:); Y = pdist(data); Ys = squareform(Y); imagesc(Ys); colormap(gray(256)) title('Interpoint Distance Matrix - Random Order') axis off % Now apply Ling's method. First need to % get a partition or clustering. Z = linkage(Y,'complete'); % Now get the ordering based on the % cluster scheme. T = cluster(Z,'maxclust',3); % Sort these, so points in the same cluster % are adjacent. [Ts,inds] = sort(T); % Sort the distance matrix using this and replot. figure imagesc(Ys(inds,inds)) title('Interpoint Distance Matrix - Cluster Order') colormap(gray(256)) axis off saveas( gcf, '../../WriteUp/Graphics/Chapter8/prob_8_7_co', 'epsc' );