Skip to content

Instantly share code, notes, and snippets.

@jetnew
Created June 1, 2019 18:16
Show Gist options
  • Save jetnew/b5b45540cb2d0920539d7ab5b179e379 to your computer and use it in GitHub Desktop.
Save jetnew/b5b45540cb2d0920539d7ab5b179e379 to your computer and use it in GitHub Desktop.
K-Means using scikit-learn
from sklearn.cluster import KMeans
clusters = 3
y_pred = KMeans(n_clusters=clusters).fit_predict(X)
plt.scatter(X[:,0], X[:,1], c=y_pred)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment