@@ -41,12 +41,13 @@ function kmeans!(alg::Hamerly, containers, design_matrix, k;
4141 @parallelize n_threads ncol chunk_initialize! (alg, containers, centroids, design_matrix)
4242
4343 converged = false
44- niters = 1
44+ niters = 0
4545 J_previous = 0.0
4646 p = containers. p
4747
4848 # Update centroids & labels with closest members until convergence
49- while niters <= max_iters
49+ while niters < max_iters
50+ niters += 1
5051 update_containers! (containers, alg, centroids, n_threads)
5152 @parallelize n_threads ncol chunk_update_centroids! (centroids, containers, alg, design_matrix)
5253 collect_containers (alg, containers, n_threads)
@@ -58,7 +59,7 @@ function kmeans!(alg::Hamerly, containers, design_matrix, k;
5859 @parallelize n_threads ncol chunk_update_bounds! (containers, r1, r2, pr1, pr2)
5960
6061 if verbose
61- # Show progress and terminate if J stopped decreasing.
62+ # Show progress and terminate if J stops decreasing as specified by the tolerance level .
6263 println (" Iteration $niters : Jclust = $J " )
6364 end
6465
@@ -69,7 +70,7 @@ function kmeans!(alg::Hamerly, containers, design_matrix, k;
6970 end
7071
7172 J_previous = J
72- niters += 1
73+
7374 end
7475
7576 @parallelize n_threads ncol sum_of_squares (containers, design_matrix, containers. labels, centroids)
0 commit comments