Running into the following error when trying to get scores on my test set using Scorer
TypeError: score() takes 2 positional arguments but 3 were given
import spacy
from spacy.tokens import Span
from spacy import displacy
from spacy.training import *
from spacy.scorer import Scorer
from spacy.util import minibatch, compounding
def evaluate(ner_model, testing_data):
scorer = Scorer()
for input_, annot in testing_data:
doc_gold_text = ner_model.make_doc(input_)
example = Example.from_dict(doc_gold_text, {"entities": annot})
pred_value = ner_model(input_)
return scorer.score(pred_value, example)
print(evaluate(nlp_updated, testing_tagged))
Where testing_tagged:
testing_tagged = [
("Who was Hamlet?", [(8,14,'PERSON')]),
("Have you ever met Rome?", [(18,22,'LOC')])
]
Expected output is where p, r and f are not 0:
{'uas': 0.0, 'las': 0.0, 'las_per_type': {'': {'p': 0.0, 'r': 0.0, 'f': 0.0}}, 'ents_p': 0.0, 'ents_r': 0.0, 'ents_f': 0.0, 'ents_per_type': {'PERSON': {'p': 0.0, 'r': 0.0, 'f': 0.0}, 'LOC': {'p': 0.0, 'r': 0.0, 'f': 0.0}}, 'tags_acc': 0.0, 'token_acc': 100.0, 'textcat_score': 0.0, 'textcats_per_cat': {}}
I initially had this working with the GoldParse function instead of Example.from_dict - but I upgraded to Spacy 3.0.5 and I can't understand why this error is occurring.