由于聚类的自动索引可能是原始标签的排列,我们如何测量K-Means聚类算法的准确性(例如,生成混淆矩阵)?
我也不完全知道你的意思。您最初的标签也许就是地面真理标签。k均值提供的聚类结果通常是整数,其范围与k均值算法希望给您的k个聚类的数量一样多。
我通常使用pandas.crosstab
函数将带有交叉表的kmeans标签的groundtruth标签的本地化可视化。
为了获得更好的可视化效果,您可能需要使用以下内容:
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(30,10))
# plot the heatmap for correlation matrix
ax = sns.heatmap(crosstab_groundtruth_kmeans.T,
square=True, annot=True, fmt='.2f')
ax.set_yticklabels(
ax.get_yticklabels(),
rotation=0);
祝你好运!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句