How to assign an new observation to existing Kmeans clusters based on nearest cluster centriod logic in python?

后端 未结 3 839
长发绾君心
长发绾君心 2021-01-15 02:28

I used the below code to create k-means clusters using Scikit learn.

kmean = KMeans(n_clusters=nclusters,n_jobs=-1,random_state=2376,max_iter=1000,n_init=100         


        
3条回答
  •  失恋的感觉
    2021-01-15 03:03

    This question is a bit old, but kmeans sets a cluster_centers_ parameter when it fits. If you have the centroids you can set it by doing:

    kmeans.cluster_centers_ = centroids_init

    It should be able to fit after this.

提交回复
热议问题