我的数据是垃圾邮件/火腿数据...我正在尝试使用内置函数计算微观/宏观平均值,但我得到的数字完全相同。他们都给了我:0.6666666667 ... 这是真的吗?即使更改数据,他们给我的数字与上面的数字不同,但使用 Macreo=Micro ! 我的计算是这样的:
cm= metrics.confusion_matrix(y_test,y_pred)
#calculating the FP,FN
TP=cm[1,1]
TN=cm[0,0]
FP=cm[0,1]
FN=cm[1,0]
print cm
#calculating the false positive rate
print "calculating the false positive rate"
print FP,TN,FP
print FP/float(TN+FP)
print "calculating the macro-averaged"
print metrics.average_precision_score(y_test, y_pred, average='macro', sample_weight=None)
print "calculating the macro-averaged"
print metrics.average_precision_score(y_test, y_pred, average='micro', sample_weight=None)
最佳答案
微观和宏观平均值是针对多类问题(或至少是序列)定义的。如果您的数据是简单的二进制标记分类(看起来如此),这两个对象是相同。
关于python - 计算宏观/微观平均值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34837620/