How to decide on the correct number of clusters?

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‘)

时间: 2024-10-12 15:12:43

How to decide on the correct number of clusters?的相关文章

Clustering by density peaks and distance

这次介绍的是Alex和Alessandro于2014年发表在的Science上的一篇关于聚类的文章[13],该文章的基本思想很简单,但是其聚类效果却兼具了谱聚类(Spectral Clustering)[11,14,15]和K-Means的特点,着实激起了我的极大的兴趣,该聚类算法主要是基于两个基本点: 聚类中心的密度高于其临近的样本点的密度 聚类中心与比其密度还高的聚类中心的距离相对较大 基于这个思想,聚类过程中的聚类中心数目可以很直观的选取,离群点也能被自动检测出来并排除在聚类分析外.无论每

ZOJ 3180 Number Game(数学啊 )

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3221 Gordon is recently reading about an interesting game. At the beginning of the game, there are three positive numbers written on a blackboard. In each round, you are asked to delete

Given the numbers 1 to 1000, what is the minimum number?

http://www.programmerinterview.com/index.php/puzzles/minimum-guesses-1-100/ Given the numbers 1 to 1000, what is the minimum number of guesses needed to find a specific number if you are given the hint ‘higher’ or ‘lower’ for each guess you make? Thi

Query runs slow via .NET

Slow in the Application, Fast in SSMS?Understanding Performance Mysteries An SQL text by Erland Sommarskog, SQL Server MVP. Last revision: 2013-08-30.This article is also available in Russian, translated by Dima Piliugin. Introduction When I read var

A brief CRC tutorial

https://www.kernel.org/doc/Documentation/crc32.txt A brief CRC tutorial. A CRC is a long-division remainder. You add the CRC to the message, and the whole thing ( message+CRC ) is a multiple of the given CRC polynomial. To check the CRC, you can eith

scala Futures and Promises

http://docs.scala-lang.org/overviews/core/futures.html Futures and Promises   By: Philipp Haller, Aleksandar Prokopec, Heather Miller, Viktor Klang, Roland Kuhn, and Vojin Jovanovic Introduction Futures provide a nice way to reason about performing m

Zend API:深入 PHP 内核

Introduction Those who know don't talk. Those who talk don't know. Sometimes, PHP "as is" simply isn't enough. Although these cases are rare for the average user, professional applications will soon lead PHP to the edge of its capabilities, in t

TCP 、UDP网络编程作业代写、代写C 语言 TCP程序 Network Programming using C

TCP .UDP网络编程作业代写.代写C 语言 TCP程序Network Programming using COverview? This homework is due by 11:59:59 PM on Thursday, April 26, 2018.? This homework will count as 8% of your final course grade.? This homework is to be completed individually. Do not shar

ACM-ICPC Asia Training League 暑假第一阶段第一场 ABF

A Choosing Ice Cream You are standing in the supermarket in front of the freezers. You have a very tough task ahead of you: you have to choose what type of ice cream you want for after dinner that evening. After a while, you give up: they are all awe