且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

python scipy/numpy中的相关性的层次聚类?

更新时间:2022-12-30 18:23:01

只需将指标更改为correlation,以使第一行变为:

Just change the metric to correlation so that the first line becomes:

Y=pdist(X, 'correlation')

但是,我认为代码可以简化为:

However, I believe that the code can be simplified to just:

Z=linkage(X, 'single', 'correlation')
dendrogram(Z, color_threshold=0)

因为链接将为您处理pdist.

because linkage will take care of the pdist for you.