spaCy/spacy
Adriane Boyd 2bcceb80c4
Refactor the Scorer to improve flexibility (#5731)
* Refactor the Scorer to improve flexibility

Refactor the `Scorer` to improve flexibility for arbitrary pipeline
components.

* Individual pipeline components provide their own `evaluate` methods
that score a list of `Example`s and return a dictionary of scores
* `Scorer` is initialized either:
  * with a provided pipeline containing components to be scored
  * with a default pipeline containing the built-in statistical
    components (senter, tagger, morphologizer, parser, ner)
* `Scorer.score` evaluates a list of `Example`s and returns a dictionary
of scores referring to the scores provided by the components in the
pipeline

Significant differences:

* `tags_acc` is renamed to `tag_acc` to be consistent with `token_acc`
and the new `morph_acc`, `pos_acc`, and `lemma_acc`
* Scoring is no longer cumulative: `Scorer.score` scores a list of
examples rather than a single example and does not retain any state
about previously scored examples
* PRF values in the returned scores are no longer multiplied by 100

* Add kwargs to Morphologizer.evaluate

* Create generalized scoring methods in Scorer

* Generalized static scoring methods are added to `Scorer`
  * Methods require an attribute (either on Token or Doc) that is
used to key the returned scores

Naming differences:

* `uas`, `las`, and `las_per_type` in the scores dict are renamed to
`dep_uas`, `dep_las`, and `dep_las_per_type`

Scoring differences:

* `Doc.sents` is now scored as spans rather than on sentence-initial
token positions so that `Doc.sents` and `Doc.ents` can be scored with
the same method (this lowers scores since a single incorrect sentence
start results in two incorrect spans)

* Simplify / extend hasattr check for eval method

* Add hasattr check to tokenizer scoring
* Simplify to hasattr check for component scoring

* Reset Example alignment if docs are set

Reset the Example alignment if either doc is set in case the
tokenization has changed.

* Add PRF tokenization scoring for tokens as spans

Add PRF scores for tokens as character spans. The scores are:

* token_acc: # correct tokens / # gold tokens
* token_p/r/f: PRF for (token.idx, token.idx + len(token))

* Add docstring to Scorer.score_tokenization

* Rename component.evaluate() to component.score()

* Update Scorer API docs

* Update scoring for positive_label in textcat

* Fix TextCategorizer.score kwargs

* Update Language.evaluate docs

* Update score names in default config
2020-07-25 12:53:02 +02:00
..
cli Refactor the Scorer to improve flexibility (#5731) 2020-07-25 12:53:02 +02:00
displacy Remove object subclassing 2020-07-12 14:03:23 +02:00
gold Refactor the Scorer to improve flexibility (#5731) 2020-07-25 12:53:02 +02:00
lang Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00
matcher Remove object subclassing 2020-07-12 14:03:23 +02:00
ml Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00
pipeline Refactor the Scorer to improve flexibility (#5731) 2020-07-25 12:53:02 +02:00
syntax Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00
tests Refactor the Scorer to improve flexibility (#5731) 2020-07-25 12:53:02 +02:00
tokens Minor refactor for Morphology and MorphAnalysis (#5804) 2020-07-24 09:28:06 +02:00
__init__.pxd * Seems to be working after refactor. Need to wire up more POS tag features, and wire up save/load of POS tags. 2014-10-24 02:23:42 +11:00
__init__.py Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00
__main__.py Tidy up 2020-06-22 00:45:40 +02:00
about.py Set version to v3.0.0a4 2020-07-10 22:40:12 +02:00
attrs.pxd Merge branch 'develop' into master-tmp 2020-05-21 18:39:06 +02:00
attrs.pyx Merge branch 'develop' into master-tmp 2020-05-21 18:39:06 +02:00
compat.py Merge branch 'develop' into refactor/remove-symlinks 2020-02-18 17:22:20 +01:00
default_config.cfg Refactor the Scorer to improve flexibility (#5731) 2020-07-25 12:53:02 +02:00
errors.py @factories -> factory (#5801) 2020-07-22 17:29:31 +02:00
glossary.py unicode -> str consistency 2020-05-24 17:20:58 +02:00
gold.pyx Improve spacy.gold (no GoldParse, no json format!) (#5555) 2020-06-26 19:34:12 +02:00
kb.pxd Tidy up compiler flags and imports (#5071) 2020-03-02 11:48:10 +01:00
kb.pyx Merge branch 'develop' into master-tmp 2020-06-20 15:52:00 +02:00
language.py Refactor the Scorer to improve flexibility (#5731) 2020-07-25 12:53:02 +02:00
lemmatizer.py Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00
lexeme.pxd Merge branch 'develop' into master-tmp 2020-05-21 18:39:06 +02:00
lexeme.pyx Merge branch 'develop' into master-tmp 2020-07-20 14:58:04 +02:00
lookups.py Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00
morphology.pxd Update Morphology to load exceptions as MORPH_RULES 2020-07-16 21:16:49 +02:00
morphology.pyx Minor refactor for Morphology and MorphAnalysis (#5804) 2020-07-24 09:28:06 +02:00
parts_of_speech.pxd Add support for Universal Dependencies v2.0 2017-03-03 13:17:34 +01:00
parts_of_speech.pyx Drop Python 2.7 and 3.5 (#4828) 2019-12-22 01:53:56 +01:00
pipe_analysis.py Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00
schemas.py Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00
scorer.py Refactor the Scorer to improve flexibility (#5731) 2020-07-25 12:53:02 +02:00
strings.pxd Tidy up compiler flags and imports (#5071) 2020-03-02 11:48:10 +01:00
strings.pyx unicode -> str consistency [ci skip] 2020-05-24 18:51:10 +02:00
structs.pxd Merge branch 'develop' into master-tmp 2020-05-21 18:39:06 +02:00
symbols.pxd Merge branch 'develop' into master-tmp 2020-05-21 18:39:06 +02:00
symbols.pyx Merge branch 'develop' into master-tmp 2020-05-21 18:39:06 +02:00
tokenizer.pxd Remove dead and/or deprecated code (#5710) 2020-07-06 13:06:25 +02:00
tokenizer.pyx Refactor the Scorer to improve flexibility (#5731) 2020-07-25 12:53:02 +02:00
typedefs.pxd Update spaCy for thinc 8.0.0 (#4920) 2020-01-29 17:06:46 +01:00
typedefs.pyx Tidy up rest 2017-10-27 21:07:59 +02:00
util.py Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00
vectors.pyx Remove object subclassing 2020-07-12 14:03:23 +02:00
vocab.pxd Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00
vocab.pyx Refactor pipeline components, config and language data (#5759) 2020-07-22 13:42:59 +02:00