The k-means clustering, as the name suggests, is a technique to cluster data, that is, partition data into a specified number of data points. It is an unsupervised learning technique. It works by identifying patterns in the given data. Remember the sorting hat from Harry Potter fame? What it is doing in the book is clustering--dividing new (unlabeled) students into four different clusters: Gryffindor, Ravenclaw, Hufflepuff, and Slytherin.
Humans are very good at grouping objects together; clustering algorithms try to give a similar capability to computers. There are many clustering techniques available such as Hierarchical, Bayesian, or Partional. The k-means clustering belongs to Partional clustering; it partitions the data into k clusters. Each cluster has a center, called centroid. The number of clusters k has to be specified by the user.
The k-means algorithm...