Skip to content

Commit

Permalink
initiate new micro cluster based on the maximum key of the existing m…
Browse files Browse the repository at this point in the history
…icro clusters, or indexed as 0 if the list of micro clusters is still empty.
  • Loading branch information
hoanganhngo610 committed Oct 9, 2023
1 parent 66f3822 commit 7dd9783
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions river/cluster/dbstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,14 @@ def _update(self, x):

if len(neighbor_clusters) < 1:
# create new micro cluster
self._micro_clusters[len(self._micro_clusters)] = DBSTREAMMicroCluster(
x=x, last_update=self._time_stamp, weight=1
)
if len(self._micro_clusters) > 0:
self._micro_clusters[max(self._micro_clusters.keys()) + 1] = DBSTREAMMicroCluster(
x=x, last_update=self._time_stamp, weight=1
)
else:
self._micro_clusters[0] = DBSTREAMMicroCluster(
x=x, last_update=self._time_stamp, weight=1
)
else:
# update existing micro clusters
current_centers = {}
Expand Down

0 comments on commit 7dd9783

Please sign in to comment.