From 8721849423e42fe99cdd6905aa98b94af446d82b Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Wed, 10 Jul 2019 11:19:28 +0200 Subject: [PATCH] Update Scorer.ents_per_type --- spacy/scorer.py | 19 ++++++++++--------- website/docs/api/scorer.md | 21 +++++++++++---------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/spacy/scorer.py b/spacy/scorer.py index c01353520..b9994e3f2 100644 --- a/spacy/scorer.py +++ b/spacy/scorer.py @@ -92,6 +92,15 @@ class Scorer(object): """RETURNS (float): Named entity accuracy (F-score).""" return self.ner.fscore * 100 + @property + def ents_per_type(self): + """RETURNS (dict): Scores per entity label. + """ + return { + k: {"p": v.precision * 100, "r": v.recall * 100, "f": v.fscore * 100} + for k, v in self.ner_per_ents.items() + } + @property def scores(self): """RETURNS (dict): All scores with keys `uas`, `las`, `ents_p`, @@ -103,17 +112,9 @@ class Scorer(object): "ents_p": self.ents_p, "ents_r": self.ents_r, "ents_f": self.ents_f, + "ents_per_type": self.ents_per_type, "tags_acc": self.tags_acc, "token_acc": self.token_acc, - "ents_per_type": self.__scores_per_ents(), - } - - def __scores_per_ents(self): - """RETURNS (dict): Scores per NER entity - """ - return { - k: {"p": v.precision * 100, "r": v.recall * 100, "f": v.fscore * 100} - for k, v in self.ner_per_ents.items() } def score(self, doc, gold, verbose=False, punct_labels=("p", "punct")): diff --git a/website/docs/api/scorer.md b/website/docs/api/scorer.md index e6a8595fd..2af4ec0ce 100644 --- a/website/docs/api/scorer.md +++ b/website/docs/api/scorer.md @@ -46,13 +46,14 @@ Update the evaluation scores from a single [`Doc`](/api/doc) / ## Properties -| Name | Type | Description | -| ----------- | ----- | -------------------------------------------------------------------------------------------- | -| `token_acc` | float | Tokenization accuracy. | -| `tags_acc` | float | Part-of-speech tag accuracy (fine grained tags, i.e. `Token.tag`). | -| `uas` | float | Unlabelled dependency score. | -| `las` | float | Labelled dependency score. | -| `ents_p` | float | Named entity accuracy (precision). | -| `ents_r` | float | Named entity accuracy (recall). | -| `ents_f` | float | Named entity accuracy (F-score). | -| `scores` | dict | All scores with keys `uas`, `las`, `ents_p`, `ents_r`, `ents_f`, `tags_acc` and `token_acc`. | +| Name | Type | Description | +| ---------------------------------------------- | ----- | ------------------------------------------------------------------------------------------------------------- | +| `token_acc` | float | Tokenization accuracy. | +| `tags_acc` | float | Part-of-speech tag accuracy (fine grained tags, i.e. `Token.tag`). | +| `uas` | float | Unlabelled dependency score. | +| `las` | float | Labelled dependency score. | +| `ents_p` | float | Named entity accuracy (precision). | +| `ents_r` | float | Named entity accuracy (recall). | +| `ents_f` | float | Named entity accuracy (F-score). | +| `ents_per_type` 2.1.5 | dict | Scores per entity label. Keyed by label, mapped to a dict of `p`, `r` and `f` scores. | +| `scores` | dict | All scores with keys `uas`, `las`, `ents_p`, `ents_r`, `ents_f`, `ents_per_type`, `tags_acc` and `token_acc`. |