1

I have seen in the documents of spacy that confidence score of NER entities are rolled out in recent version. I am using spacy==3.1.2. I tried the following code to find the confidence score but i am getting an error. Also is it possible to find the confidence score for both custom and pretrained model.

Code

nlp = spacy.load("output/model-best")
test_data = 'Sample data here'
doc = nlp(test_data)
spans = doc.spans["spancat"] # SpanGroup
print(spans.attrs["scores"]) # list of numbers, span length as SpanGroup

Error

KeyError: 'spancat'

1 Answers1

0

Entity scores are only available if you use the spancat component. I am not sure what your code is supposed to do but that's not how you use the spancat component, you need to train a pipeline with it.

The pretrained pipeline uses the EntityRecognizer/ner component, which does not support confidence scores.

polm23
  • 14,456
  • 7
  • 35
  • 59
  • the code is edited. I loaded the trained model and need to predict the entities in test data. I a, trying to get the confidence score of each predicted entitiy. –  Oct 22 '21 at 09:34