mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-11 17:56:30 +03:00
parent
6b9026a219
commit
26bf642afd
|
@ -175,10 +175,13 @@ def render_parses(
|
|||
def print_prf_per_type(
|
||||
msg: Printer, scores: Dict[str, Dict[str, float]], name: str, type: str
|
||||
) -> None:
|
||||
data = [
|
||||
(k, f"{v['p']*100:.2f}", f"{v['r']*100:.2f}", f"{v['f']*100:.2f}")
|
||||
for k, v in scores.items()
|
||||
]
|
||||
data = []
|
||||
for key, value in scores.items():
|
||||
row = [key]
|
||||
for k in ("p", "r", "f"):
|
||||
v = value[k]
|
||||
row.append(f"{v * 100:.2f}" if isinstance(v, (int, float)) else v)
|
||||
data.append(row)
|
||||
msg.table(
|
||||
data,
|
||||
header=("", "P", "R", "F"),
|
||||
|
@ -191,7 +194,10 @@ def print_textcats_auc_per_cat(
|
|||
msg: Printer, scores: Dict[str, Dict[str, float]]
|
||||
) -> None:
|
||||
msg.table(
|
||||
[(k, f"{v:.2f}") for k, v in scores.items()],
|
||||
[
|
||||
(k, f"{v:.2f}" if isinstance(v, (float, int)) else v)
|
||||
for k, v in scores.items()
|
||||
],
|
||||
header=("", "ROC AUC"),
|
||||
aligns=("l", "r"),
|
||||
title="Textcat ROC AUC (per label)",
|
||||
|
|
12
spacy/tests/regression/test_issue7019.py
Normal file
12
spacy/tests/regression/test_issue7019.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from spacy.cli.evaluate import print_textcats_auc_per_cat, print_prf_per_type
|
||||
from wasabi import msg
|
||||
|
||||
|
||||
def test_issue7019():
|
||||
scores = {"LABEL_A": 0.39829102, "LABEL_B": 0.938298329382, "LABEL_C": None}
|
||||
print_textcats_auc_per_cat(msg, scores)
|
||||
scores = {
|
||||
"LABEL_A": {"p": 0.3420302, "r": 0.3929020, "f": 0.49823928932},
|
||||
"LABEL_B": {"p": None, "r": None, "f": None},
|
||||
}
|
||||
print_prf_per_type(msg, scores, name="foo", type="bar")
|
Loading…
Reference in New Issue
Block a user