码迷,mamicode.com
首页 > 其他好文 > 详细

How to decide on the correct number of clusters?

时间:2015-06-25 00:03:48      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:


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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!