Skip to content

Commit

Permalink
solved bug in kmeans
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar Celma committed Jan 13, 2012
1 parent a6d66f5 commit 05f1f43
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion recsys/algorithm/baseclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@ def kmeans(self, id, k=5, is_row=True):
else:
point = self.get_matrix().get_col(id)
points = []
points_id = []
for i in point.nonzero_entries():
label = point.label(i)
points_id.append(label)
if not is_row:
points.append(self.get_matrix().get_row(label))
else:
Expand All @@ -254,7 +256,7 @@ def kmeans(self, id, k=5, is_row=True):
clusters[cluster] = dict()
clusters[cluster]['centroid'] = centroids[cluster]
clusters[cluster]['points'] = []
clusters[cluster]['points'].append(points[i])
clusters[cluster]['points'].append(points_id[i])
i += 1
return clusters

0 comments on commit 05f1f43

Please sign in to comment.