Skip to content

Commit 10d4cab

Browse files
committed
PEP8
1 parent c83adb5 commit 10d4cab

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

sklearn/cluster/k_means_.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,8 @@ def _init_centroids(X, k, init, random_state=None, x_squared_norms=None,
553553

554554
if len(centers) != k:
555555
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))
558558

559559
return centers
560560

@@ -845,7 +845,7 @@ def _mini_batch_step(X, x_squared_norms, centers, counts,
845845
random_state = check_random_state(random_state)
846846
# Reassign clusters that have very low counts
847847
to_reassign = np.logical_or((counts <= 1),
848-
counts <= .001 * counts.max())
848+
counts <= .001 * counts.max())
849849
# Pick new clusters amongst observations with a probability
850850
# proportional to their closeness to their center
851851
distance_to_centers = np.asarray(centers[nearest_center] - X)
@@ -861,7 +861,6 @@ def _mini_batch_step(X, x_squared_norms, centers, counts,
861861
new_centers = X[new_centers]
862862
centers[to_reassign] = new_centers
863863

864-
865864
# implementation for the sparse CSR reprensation completely written in
866865
# cython
867866
if sp.issparse(X):
@@ -1175,8 +1174,8 @@ def fit(self, X, y=None):
11751174
self.cluster_centers_, self.counts_,
11761175
old_center_buffer, tol > 0.0, distances=distances,
11771176
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)
11801179

11811180
# Monitor convergence and do early stopping if necessary
11821181
if _mini_batch_convergence(
@@ -1226,7 +1225,7 @@ def partial_fit(self, X, y=None):
12261225
# The lower the minimum count is, the more we do random
12271226
# reassignement, however, we don't want to do random
12281227
# 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 +
12301229
self.counts_.min())) == 0
12311230

12321231
_mini_batch_step(X, x_squared_norms, self.cluster_centers_,

0 commit comments

Comments
 (0)