textcat.eval throwing AttributeError: 'TextClassifier' object has no attribute 'label'

I get an AttributeError running textcat.eval

prodigy dataset realestate_eval

  ✨  Successfully added 'realestate_eval' to database SQLite.

prodigy textcat.eval realestate_eval en_core_web_sm comments.txt --label REAL_ESTATE
	Traceback (most recent call last):
	  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 193, in _run_module_as_main
	    "__main__", mod_spec)
	  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", line 85, in _run_code
	    exec(code, run_globals)
	  File "/Users/benjamin/Desktop/prodigy/lib/python3.6/site-packages/prodigy/__main__.py", line 235, in <module>
	    controller = recipe(*args, use_plac=True)
	  File "cython_src/prodigy/core.pyx", line 130, in prodigy.core.recipe.recipe_decorator.recipe_proxy
	  File "/Users/benjamin/Desktop/prodigy/lib/python3.6/site-packages/plac_core.py", line 328, in call
	    cmd, result = parser.consume(arglist)
	  File "/Users/benjamin/Desktop/prodigy/lib/python3.6/site-packages/plac_core.py", line 207, in consume
	    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
	  File "/Users/benjamin/Desktop/prodigy/lib/python3.6/site-packages/prodigy/recipes/textcat.py", line 204, in evaluate
	    'config': {'lang': nlp.lang, 'label': model.label}
	AttributeError: 'TextClassifier' object has no attribute 'label'

I’ve run textcat.teach on comments.txt using en_core_web_sm without any issue

Thanks for the report – I think this might be a typo in the recipe (or probably caused by a change to the model attributes we forgot to adjust in the recipe). Sorry about that! The line should be 'config': {'lang': nlp.lang, 'labels': model.labels}. Will fix this for the next release!

We’ve included the recipe source in Prodigy to make it easier to build and adapt recipe. So in the meantime, you can also just edit it yourself and keep working :blush:

You can find the location of Prodigy by running prodigy stats or importing Prodigy and printing prodigy.__file__. Then just edit line 204 in recipes/textcat.py and change label to labels. You could even leave it out completely, since the 'labels' config is only used to display the label(s) you’re annotating in the web app.

Awesome, that fixed it! Thanks

1 Like