mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 17:06:29 +03:00
Report p/r/f out of 100
This commit is contained in:
parent
311e1593e6
commit
f232d8db96
|
@ -30,17 +30,17 @@ class PRFScore:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def precision(self) -> float:
|
def precision(self) -> float:
|
||||||
return self.tp / (self.tp + self.fp + 1e-100)
|
return (self.tp / (self.tp + self.fp + 1e-100)) * 100
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def recall(self) -> float:
|
def recall(self) -> float:
|
||||||
return self.tp / (self.tp + self.fn + 1e-100)
|
return (self.tp / (self.tp + self.fn + 1e-100)) * 100
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fscore(self) -> float:
|
def fscore(self) -> float:
|
||||||
p = self.precision
|
p = self.precision
|
||||||
r = self.recall
|
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]:
|
def to_dict(self) -> Dict[str, float]:
|
||||||
return {"p": self.precision, "r": self.recall, "f": self.fscore}
|
return {"p": self.precision, "r": self.recall, "f": self.fscore}
|
||||||
|
@ -145,10 +145,10 @@ class Scorer:
|
||||||
acc_score.tp += 1
|
acc_score.tp += 1
|
||||||
prf_score.score_set(pred_spans, gold_spans)
|
prf_score.score_set(pred_spans, gold_spans)
|
||||||
return {
|
return {
|
||||||
"token_acc": acc_score.fscore,
|
"token_acc": acc_score.fscore * 100,
|
||||||
"token_p": prf_score.precision,
|
"token_p": prf_score.precision * 100,
|
||||||
"token_r": prf_score.recall,
|
"token_r": prf_score.recall * 100,
|
||||||
"token_f": prf_score.fscore,
|
"token_f": prf_score.fscore * 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
Loading…
Reference in New Issue
Block a user