我注意到sklearn.cluster库中有两个不同的谱聚类函数:SpectralClustering和聚类。虽然它们在一些细节上有所不同,但它们的光谱聚类和它们的大部分参数都是重叠的。我很困惑为什么在滑雪中有两种类似的方法?
我注意到了一些不同之处:
affinity同时接受字符串和数组;它的默认值是'rbf';在spectral_clustering中只能是一个矩阵。affinity_matrix_(您可以在调用.fit()之后访问它)和labels_。spectral_clustering是一个只返回标签的方法。使用SpectralClustering:
cluster=SpectralClustering().fit(X)
cluster.labels_使用spectral_clustering:
labels=spectral_clustering(affinity_matrix)尽管存在这些明显的差异,但我想知道这两种方法在基本方面是否存在差异。否则,为什么有两种方法可以完成基本相同的任务呢?
发布于 2019-04-17 06:03:34
你查过源代码了吗?
我希望SpectralClustering是一个面向对象的包装器,用于命令式方法spectral_clustering。
https://stackoverflow.com/questions/55670111
复制相似问题