相关疑难解决方法(0)

在Spacy NER模型中进行评估

我正在尝试评估使用spacy lib创建的训练有素的NER模型.通常对于这些问题,您可以使用f1分数(精确度和召回率之间的比率).我在文档中找不到训练有素的NER模型的精确度函数.

我不确定它是否正确,但我尝试使用以下方式(示例)并使用f1_scorefrom sklearn:

from sklearn.metrics import f1_score
import spacy
from spacy.gold import GoldParse


nlp = spacy.load("en") #load NER model
test_text = "my name is John" # text to test accuracy
doc_to_test = nlp(test_text) # transform the text to spacy doc format

# we create a golden doc where we know the tagged entity for the text to be tested
doc_gold_text= nlp.make_doc(test_text)
entity_offsets_of_gold_text = [(11, 15,"PERSON")]
gold = GoldParse(doc_gold_text, entities=entity_offsets_of_gold_text)

# bring the data in …
Run Code Online (Sandbox Code Playgroud)

python spacy

11
推荐指数
2
解决办法
6688
查看次数

标签 统计

python ×1

spacy ×1