如果有了类别标签,那么聚类结果也可以像分类那样计算准确率和召回率。scikitlearn上说:“其实不应该将分类标签作为聚类结果的评价指标,除非你有相关的先验知识或某种假设,知道这种分类类内差距更小”。但是它还是给出了几种评价标准
1. Adjusted Rand index
1.1 原理及代码实现
和分类中的acc类似,这是在计算样本预测值和真实值之间的相似度
similarity:同属于这一类或都不属于这一类 python实现的代码如下:
labels_true, labels_pred = check_clusterings(labels_true, labels_pred)
n_samples = labels_true.shape[0]
classes = np.unique(labels_true)
clusters = np.unique(labels_pred)
# Special limit cases: no clustering since the data is not split;
# or trivial clustering where each document is assigned a unique cluster.
# These are perfect matches hence return 1.0.
if (classes.shape[0] == clusters.shape[0] == 1
or classes.shape[0] == clusters.shape[0] == 0
or classes.shape[0] == clusters.shape[0] == len(labe