本文整理汇总了Python中sklearn.cluster.DBSCAN.set_params方法的典型用法代码示例。如果您正苦于以下问题:Python DBSCAN.set_params方法的具体用法?Python DBSCAN.set_params怎么用?Python DBSCAN.set_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.cluster.DBSCAN
的用法示例。
在下文中一共展示了DBSCAN.set_params方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TruncatedSVD
# 需要导入模块: from sklearn.cluster import DBSCAN [as 别名]
# 或者: from sklearn.cluster.DBSCAN import set_params [as 别名]
svd = TruncatedSVD(n_components=100)
pipe_trans = make_pipeline(vectorizer, svd)
dmat = pairwise_distances(pipe_trans.fit_transform(df_document.docCleanText.values),
metric='cosine', n_jobs=-1)
print('pre-calculete distance matric..')
param = {'eps': [0.13, 0.18, 0.2, 0.24 ], 'min_samples':[4, 5, 6]}
model = DBSCAN(metric='precomputed')
#X = lsa.fit_transform(df_document.docCleanText.values)
for eps in param['eps']:
for min_samples in param['min_samples']:
model.set_params(eps=eps, min_samples= min_samples)
model.fit(dmat)
cluster_labels = model.labels_
try:
silhouette_avg = silhouette_score(dmat, cluster_labels, metric='precomputed', sample_size=100)
print('eps: %4.4f, min_samples: %d, NClusters %d' % (eps, min_samples, np.unique(cluster_labels).shape[0]))
print('silhouette_avg: %4.4' % silhouette_avg)
except:
pass
#sample_silhouette_values = silhouette_samples(X.toarray(), cluster_labels)
#print(np.unique(sample_silhouette_values))