MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / plot_kmeans

Function plot_kmeans

machine_learning/k_means_clust.py:135–145  ·  view source on GitHub ↗
(data, centroids, cluster_assignment)

Source from the content-addressed store, hash-verified

133
134
135def plot_kmeans(data, centroids, cluster_assignment):
136 ax = plt.axes(projection="3d")
137 ax.scatter(data[:, 0], data[:, 1], data[:, 2], c=cluster_assignment, cmap="viridis")
138 ax.scatter(
139 centroids[:, 0], centroids[:, 1], centroids[:, 2], c="red", s=100, marker="x"
140 )
141 ax.set_xlabel("X")
142 ax.set_ylabel("Y")
143 ax.set_zlabel("Z")
144 ax.set_title("3D K-Means Clustering Visualization")
145 plt.show()
146
147
148def kmeans(

Callers 1

k_means_clust.pyFile · 0.85

Calls 1

showMethod · 0.80

Tested by

no test coverage detected