From 1d3ab193223e12bfcb67bca35ce245ef5e63c602 Mon Sep 17 00:00:00 2001 From: Nicki Skafte Date: Tue, 15 Oct 2024 11:40:34 +0200 Subject: [PATCH 1/3] fix --- src/torchmetrics/clustering/calinski_harabasz_score.py | 10 +++++----- .../functional/clustering/calinski_harabasz_score.py | 4 ++-- .../functional/clustering/davies_bouldin_score.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/torchmetrics/clustering/calinski_harabasz_score.py b/src/torchmetrics/clustering/calinski_harabasz_score.py index a9cb9df1c01..483e4332148 100644 --- a/src/torchmetrics/clustering/calinski_harabasz_score.py +++ b/src/torchmetrics/clustering/calinski_harabasz_score.py @@ -56,11 +56,11 @@ class CalinskiHarabaszScore(Metric): Example:: >>> from torch import randn, randint >>> from torchmetrics.clustering import CalinskiHarabaszScore - >>> data = randn(10, 3) - >>> labels = randint(3, (10,)) + >>> data = randn(20, 3) + >>> labels = randint(3, (20,)) >>> metric = CalinskiHarabaszScore() >>> metric(data, labels) - tensor(3.0053) + tensor(2.2128) """ @@ -108,7 +108,7 @@ def plot(self, val: Union[Tensor, Sequence[Tensor], None] = None, ax: Optional[_ >>> import torch >>> from torchmetrics.clustering import CalinskiHarabaszScore >>> metric = CalinskiHarabaszScore() - >>> metric.update(torch.randn(10, 3), torch.randint(0, 2, (10,))) + >>> metric.update(torch.randn(20, 3), torch.randint(3, (20,))) >>> fig_, ax_ = metric.plot(metric.compute()) .. plot:: @@ -120,7 +120,7 @@ def plot(self, val: Union[Tensor, Sequence[Tensor], None] = None, ax: Optional[_ >>> metric = CalinskiHarabaszScore() >>> values = [ ] >>> for _ in range(10): - ... values.append(metric(torch.randn(10, 3), torch.randint(0, 2, (10,)))) + ... values.append(metric(torch.randn(20, 3), torch.randint(3, (20,)))) >>> fig_, ax_ = metric.plot(values) """ diff --git a/src/torchmetrics/functional/clustering/calinski_harabasz_score.py b/src/torchmetrics/functional/clustering/calinski_harabasz_score.py index e28e7f9a9c3..6c742d77280 100644 --- a/src/torchmetrics/functional/clustering/calinski_harabasz_score.py +++ b/src/torchmetrics/functional/clustering/calinski_harabasz_score.py @@ -33,8 +33,8 @@ def calinski_harabasz_score(data: Tensor, labels: Tensor) -> Tensor: Example: >>> from torch import randn, randint >>> from torchmetrics.functional.clustering import calinski_harabasz_score - >>> data = randn(10, 3) - >>> labels = randint(0, 2, (10,)) + >>> data = randn(20, 3) + >>> labels = randint(0, 3, (20,)) >>> calinski_harabasz_score(data, labels) tensor(3.4998) diff --git a/src/torchmetrics/functional/clustering/davies_bouldin_score.py b/src/torchmetrics/functional/clustering/davies_bouldin_score.py index 89ee1bb5d19..18c35f961f9 100644 --- a/src/torchmetrics/functional/clustering/davies_bouldin_score.py +++ b/src/torchmetrics/functional/clustering/davies_bouldin_score.py @@ -33,8 +33,8 @@ def davies_bouldin_score(data: Tensor, labels: Tensor) -> Tensor: Example: >>> from torch import randn, randint >>> from torchmetrics.functional.clustering import davies_bouldin_score - >>> data = randn(10, 3) - >>> labels = randint(0, 2, (10,)) + >>> data = randn(20, 3) + >>> labels = randint(0, 3, (20,)) >>> davies_bouldin_score(data, labels) tensor(1.3249) From fe5dd8c232ac2d1e931e58bcb085958952eb6357 Mon Sep 17 00:00:00 2001 From: Nicki Skafte Detlefsen Date: Tue, 15 Oct 2024 11:47:35 +0200 Subject: [PATCH 2/3] Update src/torchmetrics/functional/clustering/calinski_harabasz_score.py --- .../functional/clustering/calinski_harabasz_score.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/torchmetrics/functional/clustering/calinski_harabasz_score.py b/src/torchmetrics/functional/clustering/calinski_harabasz_score.py index 6c742d77280..7501ff8f15d 100644 --- a/src/torchmetrics/functional/clustering/calinski_harabasz_score.py +++ b/src/torchmetrics/functional/clustering/calinski_harabasz_score.py @@ -36,7 +36,7 @@ def calinski_harabasz_score(data: Tensor, labels: Tensor) -> Tensor: >>> data = randn(20, 3) >>> labels = randint(0, 3, (20,)) >>> calinski_harabasz_score(data, labels) - tensor(3.4998) + tensor(2.2128) """ _validate_intrinsic_cluster_data(data, labels) From 6fbc93a6e346d07f1ce45ac761e32a5fccadfb8b Mon Sep 17 00:00:00 2001 From: Nicki Skafte Detlefsen Date: Tue, 15 Oct 2024 11:47:39 +0200 Subject: [PATCH 3/3] Update src/torchmetrics/functional/clustering/davies_bouldin_score.py --- src/torchmetrics/functional/clustering/davies_bouldin_score.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/torchmetrics/functional/clustering/davies_bouldin_score.py b/src/torchmetrics/functional/clustering/davies_bouldin_score.py index 18c35f961f9..1d6a7222703 100644 --- a/src/torchmetrics/functional/clustering/davies_bouldin_score.py +++ b/src/torchmetrics/functional/clustering/davies_bouldin_score.py @@ -36,7 +36,7 @@ def davies_bouldin_score(data: Tensor, labels: Tensor) -> Tensor: >>> data = randn(20, 3) >>> labels = randint(0, 3, (20,)) >>> davies_bouldin_score(data, labels) - tensor(1.3249) + tensor(2.7418) """ _validate_intrinsic_cluster_data(data, labels)