[scikit-learn] Using KMeans cluster labels in KNN

Sebastian Raschka se.raschka at gmail.com
Mon Mar 12 06:46:21 EDT 2018


Hi,
If you want to predict the Kmeans cluster membership, you can use Kmeans' predict method instead of training a KNN model on the cluster assignments. This will be computationally more efficient and give you the correct assignment at the borders between clusters.

Best,
Sebastian

> On Mar 12, 2018, at 2:55 AM, prince gosavi <princegosavi12 at gmail.com> wrote:
> 
> Hi,
> I have generated clusters using the KMeans algorithm and would like to use the labels of the model in the KNN.
> 
> I don't have the implementation idea but I can visualize it as
> 
> KNNmodel = KNN.fit(X, KMeansModel.labels_)
> 
> Such that the KNN will predict the cluster the new point belong to.
> 
> -- 
> Regards
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn



More information about the scikit-learn mailing list