% Example 6.6 % % This one shows how to do agglomerative model-based clustering. % % Written by: % -- % John L. Weatherwax 2009-03-24 % % 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' ); % Load up the data and put into a data matrix. load iris X = [setosa; versicolor; virginica]; % Do the agglomerative model-based clustering. % This function is included in the EDA Toolbox % and the MBC Toolbox. Z = agmbclust(X); % Construct a dendrogram. dendrogram(Z); title('Results for Iris Data - Agglomerative MBC') % We can apply the silhouette procedure for this % after we find a partition. Use 2/4 groups. cind = cluster(Z,2); figure; [S,H] = silhouette(X,cind); title('Silhouette Plot - Agglomerative MBC: 2 clusters') saveas( gcf, '../../WriteUp/Graphics/Chapter6/prob_6_9_iris_2_clusts', 'epsc' ); % after we find a partition. Use 2/4 groups. cind = cluster(Z,4); figure; [S,H] = silhouette(X,cind); title('Silhouette Plot - Agglomerative MBC: 4 clusters') saveas( gcf, '../../WriteUp/Graphics/Chapter6/prob_6_9_iris_4_clusts', 'epsc' ); % just to compare lets look at 3 groups: cind = cluster(Z,3); figure; [S,H] = silhouette(X,cind); title('Silhouette Plot - Agglomerative MBC: 3 clusters')