Scoring of textcat output #11129
Answered
by
adrianeboyd
albin02t
asked this question in
Help: Coding & Implementations
Replies: 1 comment
-
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)) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
polm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Can someone show some example of using Scorer.score_cats() and the format of the Example objects to be passed for a single label Text classification model
Beta Was this translation helpful? Give feedback.
All reactions