Report p/r/f out of 100

This commit is contained in:
Matthew Honnibal 2020-08-24 17:17:23 +02:00
parent 311e1593e6
commit f232d8db96
1 changed files with 7 additions and 7 deletions

View File

@ -30,17 +30,17 @@ class PRFScore:
@property
def precision(self) -> float:
return self.tp / (self.tp + self.fp + 1e-100)
return (self.tp / (self.tp + self.fp + 1e-100)) * 100
@property
def recall(self) -> float:
return self.tp / (self.tp + self.fn + 1e-100)
return (self.tp / (self.tp + self.fn + 1e-100)) * 100
@property
def fscore(self) -> float:
p = self.precision
r = self.recall
return 2 * ((p * r) / (p + r + 1e-100))
return (2 * ((p * r) / (p + r + 1e-100))) * 100
def to_dict(self) -> Dict[str, float]:
return {"p": self.precision, "r": self.recall, "f": self.fscore}
@ -145,10 +145,10 @@ class Scorer:
acc_score.tp += 1
prf_score.score_set(pred_spans, gold_spans)
return {
"token_acc": acc_score.fscore,
"token_p": prf_score.precision,
"token_r": prf_score.recall,
"token_f": prf_score.fscore,
"token_acc": acc_score.fscore * 100,
"token_p": prf_score.precision * 100,
"token_r": prf_score.recall * 100,
"token_f": prf_score.fscore * 100,
}
@staticmethod