course content

Course Content

Python for Data Science: Clustering Demystified

K-Means Model with Two ClustersK-Means Model with Two Clusters

K-means clustering is a method of unsupervised machine learning that groups similar data points together in clusters. The algorithm starts by randomly selecting K initial centroids, where K is the number of clusters desired. Data points are then assigned to the cluster whose centroid is closest to them. The centroids are then recomputed based on the mean of all the data points in the cluster, and the process is repeated until the centroids no longer change. The result is a set of K clusters, with each data point belonging to one cluster. It is widely used for image compression, image segmentation and other applications.


  1. Import the KMeans module;
  2. Cluster our data into 2 clusters.

Everything was clear?

Section 1. Chapter 8