标签:
Determining the number of clusters/segments in hierarchical clustering/segmentation algorithms
由于unique函数在这里找矩阵不同元素的时不能有效得到,所以自己编了小程序实现。
Matlab codeL:
clear load fisheriris figure(1) Z = linkage(meas,‘ward‘,‘euclidean‘);%Create a hierarchical binary cluster tree using linkage [Hr,Tr]=dendrogram(Z); %generates a dendrogram plot of the hierarchical binary cluster tree val0=eval(vpa(Z(:,3),5)); t=1; n(1)=0; val=val0(1); f(1)=val; for i=1:length(val0) if val0(i)==val n(t)=n(t)+1; continue else t=t+1; val=val0(i); n(t)=1; f(t)=val; continue end end figure(2) fsum=cumsum(n); plot(length(val0)-fsum, f, ‘o-‘,‘LineWidth‘, 2) xlabel(‘Number of Clusters‘) ylabel(‘Merge Distance‘) title(‘A sample evalution graph‘)
How to decide on the correct number of clusters?
标签:
原文地址:http://www.cnblogs.com/huadongw/p/4598888.html