Skip to content

Commit

Permalink
kmeans completed
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnoitanuj committed Nov 11, 2018
1 parent aef1494 commit eafdea2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Part 4 - Clustering/Section 24 - K-Means Clustering/k-means.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
y_kmeans = kmeans.fit_predict(X)

# Visualizing the clusters
plt.scatter(X[y_kmeans ==0, 0], X[y_kmeans == 0, 1], s = 50, c= 'red', label = 'Cluster 1')
plt.scatter(X[y_kmeans ==1, 0], X[y_kmeans == 1, 1], s = 50, c= 'yellow', label = 'Cluster 2')
plt.scatter(X[y_kmeans ==2, 0], X[y_kmeans == 2, 1], s = 50, c= 'green', label = 'Cluster 3')
plt.scatter(X[y_kmeans ==3, 0], X[y_kmeans == 3, 1], s = 50, c= 'cyan', label = 'Cluster 4')
plt.scatter(X[y_kmeans ==4, 0], X[y_kmeans == 4, 1], s = 50, c= 'magenta', label = 'Cluster 5')
plt.scatter(X[y_kmeans ==0, 0], X[y_kmeans == 0, 1], s = 50, c= 'red', label = 'Cluster 1: Careful')
plt.scatter(X[y_kmeans ==1, 0], X[y_kmeans == 1, 1], s = 50, c= 'yellow', label = 'Cluster 2: Standard')
plt.scatter(X[y_kmeans ==2, 0], X[y_kmeans == 2, 1], s = 50, c= 'green', label = 'Cluster 3: Target')
plt.scatter(X[y_kmeans ==3, 0], X[y_kmeans == 3, 1], s = 50, c= 'cyan', label = 'Cluster 4L Careless')
plt.scatter(X[y_kmeans ==4, 0], X[y_kmeans == 4, 1], s = 50, c= 'magenta', label = 'Cluster 5: Sensible')
plt.scatter(kmeans.cluster_centers_[:,0], kmeans.cluster_centers_[:,1], s = 150, c= 'black', label = 'Centroids')
plt.title('Clusters of clients')
plt.xlabel('Annual Income (k$)')
Expand Down

0 comments on commit eafdea2

Please sign in to comment.