MATLAB聚类有效性评价指标(外部 成对度量)

MATLAB聚类有效性评价指标(外部 成对度量)

作者:凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/

更多内容,请看:MATLAB: Clustering Algorithms, MATLAB聚类有效性评价指标(外部)文章地址https://www.yii666.com/article/754181.html文章来源地址:https://www.yii666.com/article/754181.html

前提:数据的真实标签已知!TP:真阳性,FP:假阳性,FN:假阴性,TN:真阴性网址:yii666.com<

MATLAB聚类有效性评价指标(外部 成对度量)

1. MATLAB程序

function result = Evaluate(real_label,pre_label)
% This fucntion evaluates the performance of a classification model by
% calculating the common performance measures: Accuracy, Sensitivity,
% Specificity, Precision, Recall, F-Measure, G-mean.
% Input: ACTUAL = Column matrix with actual class labels of the training
% examples
% PREDICTED = Column matrix with predicted class labels by the
% classification model
% Output: EVAL = Row matrix with all the performance measures
% https://www.mathworks.com/matlabcentral/fileexchange/37758-performance-measures-for-classification idx = (real_label()==1); p = length(real_label(idx));
n = length(real_label(~idx));
N = p+n; tp = sum(real_label(idx)==pre_label(idx));
tn = sum(real_label(~idx)==pre_label(~idx));
fp = n-tn;
fn = p-tp; tp_rate = tp/p;
tn_rate = tn/n; accuracy = (tp+tn)/N; %准确度
sensitivity = tp_rate; %敏感性:真阳性率
specificity = tn_rate; %特异性:真阴性率
precision = tp/(tp+fp); %精度
recall = sensitivity; %召回率
f_measure = 2*((precision*recall)/(precision + recall)); %F-measure
gmean = sqrt(tp_rate*tn_rate);
Jaccard=tp/(tp+fn+fp); %Jaccard系数 result = [accuracy sensitivity specificity precision recall f_measure gmean Jaccard];
fprintf('accuracy=%.4f, sensitivity=%.4f, specificity=%.4f, precision=%.4f, recall=%.4f, f_measure=%.4f, gmean=%.4f, Jaccard=%.4f\n', ...
accuracy, sensitivity, specificity, precision, recall, f_measure, gmean, Jaccard);

2. 结果

>> A = [1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 3];
>> B = [1 2 1 1 1 1 1 2 2 2 2 3 1 1 3 3 3];
>> result = Evaluate(A,B)
accuracy=0.7059, sensitivity=0.8333, specificity=0.6364, precision=0.5556, recall=0.8333, f_measure=0.6667, gmean=0.7282, Jaccard=0.5000 result = 0.705882352941177 0.833333333333333 0.636363636363636 0.555555555555556 0.833333333333333 0.666666666666667 0.728219081254419 0.500000000000000

3. 参考

[1] MATLAB聚类有效性评价指标(外部)网址:yii666.com

[2] 相似性度量

[3] Performance Measures for Classification文章来源地址https://www.yii666.com/article/754181.html

[4] Gaussian field consensus论文解读及MATLAB实现

版权声明:本文内容来源于网络,版权归原作者所有,此博客不拥有其著作权,亦不承担相应法律责任。文本页已经标记具体来源原文地址,请点击原文查看来源网址,站内文章以及资源内容站长不承诺其正确性,如侵犯了您的权益,请联系站长如有侵权请联系站长,将立刻删除

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信图片_20190322181744_03.jpg

微信扫一扫打赏

请作者喝杯咖啡吧~

支付宝扫一扫领取红包,优惠每天领

二维码1

zhifubaohongbao.png

二维码2

zhifubaohongbao2.png