我有以下代码(从 SpaCy v2 迁移),我想在其中计算给定模型的精度、召回率和 f1 分数:
nlp = spacy.load("my_model")
scorer = Scorer(nlp)
examples = []
for text, annotations in TEST_DATA:
examples.append(Example.from_dict(nlp.make_doc(text), annotations))
results = scorer.score(examples)
print(
"Precision {:0.4f}\tRecall {:0.4f}\tF-score {:0.4f}".format(results['ents_p'], results['ents_r'], results['ents_f'])
)
我试图理解的奇怪事情是为什么它总是返回
Precision 0.0000 Recall 0.0000 F-score 0.0000
我的 TEST_DATA 集与我用来训练相同模型的 TRAIN_DATA 集的形式相同。这是它的样子:
[
(
'Line 106 – for dilution times, the units should be specified', {'entities': [(51, 60, 'ACTION'), (41, 47, 'MODAL'), (11, 40, 'CONTENT'), (0, 8, 'LOCATION')]}
),
(
'It should be indicated what test was applied to verify the normality of distribution.', {'entities': [(13, 22, 'ACTION'), (28, 85, 'CONTENT'), (3, 9, 'MODAL')]}
)
]