applying -means with scikit-learn is quite straightforward herewe apply it to the synthetic data that we used for the preceding plots we instantiate the kmeans classand set the number of clusters we are looking for then we call the fit method with the datain[ ]from sklearn datasets import make_blobs from sklearn cluster import kmeans generate synthetic two-dimensional data xy make_blobs(random_state= build the clustering model kmeans kmeans(n_clusters= kmeans fit(xduring the algorithmeach training data point in is assigned cluster label you can find these labels in the kmeans labels_ attribute if you don' provide n_clustersit is set to by default there is no particular reason why you should use this value unsupervised learning and preprocessing