Search code examples
pythonscikit-learnk-meansadjacency-matrixcomplex-networks

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


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)


Solution

  • 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.