这种写法不懂。。

data = data[row_idx][:, col_idx]

这个例子演示如何产生一个数据集,并且用谱系共聚类法(Spectral Co-Clustering algorithm)对它进行双向聚类。所谓“双向聚类”,是指对变量和实例同时聚类。
这里,使用函数make_biclusters产生双向聚类的数据集。该函数产生的矩阵元素较小,但嵌入的双向类bicluster具有较大的值。然后随机重排矩阵的行和列,作为参数传递给算法。再重新排列这个随机重排的矩阵,使得biclusters邻接。这样一来就可以看出算法的准确程度了。
导入库

import numpy as np
from matplotlib import pyplot as pltfrom sklearn.datasets import make_biclusters
from sklearn.cluster.bicluster import SpectralCoclustering
from sklearn.metrics import consensus_score

调用函数make_biclusters, 产生一个300行,300列的数据数组,该数组有一个用于双向聚类的固定对角块结构。预置5个biclusters, 5个标准差的高斯误差。作图显示产生的数据集。

data, rows, columns = make_biclusters(shape=(300, 300), n_clusters=5, noise=5,shuffle=False, random_state=0)plt.matshow(data, cmap=plt.cm.Blues)
plt.title("Original dataset")
plt.show()

# shuffle clusters
rng = np.random.RandomState(0)
row_idx = rng.permutation(data.shape[0])
col_idx = rng.permutation(data.shape[1])
data = data[row_idx][:, col_idx]plt.matshow(data, cmap=plt.cm.Blues)
plt.title("Shuffled dataset")

model = SpectralCoclustering(n_clusters=5, random_state=0)
model.fit(data)
score = consensus_score(model.biclusters_,(rows[:, row_idx], columns[:, col_idx]))print("consensus score: {:.3f}".format(score))fit_data = data[np.argsort(model.row_labels_)]
fit_data = fit_data[:, np.argsort(model.column_labels_)]plt.matshow(fit_data, cmap=plt.cm.Blues)
plt.title("After biclustering; rearranged to show biclusters")plt.show()

consensus score: 1.000

002A demo of the Spectral Co-Clustering algorithm相关推荐

  1. 文献记录(part90)--A novel density-based clustering algorithm using nearest neighbor graph

    学习笔记,仅供参考,有错必纠 关键词:基于密度的聚类:最近邻图:DBSCAN 文章目录 A novel density-based clustering algorithm using nearest ...

  2. 文献记录(part89)--I-k-means-+:An iterative clustering algorithm based on an enhanced k -means

    学习笔记,仅供参考,有错必究 关键词:k均值:解决方案改进:准确的k均值:迭代改进 I-k-means-+:An iterative clustering algorithm based on an ...

  3. 文献学习(part20)--Sparse Subspace Clustering: Algorithm, Theory, and Applications

    学习笔记,仅供参考,有错必纠 文章目录 Sparse Subspace Clustering: Algorithm, Theory, and Applications Abstract INTRODU ...

  4. 【聚类算法】密度峰值聚类算法DPC(Density Peak Clustering Algorithm)

    every blog every motto: You can do more than you think. https://blog.csdn.net/weixin_39190382?type=b ...

  5. 【ML30】Basic K-means clustering algorithm

    Centroids 首先将明确什么是 centroid 质心 ,如果理解可以直接跳到第二部分. 质心(centroid) ,即质量中心的简称,在物质系统中,被认为是质量集中于此的一个假想点. 举一个简 ...

  6. 【ML31】Advanced K-means clustering algorithm

    Cost Function for K-means J ( c ( 1 ) , c ( 2 ) , . . . , c ( m ) , μ 1 , μ 2 , . . . , μ k ) = 1 m ...

  7. 一个不错的Spectral Clustering方法的总结

    什么叫Spectral Algorithm?  广义上来说,任何在演算法中用到SVD/特征值分解的,都叫Spectral Algorithm. 从很老很老的PCA/LDA,到比较近的Spectral ...

  8. python谱聚类算法_谱聚类Spectral clustering(SC)

    在之前的文章里,介绍了比较传统的K-Means聚类.Affinity Propagation(AP)聚类.比K-Means更快的Mini Batch K-Means聚类以及混合高斯模型Gaussian ...

  9. Spectral Algorithm

    Spectral Algorithm[转自网络,参考用] 有关Spectral Algorithm sigchi结束之后,这两天看了下spectral algorithm的一些相关的paper.现在给 ...

最新文章

  1. mysql 1005 错误
  2. OFDM资料(待总结)
  3. drop by time at xjtlu consultation center
  4. vue.js官方文档 PDF
  5. 关于Webapp的注意事项
  6. idea无法启动Tomcat
  7. 【代码笔记】iOS-实现网络图片的异步加载和缓存
  8. axios post请求
  9. 开始位置 环状图_【技术分享】如何找到压铸模具中真空阀的最佳位置?
  10. 主题桌面 树莓派4b经典_用树莓派4b构建深度学习应用(一)硬件篇
  11. 文献阅读 Fully Convolutional Networks for Semantic Segmentation
  12. 计算机基础命令系统,Win7定时开关命令_计算机基础知识_IT /计算机_信息
  13. 在 js 中应用 订阅发布模式(subscrib/public)
  14. (附源码)springboot社区文明养宠平台 毕业设计 231609
  15. matlab 单位化矩阵,MATLAB数据矩阵单位化,归一化,标准化
  16. UE4项目开启光线追踪
  17. wps如何保存最终状态_wps word 最后一次保存者 wps最后一次保存者
  18. Processing 入门教程(三十) lerpColor颜色渐变
  19. [问题已处理]-mac安装cobra失败
  20. 【正点原子FPGA连载】第三十一章RTC实时时钟数码管显示实验 -摘自【正点原子】新起点之FPGA开发指南_V2.1

热门文章

  1. 【BZOJ3551】Peaks加强版,主席树+kruskal重构+dfs序+倍增思想
  2. 【BZOJ2243】【codevs1566】染色,树链剖分练习
  3. 11.频域里的卷积——平滑和模糊,2D例子,低通和高通滤波器_2
  4. 合成迪丽热巴下海_热巴生图颜值回春,被韩媒吹上天,她是找了杨幂的医生?...
  5. elasticsearch docker无法挂载_ElasticSearch数据备份与恢复
  6. 【英语学习】【医学】Unit 09 The Respiratory System
  7. Intel 64/x86_64/x86/IA-32处理器串行化指令(2) - 参考
  8. Intel® Nehalem/Westmere架构/微架构/流水线 (9) - 系统软件增强/能耗增强
  9. 前锋php人工智能_人工智能除了学习php,还应该学什么?
  10. uml类图工具_三款超级轻量化制图工具!每个不超过2MB,堪称神器!