Skip to content Skip to sidebar Skip to footer

Spacy 3 Ner Scorer() Throws Typeerror: Score() Takes 2 Positional Arguments But 3 Were Given

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.t

Solution 1:

Since spaCy v3, scorer.score just takes a list of examples. Each Exampleobject holds two Doc objects:

  • one reference doc with the gold-standard annotations, created for example from the given annot dictionary
  • one predicted doc with the predictions. The scorer will then compare the two.

So you want something like this:

from spacy.training import Example
examples = []
for ...:
    example = Example.from_dict(text, {"entities": annot})
    example.predicted = ner_model(example.predicted)
    examples.append(example)
scorer.score(examples)

Post a Comment for "Spacy 3 Ner Scorer() Throws Typeerror: Score() Takes 2 Positional Arguments But 3 Were Given"