SpanCategorizer 中的 Spacy 置信度分数
Spacy Confidence Score in SpanCategorizer
我用 'spancat' 模型训练了一个 Spacy nlp 模型。
为了测试模型,我添加了下面的代码来预测跨度和标签
nlp = spacy.load('output_/model-best')
rest = 'The book was of red colour'
doc1 = nlp(rest)
print(doc1.spans) #To get predicted span
span = doc1.spans['sc'][0]
print(span.label_) # to get label
我怎样才能获得跨度预测的置信度分数?
您可以使用 scores
属性直接从 span 组中获取分数。例如:
doc = nlp("your text here")
spans = doc.spans["sc"]
for span, confidence in zip(spans, spans.attrs["scores"]):
print(span.label_, confidence)
我用 'spancat' 模型训练了一个 Spacy nlp 模型。 为了测试模型,我添加了下面的代码来预测跨度和标签
nlp = spacy.load('output_/model-best')
rest = 'The book was of red colour'
doc1 = nlp(rest)
print(doc1.spans) #To get predicted span
span = doc1.spans['sc'][0]
print(span.label_) # to get label
我怎样才能获得跨度预测的置信度分数?
您可以使用 scores
属性直接从 span 组中获取分数。例如:
doc = nlp("your text here")
spans = doc.spans["sc"]
for span, confidence in zip(spans, spans.attrs["scores"]):
print(span.label_, confidence)