diff --git a/river/cluster/clustream.py b/river/cluster/clustream.py index 858e2f7302..bd66bd17c5 100644 --- a/river/cluster/clustream.py +++ b/river/cluster/clustream.py @@ -236,12 +236,12 @@ def learn_one(self, x, w=1.0): if closest_dist < radius: closest_mc.insert(x, w, self._timestamp) - return + else: - # If the new point does not fit in the micro-cluster, micro-clusters - # whose relevance stamps are less than the threshold are deleted. - # Otherwise, closest micro-clusters are merged with each other. - self._maintain_micro_clusters(x=x, w=w) + # If the new point does not fit in the micro-cluster, micro-clusters + # whose relevance stamps are less than the threshold are deleted. + # Otherwise, closest micro-clusters are merged with each other. + self._maintain_micro_clusters(x=x, w=w) # Apply incremental K-Means on micro-clusters after each time_gap if self._timestamp % self.time_gap == self.time_gap - 1: @@ -260,7 +260,7 @@ def learn_one(self, x, w=1.0): def predict_one(self, x): index, _ = self._get_closest_mc(x) try: - return self._kmeans_mc.predict_one(self._mc_centers[index]) + return self._kmeans_mc.predict_one(self.micro_clusters[index].center) except (KeyError, AttributeError): return 0