Skip to content

Commit

Permalink
Fix #1767
Browse files Browse the repository at this point in the history
  • Loading branch information
sgugger committed Mar 7, 2019
1 parent ad21ce3 commit d5c8be7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fastai/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def on_epoch_end(self, last_metrics, **kwargs):

def on_train_end(self, **kwargs): self.average = self.avg

@dataclass
class KappaScore(ConfusionMatrix):
"Compute the rate of agreement (Cohens Kappa)."
weights:Optional[str]=None # None, `linear`, or `quadratic`
Expand All @@ -235,7 +236,8 @@ def on_epoch_end(self, last_metrics, **kwargs):
else: raise ValueError('Unknown weights. Expected None, "linear", or "quadratic".')
k = torch.sum(w * self.cm) / torch.sum(w * expected)
return add_metrics(last_metrics, 1-k)


@dataclass
class MatthewsCorreff(ConfusionMatrix):
"Compute the Matthews correlation coefficient."
def on_epoch_end(self, last_metrics, **kwargs):
Expand Down

0 comments on commit d5c8be7

Please sign in to comment.