From b91a0285c9e1dd66124d9d3fa0f1537e1fa72824 Mon Sep 17 00:00:00 2001 From: SkafteNicki Date: Sat, 26 Jun 2021 13:25:29 +0200 Subject: [PATCH 1/2] fix --- CHANGELOG.md | 2 +- torchmetrics/functional/classification/matthews_corrcoef.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4052f817ab2..e0a38899dd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - AUC can also support more dimensional inputs when all but one dimension are of size 1 ([#242](https://github.com/PyTorchLightning/metrics/pull/242)) - Fixed `dtype` of modular metrics after reset has been called ([#243](https://github.com/PyTorchLightning/metrics/pull/243)) - +- Fixed calculation in `matthews_corrcoef` to correctly match formula (()) ## [0.3.2] - 2021-05-10 diff --git a/torchmetrics/functional/classification/matthews_corrcoef.py b/torchmetrics/functional/classification/matthews_corrcoef.py index 19ccf8dc967..5be0b783440 100644 --- a/torchmetrics/functional/classification/matthews_corrcoef.py +++ b/torchmetrics/functional/classification/matthews_corrcoef.py @@ -20,8 +20,8 @@ def _matthews_corrcoef_compute(confmat: Tensor) -> Tensor: - tk = confmat.sum(dim=0).float() - pk = confmat.sum(dim=1).float() + tk = confmat.sum(dim=1).float() + pk = confmat.sum(dim=0).float() c = torch.trace(confmat).float() s = confmat.sum().float() return (c * s - sum(tk * pk)) / (torch.sqrt(s**2 - sum(pk * pk)) * torch.sqrt(s**2 - sum(tk * tk))) From 0ba97e05cae27fc425bf4e393ee5d6c6a5148f85 Mon Sep 17 00:00:00 2001 From: Nicki Skafte Date: Sat, 26 Jun 2021 13:29:42 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0a38899dd9..864eddea331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,7 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - AUC can also support more dimensional inputs when all but one dimension are of size 1 ([#242](https://github.com/PyTorchLightning/metrics/pull/242)) - Fixed `dtype` of modular metrics after reset has been called ([#243](https://github.com/PyTorchLightning/metrics/pull/243)) -- Fixed calculation in `matthews_corrcoef` to correctly match formula (()) +- Fixed calculation in `matthews_corrcoef` to correctly match formula ([#321](https://github.com/PyTorchLightning/metrics/pull/321)) ## [0.3.2] - 2021-05-10