Skip to content

Commit d7e2e14

Browse files
committed
update
1 parent 0e97857 commit d7e2e14

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

unsupervised_class/kmeans.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ def cost(X, R, M):
3333

3434
def plot_k_means(X, K, max_iter=20, beta=3.0, show_plots=False):
3535
N, D = X.shape
36-
M = np.zeros((K, D))
3736
# R = np.zeros((N, K))
3837
exponents = np.empty((N, K))
3938

4039
# initialize M to random
41-
for k in range(K):
42-
M[k] = X[np.random.choice(N)]
40+
initial_centers = np.random.choice(N, K, replace=False)
41+
M = X[initial_centers]
4342

4443
costs = []
4544
k = 0

0 commit comments

Comments
 (0)