MCPcopy
hub / github.com/explosion/spaCy / evaluate_cli

Function evaluate_cli

spacy/cli/evaluate.py:19–84  ·  view source on GitHub ↗

Evaluate a trained pipeline. Expects a loadable spaCy pipeline and evaluation data in the binary .spacy format. The --gold-preproc option sets up the evaluation examples with gold-standard sentences and tokens for the predictions. Gold preprocessing helps the annotations align to th

(
    # fmt: off
    model: str = Arg(..., help="Model name or path"),
    data_path: Path = Arg(
        ..., help="Location of binary evaluation data in .spacy format", exists=True
    ),
    output: Optional[Path] = Opt(
        None, "--output", "-o", help="Output JSON file for metrics", dir_okay=False
    ),
    code_path: Optional[Path] = Opt(
        None,
        "--code",
        "-c",
        help="Path to Python file with additional code (registered functions) to be imported",
    ),
    use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"),
    gold_preproc: bool = Opt(
        False, "--gold-preproc", "-G", help="Use gold preprocessing"
    ),
    displacy_path: Optional[Path] = Opt(
        None,
        "--displacy-path",
        "-dp",
        help="Directory to output rendered parses as HTML",
        exists=True,
        file_okay=False,
    ),
    displacy_limit: int = Opt(
        25, "--displacy-limit", "-dl", help="Limit of parses to render as HTML"
    ),
    per_component: bool = Opt(
        False,
        "--per-component",
        "-P",
        help="Return scores per component, only applicable when an output JSON file is specified.",
    ),
    spans_key: str = Opt(
        "sc", "--spans-key", "-sk", help="Spans key to use when evaluating Doc.spans"
    ),
    # fmt: on
)

Source from the content-addressed store, hash-verified

17)
18@app.command("evaluate")
19def evaluate_cli(
20 # fmt: off
21 model: str = Arg(..., help="Model name or path"),
22 data_path: Path = Arg(
23 ..., help="Location of binary evaluation data in .spacy format", exists=True
24 ),
25 output: Optional[Path] = Opt(
26 None, "--output", "-o", help="Output JSON file for metrics", dir_okay=False
27 ),
28 code_path: Optional[Path] = Opt(
29 None,
30 "--code",
31 "-c",
32 help="Path to Python file with additional code (registered functions) to be imported",
33 ),
34 use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"),
35 gold_preproc: bool = Opt(
36 False, "--gold-preproc", "-G", help="Use gold preprocessing"
37 ),
38 displacy_path: Optional[Path] = Opt(
39 None,
40 "--displacy-path",
41 "-dp",
42 help="Directory to output rendered parses as HTML",
43 exists=True,
44 file_okay=False,
45 ),
46 displacy_limit: int = Opt(
47 25, "--displacy-limit", "-dl", help="Limit of parses to render as HTML"
48 ),
49 per_component: bool = Opt(
50 False,
51 "--per-component",
52 "-P",
53 help="Return scores per component, only applicable when an output JSON file is specified.",
54 ),
55 spans_key: str = Opt(
56 "sc", "--spans-key", "-sk", help="Spans key to use when evaluating Doc.spans"
57 ),
58 # fmt: on
59):
60 """
61 Evaluate a trained pipeline. Expects a loadable spaCy pipeline and evaluation
62 data in the binary .spacy format. The --gold-preproc option sets up the
63 evaluation examples with gold-standard sentences and tokens for the
64 predictions. Gold preprocessing helps the annotations align to the
65 tokenization, and may result in sequences of more consistent length. However,
66 it may reduce runtime accuracy due to train/test skew. To render a sample of
67 dependency parses in a HTML file, set as output directory as the
68 displacy_path argument.
69
70 DOCS: https://spacy.io/api/cli#benchmark-accuracy
71 """
72 import_code(code_path)
73 evaluate(
74 model,
75 data_path,
76 output=output,

Callers

nothing calls this directly

Calls 2

import_codeFunction · 0.85
evaluateFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…