计算 macro/micro 平均值
calculating the macro/micro average
我的数据是 spam/ham 数据 ... 我正在尝试使用内置函数计算 Micro/Macro 平均值,但我得到的数字完全相同。他们都给了我: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)
为多class问题(或至少序列)定义了微观和宏观平均数。如果您的数据很简单,二进制标记为 classification(看起来如此),这两个对象 相同。
我的数据是 spam/ham 数据 ... 我正在尝试使用内置函数计算 Micro/Macro 平均值,但我得到的数字完全相同。他们都给了我: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)
为多class问题(或至少序列)定义了微观和宏观平均数。如果您的数据很简单,二进制标记为 classification(看起来如此),这两个对象 相同。