Fix return values for per feat score (#5885)

* Fix return values for per feat score

Convert `PRFScore` to dict as other per type scores.

* Update tests accordingly
This commit is contained in:
Adriane Boyd 2020-08-06 15:14:47 +02:00 committed by GitHub
parent 5d417d3b19
commit 5e683a6e46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View File

@ -242,7 +242,8 @@ class Scorer:
per_feat[field].score_set(
pred_per_feat.get(field, set()), gold_per_feat.get(field, set()),
)
return {f"{attr}_per_feat": per_feat}
result = {k: v.to_dict() for k, v in per_feat.items()}
return {f"{attr}_per_feat": result}
@staticmethod
def score_spans(

View File

@ -259,7 +259,7 @@ def test_tag_score(tagged_doc):
assert results["tag_acc"] == 1.0
assert results["pos_acc"] == 1.0
assert results["morph_acc"] == 1.0
assert results["morph_per_feat"]["NounType"].fscore == 1.0
assert results["morph_per_feat"]["NounType"]["f"] == 1.0
# Gold annotation is modified
scorer = Scorer()
@ -282,9 +282,9 @@ def test_tag_score(tagged_doc):
assert results["tag_acc"] == 0.9
assert results["pos_acc"] == 0.9
assert results["morph_acc"] == approx(0.8)
assert results["morph_per_feat"]["NounType"].fscore == 1.0
assert results["morph_per_feat"]["Poss"].fscore == 0.0
assert results["morph_per_feat"]["Number"].fscore == approx(0.72727272)
assert results["morph_per_feat"]["NounType"]["f"] == 1.0
assert results["morph_per_feat"]["Poss"]["f"] == 0.0
assert results["morph_per_feat"]["Number"]["f"] == approx(0.72727272)
def test_roc_auc_score():