协作网站是什么,房地产网址大全,网站建设中的页数,安卓开发助手一、Given Label
均一性homogeneity#xff1a;一个簇中只包含一个类别样本#xff0c;Precision 完整性completeness#xff1a;同类别样本被归到同一个簇中#xff0c;Recall 将均一性h和完整性c进行结合(二者加权平均)得到V-Measure#xff0c;#xff0c;β为权重 …一、Given Label
均一性homogeneity一个簇中只包含一个类别样本Precision 完整性completeness同类别样本被归到同一个簇中Recall 将均一性h和完整性c进行结合(二者加权平均)得到V-Measureβ为权重
代码实现
from sklearn import metricsif __name__ __main__:y [0, 0, 0, 1, 1, 1]#正确的分类y_hat [0, 0, 1, 1, 2, 2]#生成的分类h metrics.homogeneity_score(y, y_hat)c metrics.completeness_score(y, y_hat)print(u同一性(Homogeneity), h)print(u完整性(Completeness), c)v2 2 * c * h / (c h)v metrics.v_measure_score(y, y_hat)print(uV-Measure, v2, v)y [0, 0, 0, 1, 1, 1]y_hat [0, 0, 1, 3, 3, 3]h metrics.homogeneity_score(y, y_hat)c metrics.completeness_score(y, y_hat)v metrics.v_measure_score(y, y_hat)print(u同一性(Homogeneity), h)print(u完整性(Completeness), c)print(uV-Measure, v)# 允许不同值y [0, 0, 0, 1, 1, 1]y_hat [1, 1, 1, 0, 0, 0]h metrics.homogeneity_score(y, y_hat)c metrics.completeness_score(y, y_hat)v metrics.v_measure_score(y, y_hat)print(u同一性(Homogeneity), h)print(u完整性(Completeness), c)print(uV-Measure, v)y [0, 0, 1, 1]y_hat [0, 1, 0, 1]ari metrics.adjusted_rand_score(y, y_hat)print(ari)y [0, 0, 0, 1, 1, 1]y_hat [0, 0, 1, 1, 2, 2]ari metrics.adjusted_rand_score(y, y_hat)print(ari)二、ARI评估
已知类别的情况下看看聚类算法是否对这样的数据集有效 评判聚类结果Y和实际结果X相关性 n11是共同的a1是X1簇中的样本数量b1是Y1簇中样本个数 Rand Index Adjusted Rand index(调整兰德指数)(ARI)表示数据集中可以组成的对数RI取值范围为[0,1]值越大意味着聚类结果与真实情况越吻合 ARI取值范围为[−1,1]值越大意味着聚类结果与真实情况越吻合。从广义的角度来讲ARI衡量的是两个数据分布的吻合程度 任意取两个是属于某一个类别的概率一样
三、AMI 四、轮廓系数
计算同簇内每一个样本到同簇内样本的平均距离可以度量这个样本和其他同簇样本的相似性 计算一个簇内每一个样本到不同簇内所有样本的距离不同簇的那些样本距离求平均然后求最小的那个距离是不相似性 第一个值很小第二个值很大那这个就是簇内很典型性的样本 如果相反按道理应该属于另外一个簇了
轮廓系数是要照顾到每一个样本的 Si接近1说明样本i聚类合理Si接近-1说明样本更应该分到其他簇 Si接近0说明在簇分界上