import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from sklearn import datasets

X, y = datasets.make_moons(n_samples=500)

kmeans = KMeans(n_clusters=5).fit(X)
plt.scatter(X[:, 0], X[:, 1], c=kmeans.labels_.astype(float))
plt.show()

X, y = datasets.make_moons(n_samples=500, noise=0.05)

kmeans = KMeans(n_clusters=5).fit(X)
plt.scatter(X[:, 0], X[:, 1], c=kmeans.labels_.astype(float))
plt.show()

X, y = datasets.make_circles(n_samples=500)

kmeans = KMeans(n_clusters=5).fit(X)
plt.scatter(X[:, 0], X[:, 1], c=kmeans.labels_.astype(float))
plt.show()

X, y = datasets.make_circles(n_samples=500, noise=0.05)

kmeans = KMeans(n_clusters=5).fit(X)
plt.scatter(X[:, 0], X[:, 1], c=kmeans.labels_.astype(float))
plt.show()
