Skip to content
Discussion options

You must be logged in to vote
import spacy
from spacy.scorer import Scorer
from spacy.training import Example

nlp = spacy.blank("en")
# load/add your textcat pipe instead

text = "This is a positive text."

# create a reference doc
reference = nlp.make_doc(text)
reference.cats = {"POSITIVE": 1.0}

# create a predicted doc
predicted = nlp(text)
# fake a prediction for this demo since there's no textcat
predicted.cats = {"POSITIVE": 0.95}

example = Example(predicted, reference)

print(Scorer.score_cats([example], attr="cats", labels=["POSITIVE"], multi_label=True, threshold=0.75))

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by polm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat / scorer Feature: Scorer
2 participants