【发布时间】:2019-01-15 13:11:15
【问题描述】:
我试图使用 GridSearch 来迭代 MeanShift 算法的不同带宽值,它显示了这个错误;你们有谁知道我该如何解决这个问题?非常感谢!
# Using GridSearch for Algorithm Tuning
from sklearn.model_selection import GridSearchCV
meanshift=MeanShift()
C = range(48, 69) # For MeanShift bandwidth
param_grid = {"bandwidth": range(48, 69)}
mean_grid = GridSearchCV(estimator=meanshift, param_grid=param_grid, scoring=None)
mean_grid.fit(X)
这是我得到的错误:
TypeError: If no scoring is specified, the estimator passed should have a 'score' method. The estimator MeanShift(bandwidth=None, bin_seeding=False, cluster_all=True, min_bin_freq=1,
n_jobs=1, seeds=None) does not.
【问题讨论】:
-
你有集群的实际标签吗?由于您没有在
fit()中传递任何基本事实数据(集群的实际标签,y),您将如何计算分数?在什么基础上,GridSearchCV 会判定一个特定的bandwidth值优于其他值? -
sklearn.clustering中没有类支持score(),KMeans除外。你想使用那个score()函数吗? -
@VivekKumar;非常感谢你的回复。我实际上对我最终应该拥有的集群一无所知..这意味着我无法计算 MeanShift 的分数。但是,我想知道是否还有其他的,以便我们根据我们想要的集群数量来设置分数?
标签: machine-learning scikit-learn cluster-analysis grid-search mean-shift