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?的更多相关文章

  1. 吴恩达机器学习笔记47-K均值算法的优化目标、随机初始化与聚类数量的选择(Optimization Objective & Random Initialization & Choosing the Number of Clusters of K-Means Algorithm)

    一.K均值算法的优化目标 K-均值最小化问题,是要最小化所有的数据点与其所关联的聚类中心点之间的距离之和,因此 K-均值的代价函数(又称畸变函数 Distortion function)为: 其中

  2. Clustering by density peaks and distance

    这次介绍的是Alex和Alessandro于2014年发表在的Science上的一篇关于聚类的文章[13],该文章的基本思想很简单,但是其聚类效果却兼具了谱聚类(Spectral Clustering ...

  3. Machine Learning|Andrew Ng|Coursera 吴恩达机器学习笔记

    Week1: Machine Learning: A computer program is said to learn from experience E with respect to some ...

  4. Using std::map with a custom class key

    From: https://www.walletfox.com/course/mapwithcustomclasskey.php If you have ever tried to use a cus ...

  5. A brief CRC tutorial

    https://www.kernel.org/doc/Documentation/crc32.txt A brief CRC tutorial. A CRC is a long-division re ...

  6. 近年Recsys论文

    2015年~2017年SIGIR,SIGKDD,ICML三大会议的Recsys论文: [转载请注明出处:https://www.cnblogs.com/shenxiaolin/p/8321722.ht ...

  7. Machine Learning|Andrew Ng|Coursera 吴恩达机器学习笔记(完结)

    Week 1: Machine Learning: A computer program is said to learn from experience E with respect to some ...

  8. Zend API:深入 PHP 内核

    Introduction Those who know don't talk. Those who talk don't know. Sometimes, PHP "as is" ...

  9. 【Machine Learning is Fun!】1.The world’s easiest introduction to Machine Learning

    Bigger update: The content of this article is now available as a full-length video course that walks ...

随机推荐

  1. javascript权威指南笔记--javascript语言核心(六)

    通过ECMAScript 3创建的属性都是可写的.可枚举的.可配置的. 在ECMAScript 5中,数据属性的4个特性分别是它的值.可写性.可枚举性.可配置性.存取器属性的特性是读取.写入.可枚举性 ...

  2. 微信公众平台开发详细步骤与java代码

    1.微信公众平台设置 首先在https://mp.weixin.qq.com/注册一个公众平台账号(服务号.订阅号.企业号的区别) 微信公众平台地址:https://mp.weixin.qq.com ...

  3. iOS - UINavigationController

    前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UINavigationController : UIViewController @available(iOS 2 ...

  4. sql for xml 嵌套

    找很久.原来差一个ELEMENTS 关键字. 想到哪里插入子节点.就直接写一条语句,加一个ELEMENTS. 为什么baidu这么就都找不到.到处都是转来转去的东西.郁闷. select h.*,(s ...

  5. caffe中的Blob块

    首先说明:Blob定义了一个类模板. 让我们看一下Blob的头文件里有什么哈: 定义了一个全局变量: const ; 看看它的构造函数: Blob() : data_(), diff_(), coun ...

  6. 修正ios h5上传图时的图片方向问题

     .ios上传会在exif中带一个 Orientation的属性,这个属性在windows中不会生效,在ios浏览器中会生效,造成图片在windows资源管理器中与ios浏览器中方向不一致  为了用户 ...

  7. nginx的location root 指令

    原文:http://blog.csdn.net/bjash/article/details/8596538 location /img/ { alias /var/www/image/; } #若按照 ...

  8. 强制关闭tomcat

    ps -ef |grep tomcat //找到tomcat的端口号 kill - tomcatpid

  9. Android布局_帧布局FrameLayout

    一.FrameLayout布局概述 在这个布局中,所有的子元素都不能被指定放置的位置,他们统统放于这块区域的左上角,并且后面的子元素直接覆盖在前面的子元素之上,将前面的子元素部分和全部遮挡  如下面的 ...

  10. Java 7 命令/工具 jcmd 使用详细解释

    常见功能 列出 Java 进程 PID 以及 名称 列出进程的 thread dump 得到进程的 heap dump 得到进程的 JVM 参数 具体如下: 列出 Java 进程 PID 以及 名称 ...