kmeans clustering centroid
The KMeans clustering algorithm can be used to cluster observed data automatically. All of its centroids are stored in the attribute cluster_centers.
In this article we’ll show you how to plot the centroids.
Related course:
KMeans cluster centroids
We want to plot the cluster centroids like this:
First thing we’ll do is to convert the attribute to a numpy array:
centers = np.array(kmeans_model.cluster_centers_) |
This array is one dimensional, thus we plot it using:
plt.scatter(centers[:,0], centers[:,1], marker="x", color='r') |
We can plot the cluster centroids using the code below.
# clustering dataset |
Posted in Machine Learning