【发布时间】:2022-09-27 15:25:44
【问题描述】:
我正在使用 Seaborn 库在我的程序中生成一个集群图。它使用 Scipy 来执行此操作,但 Scipy 中有一个名为 optimal_leaf_ordering 的特殊参数,Seaborn 没有选择。
我想我可以在我的程序中使用 Seaborn 中的类创建一个继承类,该类绘制集群图,并确保它将optimal_ordering=True 传递给 Scipy,如下所示:
from scipy.cluster import hierarchy
from seaborn.matrix import _DendrogramPlotter
class _DendrogramPlotter(_DendrogramPlotter):
def _calculate_linkage_scipy(self):
linkage = hierarchy.linkage(self.array, method=self.method,
metric=self.metric, optimal_ordering=True)
return linkage
但这似乎并没有改变我的程序中的任何内容。有人可以解释我哪里出错了吗?