问题描述
我正在为单人作业研究kmeans功能.我们需要对一组数据运行欧几里得聚类,然后对另一组数据运行Jaccard.我们需要探索一些不同的模型来评估聚类的数量,对于欧几里得来说,使用 sklearn.metrics.silhouette_score 很简单,但这并没有提供使用Jaccard距离的选项.
I'm working on a kmeans functionality for a uni assignment. We need to run euclidean clustering on one set of data and then Jaccard on the other. We need to explore a few different models to evaluate the number of clusters and for the Euclidean it was quite straight forward using sklearn.metrics.silhouette_score, but this does not give the option to use Jaccard distance.
正因为如此,我想知道是否有人对如何计算Jaccard距离有一个想法?我设法为彼此之间的所有距离创建一个矩阵.我还在欧几里得距离中使用了Elbow方法,这对于Jaccard也是一种有效方法吗?
As such I was wondering if anyone has an idea of how to calculate it for Jaccard distance? I have managed to create a matrix for all the distances to each other. I also used the Elbow method in the Euclidean distance, would that be a valid method for Jaccard as well?
推荐答案
使用metric ="precomputed"
Use metric="precomputed"
from sklearn.metrics import silhouette_score
silhouette_score(dist_matrix, k_means_cluster_ids, metric="precomputed")
这篇关于Jaccard距离的轮廓分数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!