@@ -553,8 +553,8 @@ def _init_centroids(X, k, init, random_state=None, x_squared_norms=None,
553
553
554
554
if len (centers ) != k :
555
555
raise ValueError ('The shape of the inital centers (%s) '
556
- 'does not match the number of clusters %i'
557
- % (centers .shape , k ))
556
+ 'does not match the number of clusters %i'
557
+ % (centers .shape , k ))
558
558
559
559
return centers
560
560
@@ -845,7 +845,7 @@ def _mini_batch_step(X, x_squared_norms, centers, counts,
845
845
random_state = check_random_state (random_state )
846
846
# Reassign clusters that have very low counts
847
847
to_reassign = np .logical_or ((counts <= 1 ),
848
- counts <= .001 * counts .max ())
848
+ counts <= .001 * counts .max ())
849
849
# Pick new clusters amongst observations with a probability
850
850
# proportional to their closeness to their center
851
851
distance_to_centers = np .asarray (centers [nearest_center ] - X )
@@ -861,7 +861,6 @@ def _mini_batch_step(X, x_squared_norms, centers, counts,
861
861
new_centers = X [new_centers ]
862
862
centers [to_reassign ] = new_centers
863
863
864
-
865
864
# implementation for the sparse CSR reprensation completely written in
866
865
# cython
867
866
if sp .issparse (X ):
@@ -1175,8 +1174,8 @@ def fit(self, X, y=None):
1175
1174
self .cluster_centers_ , self .counts_ ,
1176
1175
old_center_buffer , tol > 0.0 , distances = distances ,
1177
1176
random_reassign = (iteration_idx + 1 ) % (10 +
1178
- self .counts_ .min ()) == 0 ,
1179
- random_state = self .random_state )
1177
+ self .counts_ .min ()) == 0 ,
1178
+ random_state = self .random_state )
1180
1179
1181
1180
# Monitor convergence and do early stopping if necessary
1182
1181
if _mini_batch_convergence (
@@ -1226,7 +1225,7 @@ def partial_fit(self, X, y=None):
1226
1225
# The lower the minimum count is, the more we do random
1227
1226
# reassignement, however, we don't want to do random
1228
1227
# reassignement to often, to allow for building up counts
1229
- random_reassign = self .random_state .randint (10 * (1 +
1228
+ random_reassign = self .random_state .randint (10 * (1 +
1230
1229
self .counts_ .min ())) == 0
1231
1230
1232
1231
_mini_batch_step (X , x_squared_norms , self .cluster_centers_ ,
0 commit comments