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?How to decide on the correct number of clusters?

相关文章:

  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-09-13
  • 2021-10-21
  • 2022-12-23
  • 2021-11-29
猜你喜欢
  • 2021-07-14
  • 2021-10-22
  • 2022-12-23
  • 2021-07-08
  • 2022-02-10
  • 2021-11-03
  • 2021-12-14
相关资源
相似解决方案