使用scipy进行聚类
来源:互联网 发布:linux内核开发教程 编辑:程序博客网 时间:2024/06/05 17:16
最近做图像的时候,突然有个idea,需要进行聚类,其实算法很简单,但是当时很急,就直接使用了scipy的cluster。
使用起来其实很简单,但是中文的文章很少,所以就简单的介绍一下,感兴趣的也可以自己去看一下英文的文档:http://docs.scipy.org/doc/scipy/reference/cluster.html。
这是我从stackoverflow看到的一个demo,如果只是简单的使用cluster,这样就可以了。
import scipyimport scipy.cluster.hierarchy as schimport matplotlib.pylab as pltscipy.randn(100,2)d = sch.distance.pdist(X)Z= sch.linkage(d,method='complete')P =sch.dendrogram(Z)plt.savefig('plot_dendrogram.png')T = sch.fcluster(Z, 0.5*d.max(), 'distance')#array([4, 5, 3, 2, 2, 3, 5, 2, 2, 5, 2, 2, 2, 3, 2, 3, 2, 5, 4, 5, 2, 5, 2,# 3, 3, 3, 1, 3, 4, 2, 2, 4, 2, 4, 3, 3, 2, 5, 5, 5, 3, 2, 2, 2, 5, 4,# 2, 4, 2, 2, 5, 5, 1, 2, 3, 2, 2, 5, 4, 2, 5, 4, 3, 5, 4, 4, 2, 2, 2,# 4, 2, 5, 2, 2, 3, 3, 2, 4, 5, 3, 4, 4, 2, 1, 5, 4, 2, 2, 5, 5, 2, 2,# 5, 5, 5, 4, 3, 3, 2, 4], dtype=int32)sch.leaders(Z,T)
如果想要了解更多一些的话,可以参考 http://nbviewer.ipython.org/github/herrfz/dataanalysis/blob/master/week4/clustering_example.ipynb
这篇文章其实写的已经非常棒了,虽然文件我没有能够成功down下来。
0 0
- 使用scipy进行聚类
- 使用scipy进行层次聚类和k-means聚类
- 使用scipy进行层次聚类和k-means聚类
- python进行聚类(scikit-lean、scipy)
- python进行聚类(scikit-lean、scipy)
- 使用NumPy和SciPy进行数值分析
- 使用SciPy进行常用的图像操作
- Python使用scipy进行多项式计算与符号计算
- 使用scipy.optimize进行目标函数中的矩阵参数优化
- python中做层次聚类,使用scipy.cluster.hierarchy.fclusterdata方法
- python中做层次聚类,使用scipy.cluster.hierarchy.fclusterdata方法
- python模块之scipy的层次聚类简单测试与使用
- 使用pip安装scipy
- 5.scipy基础使用
- Python聚类工具scipy cluster
- Python使用matplotlib,numpy,scipy进行散点的平滑曲线化方法
- 使用scipy实现最小二乘法,以及通过曲线对数据进行拟合(Python)
- Python使用matplotlib,numpy,scipy进行散点的平滑曲线化方法
- 吝啬的国度(深搜+vector)
- 没有什么,开发ASP.NET时随便写写
- C++指针
- 学习总结二十一:Hbase集群搭建
- 21天学通Java学习笔记-Day12(MYsql-JDBC)
- 使用scipy进行聚类
- struts.xml中package的namespace属性
- 访问google的办法之一
- obj-c编程17:键值观察(KVO)
- uva10561 - Treblecross SG定理
- 数据库中视图的作用
- C++中delete和delete[]的区别
- poj 2051 Argus(优先队列)
- leetcode Jump Game II