K-means clustering is a type of semi-supervised or unsupervised machine learning, which works with partially labeled or even unlabeled data. As the name suggests, this is a type of clustering algorithm, which tries to form clusters of data points based on a similarity function. This algorithm is quite often confused with k-nearest neighbors. Although both algorithms share the same spirit, they are different from each other.

In k-means clustering, we form k clusters using the given data points based on a similarity metric. The most common form of a similarity metric is the distance between two points in the given space. Points closer to each other are clustered together. Initially, when the algorithm begins, we randomly ...