What other parameters can we pass into the KMeans method?


#1

Question

In the context of this exercise, what other parameters can we pass into the KMeans method?

Answer

There are several other parameters that you can provide to the KMeans method. Some of them are as follows.

You can utilize the init parameter, which determines how the initial clusters are placed in step 1 of the algorithm. One of the values you can provide for this parameter is “k-means++”, which is an optimization of the algorithm by choosing initial cluster centers in a smart way to speed up convergence.

You can also provide a max_iter parameter, which is the maximum number of iterations of the algorithm for each run. By default, this value is 300.

Another parameter you can utilize is n_init which sets the number of times the K-Means clustering algorithm is run, each time with different initial centroids. By default, the algorithm will run 10 times. The best result of all the runs of the algorithm is chosen and used as the final output.

For more parameters available, you can check out the documentation at scikit-learn’s site, under the sklearn.cluster.KMeans method.