Skip to content

Instantly share code, notes, and snippets.

@ForteXX-2020
Last active January 12, 2021 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ForteXX-2020/3a25846cc40488df9721209c717c91d6 to your computer and use it in GitHub Desktop.
Save ForteXX-2020/3a25846cc40488df9721209c717c91d6 to your computer and use it in GitHub Desktop.
0001_clustering
from pylab import plt, mpl
from sklearn.cluster import KMeans
from sklearn.datasets import make_blobs
x, y = make_blobs(n_samples=200, centers=5,
random_state=500, cluster_std=1.25)
model = KMeans(n_clusters=5, random_state=0)
model.fit(x)
KMeans(n_clusters=5, random_state=0)
y_ = model.predict(x)
plt.figure(figsize=(10, 6))
plt.scatter(x[:, 0], x[:, 1], c=y_, cmap='coolwarm');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment