首页 > 解决方案 > 在 DBSCAN 上运行网格搜索时引发值错误

问题描述

我正在研究管道并使用它在 DBSCAN 上运行网格搜索。这就是我的管道的样子:

pca = PCA()
db = DBSCAN()

classifier = pipeline.Pipeline([
    ("pca",pca),
    ("db",db)
])

param_grid = {
    "pca__n_components": np.arange(2,5),
    "db__eps": np.arange(0.01, 0.09),
    "db__min_samples": np.arange(15,75)
}

model = model_selection.GridSearchCV(
    estimator=classifier,
    param_grid=param_grid,
    scoring=silhouette_score(X, labels, metric='sqeuclidean'),
    cv=5)

model.fit(X,labels)

引发的错误如下。有谁熟悉如何停止提出这个错误?我知道一些 siloette 分数会是负数,我想网格搜索继续运行。谢谢。

ValueError: scoring is invalid (got -0.10780103330375239). Refer to the scoring glossary for details: https://scikit-learn.org/stable/glossary.html#term-scoring

标签: pythonscikit-learncluster-analysispipelinegrid-search

解决方案


推荐阅读