from sklearn.cluster import KMeans # Import KMeans
model = KMeans(n_clusters=3) # Create a KMeans instance with 3 clusters
model.fit(samples) # Pass the array of a sample to the predict method of the k-mean model
labels = model.predict(samples)
print(labels)
import matplotlib.pyplot as plt # Import pyplot
xs = samples[:, 0] # Assign the columns of samples
ys = samples[:, 1] # Assign the columns of samples
plt.scatter(xs, ys, c=labels,alpha=0.5) # Make a scatter plot of xs and ys, using labels to define the colours
centroids = model.cluster_centers_ # Assign the cluster centers
centroids_x = centroids[:,0] # Assign the columns of centroids
centroids_y = centroids[:,1] # Assign the columns of centroids
plt.scatter(centroids_x, centroids_y, marker='D', s=50)
plt.show()