scikit 加权 f1 分数计算和使用
scikit weighted f1 score calculation and usage
我有一个关于 sklearn.metrics 的 weighted
平均值的问题。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。
其次,我听说 weighted-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
}
}
如何计算上述例子的weighted-F1。我虽然应该是 (0.8*2/3 + 0.4*1/3)/3,但是我错了。
First, if there is any reference that justifies the usage of weighted-F1, I am just curios in which cases I should use weighted-F1.
我没有任何参考资料,但如果您对多标签分类感兴趣,您关心 precision/recall of all 类 ,那么加权的 f1-score 是合适的。如果你有二进制分类,你只关心正样本,那么它可能不合适。
Second, I heard that weighted-F1 is deprecated, is it true?
不,加权 F1 本身并没有被弃用。只有函数接口的某些方面被弃用,回到 v0.16,然后只是为了在以前模棱两可的情况下使其更加明确。 (历史讨论 on github or check out the source code 并在页面中搜索 "deprecated" 以查找详细信息。)
Third, how actually weighted-F1 is being calculated?
来自 f1_score
的文档:
``'weighted'``:
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 分数。
我有一个关于 sklearn.metrics 的 weighted
平均值的问题。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。
其次,我听说 weighted-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
}
}
如何计算上述例子的weighted-F1。我虽然应该是 (0.8*2/3 + 0.4*1/3)/3,但是我错了。
First, if there is any reference that justifies the usage of weighted-F1, I am just curios in which cases I should use weighted-F1.
我没有任何参考资料,但如果您对多标签分类感兴趣,您关心 precision/recall of all 类 ,那么加权的 f1-score 是合适的。如果你有二进制分类,你只关心正样本,那么它可能不合适。
Second, I heard that weighted-F1 is deprecated, is it true?
不,加权 F1 本身并没有被弃用。只有函数接口的某些方面被弃用,回到 v0.16,然后只是为了在以前模棱两可的情况下使其更加明确。 (历史讨论 on github or check out the source code 并在页面中搜索 "deprecated" 以查找详细信息。)
Third, how actually weighted-F1 is being calculated?
来自 f1_score
的文档:
``'weighted'``:
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 分数。