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`. |