AgglomerativeClustering 中的 pooling_func 不起作用。
from sklearn import metrics
from sklearn.datasets.samples_generator import make_blobs
from sklearn.cluster import AgglomerativeClustering
centers = [[1, 1], [-1, -1], [1, -1]]
X, labels_true = make_blobs(n_samples=300, centers=centers, cluster_std=0.5,
random_state=0)
model = AgglomerativeClustering(linkage='complete',
connectivity=None,
affinity = 'cosine',
pooling_func = "test_error",
n_clusters=3)
model.fit(X)
引发错误,因为 pooling_func 不可调用。 这是一个字符串。
没有警告,没有错误
Linux-4.4.0-64-generic-x86_64-with-debian-stretch-sid
Python 3.5.3 | 由 conda-forge 打包 | (默认,2017 年 2 月 9 日,14:37:12)
[GCC 4.8.2 20140120(红帽 4.8.2-15)]
NumPy 1.13.1
SciPy 0.19.1
Scikit-Learn 0.19.0
在我看来,这是一个类设计问题:FeatureAgglomeration 派生自 AgglomerativeClustering,但 pooling_func 仅用于 AgglomerativeClustering.transform。
随意打开一个 PR。 我没有详细查看,但可能的解决方案是让 FeatureAgglomeration 和 AgglomerativeClustering 从一个公共基类派生,并且仅在 FeatureAgglomeration 中具有 pooling_func。
话虽如此,但这样做可能是有原因的,尽管我想不出任何原因。
(而 FeatureAgglomeration 应该是一个包装器或混合器......)
2017 年 9 月 28 日晚上 9:24,“Loïc Estève”通知@ github.com 写道:
在我看来,这是一个类设计问题:FeatureAgglomeration
派生自 AgglomerativeClustering 但 pooling_func 仅用于
AgglomerativeClustering.transform。随意打开一个 PR。 我没有详细看,但一个可能的解决方案
将有 FeatureAgglomeration 和 AgglomerativeClustering 派生
来自公共基类,并且仅在 FeatureAgglomeration 中具有 pooling_func。话虽如此,但这样做可能是有原因的,尽管我
想不出任何。—
您收到此消息是因为您订阅了此线程。
直接回复本邮件,在GitHub上查看
https://github.com/scikit-learn/scikit-learn/issues/9846#issuecomment-332807654 ,
或静音线程
https://github.com/notifications/unsubscribe-auth/AAEz6z9lkUF7u0jA2-sWEe_XIZvUk1r_ks5sm4HdgaJpZM4PnBzV
.
如果目前没有解决这个问题,我想解决这个问题。