diff --git a/river/metrics/silhouette.py b/river/metrics/silhouette.py index d3c6d0a27d..3c0bb3d05c 100644 --- a/river/metrics/silhouette.py +++ b/river/metrics/silhouette.py @@ -47,7 +47,7 @@ class Silhouette(metrics.base.ClusteringMetric): ... metric.update(x, y_pred, k_means.centers) >>> metric - Silhouette: 0.568058 + Silhouette: 0.32145 References ---------- @@ -65,18 +65,18 @@ def __init__(self): @staticmethod def _find_distance_second_closest_center(centers, x): - distances = {i: math.sqrt(utils.math.minkowski_distance(centers[i], x, 2)) for i in centers} + distances = {i: utils.math.minkowski_distance(centers[i], x, 2) for i in centers} return sorted(distances.values())[-2] def update(self, x, y_pred, centers, w=1.0): - distance_closest_centroid = math.sqrt(utils.math.minkowski_distance(centers[y_pred], x, 2)) + distance_closest_centroid = utils.math.minkowski_distance(centers[y_pred], x, 2) self._sum_distance_closest_centroid += distance_closest_centroid distance_second_closest_centroid = self._find_distance_second_closest_center(centers, x) self._sum_distance_second_closest_centroid += distance_second_closest_centroid def revert(self, x, y_pred, centers, w=1.0): - distance_closest_centroid = math.sqrt(utils.math.minkowski_distance(centers[y_pred], x, 2)) + distance_closest_centroid = utils.math.minkowski_distance(centers[y_pred], x, 2) self._sum_distance_closest_centroid -= distance_closest_centroid distance_second_closest_centroid = self._find_distance_second_closest_center(centers, x)