【发布时间】:2021-07-12 22:56:46
【问题描述】:
我使用 sklearns crfsuite 计算 f1、精度和召回分数,但出现异常。出于测试目的,我给出了相同的测试和预测值。
from sklearn_crfsuite import scorers
from sklearn_crfsuite import metrics
cls = [i for i, _ in enumerate(CLASSES)]
cls.append(7)
cls.append(8)
print(metrics.flat_classification_report(
test["y"], test["y"], labels=cls, digits=3
))
precision recall f1-score support
0 1.000 1.000 1.000 551
1 0.000 0.000 0.000 0
2 0.000 0.000 0.000 0
3 1.000 1.000 1.000 1196
4 1.000 1.000 1.000 2593
5 1.000 1.000 1.000 95200
6 1.000 1.000 1.000 1165
7 1.000 1.000 1.000 9636
8 1.000 1.000 1.000 506363
micro avg 1.000 1.000 1.000 616704
macro avg 0.778 0.778 0.778 616704
weighted avg 1.000 1.000 1.000 616704
为什么 1 和 2 个标签的分数都为 0。 它应该给出 1 作为其余数据。谁能给我解释一下原因?
需要帮助。提前致谢!
【问题讨论】:
-
你能打印 test["y"] 中的唯一标签吗?
标签: python scikit-learn named-entity-recognition precision-recall