scikit-learn中的SpectralClustering与Spectrum_Clustering [英] SpectralClustering vs. spectral_clustering in scikit-learn

查看:103
本文介绍了scikit-learn中的SpectralClustering与Spectrum_Clustering的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到sklearn.cluster库中有两个不同的谱聚类函数: SpectralClustering spectral_clustering .尽管它们在某些细节上有所不同,但它们都进行频谱聚类,并且它们的大多数参数重叠.我很困惑为什么sklearn中有两种方法如此相似?

I noticed that there are two different functions for spectral clustering in sklearn.cluster library: SpectralClustering and spectral_clustering. Although they differ in some details, both do spectral clustering and most of their parameters overlap. I am confused about why there are two methods so similar in sklearn?

我注意到了一些差异:

  • 在SpectralClustering中,参数 affinity 同时包含字符串和数组;其默认值为'rbf';在Spectrum_clustering中,它只能是一个矩阵

  • In SpectralClustering, parameter affinity takes both string and array; its default value is 'rbf'; in spectral_clustering it can only be a matrix

SpectralClustering()的工作方式类似于构造函数.它不返回任何内容,但具有两个属性 affinity_matrix _ (您可以在调用.fit()之后访问该属性)和 labels _ .spectrum_clustering是仅返回标签的方法.

SpectralClustering() works like a constructor. It doesn't return anything but has two attributes affinity_matrix_(which you can access after calling .fit()) and labels_. spectral_clustering is a method that only returns the labels.

使用SpectralClustering:

Using SpectralClustering:

cluster=SpectralClustering().fit(X)
cluster.labels_

使用Spectrum_clustering:

Using spectral_clustering:

labels=spectral_clustering(affinity_matrix)

尽管存在这些明显的差异,但我想知道这两种方法在基本方面是否有所不同.否则,为什么有两种方法可以完成基本相同的事情?

Despite these apparent differences, I'm wondering whether these two methods differ in fundamental aspects. Otherwise why are there two methods that accomplish basically the same thing?

推荐答案

您是否检查了源代码?

我希望 SpectralClustering 是命令式 spectral_clustering 的面向对象包装.

I'd expect that SpectralClustering is an object oriented wrapper for the imperative method spectral_clustering.

这篇关于scikit-learn中的SpectralClustering与Spectrum_Clustering的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆