Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
396 B
3
Indexable
Never

plt.figure(figsize=(8, 6))

for i in range(k):
    plt.scatter(X[y_kmeans == i, 0], X[y_kmeans == i, 1], s=50, label=f'Cluster {i+1}')

plt.scatter(kmeans.cluster_centers_[:, 0], kmeans.cluster_centers_[:, 1], s=200, c='red', marker='X', label='Centroids')
plt.xlabel(iris.feature_names[0])
plt.ylabel(iris.feature_names[1])
plt.title('KMeans Clustering of Iris Dataset')
plt.legend()
plt.show()
Leave a Comment