2个树状图和凝聚态相关矩阵的热图

时间:2018-09-26 12:09:14

标签: python scipy cluster-analysis

我尝试创建如下内容: plotting results of hierarchical clustering ontop of a matrix of data in python

不幸的是,当我尝试执行代码时,收到以下警告:

Warning (from warnings module):
  File "C:\Users\USER1\Desktop\test.py", line 15
    Y = sch.linkage(D, method='centroid')
ClusterWarning: scipy.cluster: The symmetric non-negative hollow observation matrix looks suspiciously like an uncondensed distance matrix

Warning (from warnings module):
  File "C:\Users\USER1\Desktop\test.py", line 22
    Y = sch.linkage(D, method='single')
ClusterWarning: scipy.cluster: The symmetric non-negative hollow observation matrix looks suspiciously like an uncondensed distance matrix

此外,还会打开一个小窗口,但会崩溃...

1 个答案:

答案 0 :(得分:0)

您链接到的代码有一个问题:它将平方距离矩阵传递到linkagelinkage的第一个参数经常引起混乱,因此在最新版本的scipy中,如果传入了看起来像平方距离矩阵的代码,则代码会生成警告。

您将不得不修改代码以不将平方距离矩阵传递给linkage。如果您已有这样的矩阵,则可以使用函数scipy.spatial.distance.squareform将其转换为linkage期望的压缩形式。

为避免进一步的混乱,我更新了链接答案中的代码,以使它将压缩的距离矩阵传递给linkage

相关问题