% % example epage ???104 % problem epage 130 % % Appy the Fowlkes-Mallows clustering index to the ornsay data set % % 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' ); %[X,midden,beachdune] = load_oronsay(0,0,0,0); [X,midden,beachdune] = load_oronsay(1,0,1,0); [X,midden,beachdune] = load_oronsay(1,0,1,1); [n,p] = size(X); truth_labels = midden; truth_type = 'midden'; fprintf(['the proptions of ', truth_type ,' labeling in each class\n']); tabulate( truth_labels ) y = pdist(X,'euclidean'); link_method = 'average'; z = linkage(y,link_method); %figure; dendrogram(z); %title( ['oronsay dendrogram with ',link_method,' linkage'] ); khat=3; %fprintf('khat = %10d\n',khat); c_agg_inds = cluster(z,'maxclust',khat); fprintf('agglomerative clustering proportions:\n'); tabulate( c_agg_inds ) % Get a k-means clustering using 3 clusters, and 5 replicates. % We also ask MATLAB to display the final results for each replicate. % kmus3 = kmeans(X,3,'replicates',5,'display','final'); fprintf('k-means result proportions:\n'); tabulate( kmus3 ); fm = fowlkes_mallows_index( c_agg_inds,truth_labels ); fprintf('fowlkes mallows index (agglomerative,truth) = %20.6f\n',fm); fm = fowlkes_mallows_index( kmus3,truth_labels ); fprintf('fowlkes mallows index (k-means,truth) = %20.6f\n',fm);