1from sklearn.cluster import KMeans
2df = np.array([[1,4],[2,2],[2,5],[3,3],[3,4],[4,7],[5,6],[6,4],[6,7],[7,6],[7,9],[8,7],[8,9],[9,4],[9,8]])
3kmeans = KMeans(n_clusters=3, init='k-means++', max_iter=300, n_init=10)
4y_pred = kmeans.fit_predict(df)