Python-ML聚类的性能评价指标
Posted fjssharpsword
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python-ML聚类的性能评价指标相关的知识,希望对你有一定的参考价值。
参考:http://scikit-learn.org/stable/modules/clustering.html#clustering-performance-evaluation
1、兰德指数
from sklearn import metrics
labels_true = [0, 0, 0, 1, 1, 1]
labels_pred = [0, 0, 1, 1, 2, 2]
print (metrics.adjusted_rand_score(labels_true, labels_pred))
2、互信息
from sklearn import metrics
labels_true = [0, 0, 0, 1, 1, 1]
labels_pred = [0, 0, 1, 1, 2, 2]
print (metrics.adjusted_mutual_info_score(labels_true, labels_pred) )
3、Homogeneity, completeness and V-measure
同质性homogeneity:每个群集只包含单个类的成员。
完整性completeness:给定类的所有成员都分配给同一个群集。
两者的调和平均V-measure。
from sklearn import metrics
labels_true = [0, 0, 0, 1, 1, 1]
labels_pred = [0, 0, 1, 1, 2, 2]
print (metrics.homogeneity_score(labels_true, labels_pred))
print (metrics.completeness_score(labels_true, labels_pred))
print (metrics.v_measure_score(labels_true, labels_pred))
4、Fowlkes-Mallows scores
from sklearn import metrics
labels_true = [0, 0, 0, 1, 1, 1]
labels_pred = [0, 0, 1, 1, 2, 2]
print (metrics.fowlkes_mallows_score(labels_true, labels_pred))
5、Silhouette Coefficient 轮廓系数
参考:
http://blog.csdn.net/fjssharpsword/article/details/79161570
6、Calinski-Harabaz Index
类别内部数据的协方差越小越好,类别之间的协方差越大越好,这样的Calinski-Harabasz分数会高。
以上是关于Python-ML聚类的性能评价指标的主要内容,如果未能解决你的问题,请参考以下文章