Skip to content

Commit

Permalink
BUG: sparse vs non sparse centers
Browse files Browse the repository at this point in the history
The 'toarray()' method is not present on arrays
  • Loading branch information
GaelVaroquaux committed Jan 31, 2013
1 parent 16244a0 commit 8214100
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sklearn/cluster/k_means_.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,9 @@ def _mini_batch_step(X, x_squared_norms, centers, counts,
if n_reassigns:
print("[_mini_batch_step] Reassigning %i cluster centers."
% n_reassigns)
centers[to_reassign] = new_centers.toarray()
if sp.issparse(new_centers) and not sp.issparse(centers):
new_centers = new_centers.toarray()
centers[to_reassign] = new_centers

# implementation for the sparse CSR reprensation completely written in
# cython
Expand Down

0 comments on commit 8214100

Please sign in to comment.