2016-10-20 12 views
3

ValueError: Linkage 'Z' uses the same cluster more than once.は、scipy.cluster.hierarchy.fclusterを使用してPythonでフラットクラスタを取得しようとしています。このエラーは、たまにしか発生しません。通常、実際には大きな行列、つまり10000x10000でのみ発生します。ValueError:Linkage 'Z'はPython scipy fclusterで同じクラスタを2回以上使用します

import scipy.cluster.hierarchy as sch 
Z = sch.linkage(d, method="ward") 
# some computation here, returning n (usually between 5-30) 
clusters = sch.fcluster(Z, t=n, criterion='maxclust') 

どうしてですか?どうすればそれを避けることができますか?残念ながら、私はグーグルで有用な情報を見つけることができませんでした。

EDITデンドログラムを取得しようとするとエラーが発生します。 method='average'を使用すると、このようなエラーは発生しません。

答えて

0

scipy.cluster.hierarchyの代わりにfastclusterを使用しているようですが、この問題を解決します。さらに、の実装はscipyよりわずかに高速です。
詳細はthe paperをご覧ください。

import fastcluster 
Z = fastcluster.linkage(d, method="ward") 
# some computation here, returning n (usually between 5-30) 
clusters = fastcluster.fcluster(Z, t=n, criterion='maxclust') 
関連する問題