Implement the K-means algorithm and apply it to properly cluster the dataset, as shown in the left panel of Figure 2, using K = cluster centroids. Visualize your results by plotting the dataset and coloring each cluster with a unique color. You may use the Python code given below to create the dataset.
data
cost value
number of clusters
Figure_
1 P = 50 # Number of data points
2 from sklearn import datasets
3 blobs = datasets.make_blobs(n_samples=P, centers=data, np.transpose(blobs[0]))