Data, Python, Machine Learning, Data Science, AI.
clusters kmeans = KMeans(n_clusters=3) kmeans.fit(df) # Visualize the clusters plt.scatter(df.iloc[:, 0], df.iloc[:, 1], c=kmeans.labels_, cmap='viridis') plt.scatter(kmeans.cluster_centers_[:, 0], kmeans.cluster_centers_[:, 1], s=300, c='red', label='Centroids') plt.title('K-means Clustering')