我有一个关于sklearn.metrics.f1_score中加权平均的问题。
sklearn.metrics.f1_score(y_true, y_pred, labels=None, pos_label=1, average='weighted', sample_weight=None)
Calculate metrics for each label, and find their average, weighted by support (the number of true instances for each label). This alters ‘macro’ to account for label imbalance; it can result in an F-score that is not between precision and recall.
首先,如果有任何参考资料支持使用加权F1值,我只是好奇在哪些情况下应该使用加权F1值。
其次,我听说加权F1值已经被弃用了,这是真的吗?
第三,加权F1值实际上是如何计算的,例如:
{
"0": {
"TP": 2,
"FP": 1,
"FN": 0,
"F1": 0.8
},
"1": {
"TP": 0,
"FP": 2,
"FN": 2,
"F1": -1
},
"2": {
"TP": 1,
"FP": 1,
"FN": 2,
"F1": 0.4
}
}
如何计算上述示例的加权 F1 值。我认为应该像这样计算:(0.8*2/3 + 0.4*1/3)/3,但是我错了。