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:
Data Science and Machine Learning with Python – Hands On!

KMeans cluster centroids

We want to plot the cluster centroids like this:
 
kmeans centroids

First thing we’ll do is to convert the attribute to a numpy array:

This array is one dimensional, thus we plot it using:

We can plot the cluster centroids using the code below.

Previous Post
Next Post

Leave a Reply