how can I pass some nodes as init in sklearn.kmeans(n_clusters,init,....) in python

126 Views Asked by At

how can I pass 2 nodes as centroids to sklearn.kmeans(n_clusters,init,....) instead of random or kmeans++? algorithms['kmeans'] = KMeans(n_clusters=k_clusters,init='random', n_init=200)

1

There are 1 best solutions below

6
sotmot On BEST ANSWER

sklearn also allows users to input centroids of shape (n_clusters, n_features).

The documentation: https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html

For less than n_clusters, you could use random initialization and pass it.