mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 00:46:28 +03:00
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:
parent
5d417d3b19
commit
5e683a6e46
|
@ -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(
|
||||
|
|
|
@ -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():
|
||||
|
|
Loading…
Reference in New Issue
Block a user