MCPcopy
hub / github.com/explosion/spaCy / test_evaluate_textcat_multilabel

Function test_evaluate_textcat_multilabel

spacy/tests/test_language.py:132–149  ·  view source on GitHub ↗

Test that evaluate works with a multilabel textcat pipe.

(en_vocab)

Source from the content-addressed store, hash-verified

130
131
132def test_evaluate_textcat_multilabel(en_vocab):
133 """Test that evaluate works with a multilabel textcat pipe."""
134 nlp = Language(en_vocab)
135 textcat_multilabel = nlp.add_pipe("textcat_multilabel")
136 for label in ("FEATURE", "REQUEST", "BUG", "QUESTION"):
137 textcat_multilabel.add_label(label)
138 nlp.initialize()
139
140 annots = {"cats": {"FEATURE": 1.0, "QUESTION": 1.0}}
141 doc = nlp.make_doc("hello world")
142 example = Example.from_dict(doc, annots)
143 scores = nlp.evaluate([example])
144 labels = nlp.get_pipe("textcat_multilabel").labels
145 for label in labels:
146 assert scores["cats_f_per_type"].get(label) is not None
147 for key in example.reference.cats.keys():
148 if key not in labels:
149 assert scores["cats_f_per_type"].get(key) is None
150
151
152def test_evaluate_multiple_textcat_final(en_vocab):

Callers

nothing calls this directly

Calls 9

add_pipeMethod · 0.95
initializeMethod · 0.95
make_docMethod · 0.95
evaluateMethod · 0.95
get_pipeMethod · 0.95
LanguageClass · 0.90
from_dictMethod · 0.80
add_labelMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…