From 7634812172872090fbf23d2b9adb9478fbd97770 Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Fri, 24 May 2019 14:06:36 +0200 Subject: [PATCH] Document Language.evaluate --- spacy/language.py | 13 +++++++++++++ website/docs/api/language.md | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/spacy/language.py b/spacy/language.py index dab60a421..39d95c689 100644 --- a/spacy/language.py +++ b/spacy/language.py @@ -600,6 +600,19 @@ class Language(object): def evaluate( self, docs_golds, verbose=False, batch_size=256, scorer=None, component_cfg=None ): + """Evaluate a model's pipeline components. + + docs_golds (iterable): Tuples of `Doc` and `GoldParse` objects. + verbose (bool): Print debugging information. + batch_size (int): Batch size to use. + scorer (Scorer): Optional `Scorer` to use. If not passed in, a new one + will be created. + component_cfg (dict): An optional dictionary with extra keyword + arguments for specific components. + RETURNS (Scorer): The scorer containing the evaluation results. + + DOCS: https://spacy.io/api/language#evaluate + """ if scorer is None: scorer = Scorer() if component_cfg is None: diff --git a/website/docs/api/language.md b/website/docs/api/language.md index 47d747775..3245a165b 100644 --- a/website/docs/api/language.md +++ b/website/docs/api/language.md @@ -122,6 +122,25 @@ Update the models in the pipeline. | `losses` | dict | Dictionary to update with the loss, keyed by pipeline component. | | `component_cfg` 2.1 | dict | Config parameters for specific pipeline components, keyed by component name. | +## Language.evaluate {#evaluate tag="method"} + +Evaluate a model's pipeline components. + +> #### Example +> +> ```python +> scorer = nlp.evaluate(docs_golds, verbose=True) +> print(scorer.scores) +> ``` + +| Name | Type | Description | +| -------------------------------------------- | -------- | ------------------------------------------------------------------------------------- | +| `docs_golds` | iterable | Tuples of `Doc` and `GoldParse` objects. | +| `verbose` | bool | Print debugging information. | +| `batch_size` | int | The batch size to use. | +| `scorer` | `Scorer` | Optional [`Scorer`](/api/scorer) to use. If not passed in, a new one will be created. | +| `component_cfg` 2.1 | dict | Config parameters for specific pipeline components, keyed by component name. | + ## Language.begin_training {#begin_training tag="method"} Allocate models, pre-process training data and acquire an optimizer.