What is K-means?
In Turkish: K-ortalamalar (k-means) · Topic: Math foundations
An unsupervised learning method that splits unlabeled data into k clusters of similar points. Each cluster is represented by a center, which is the average of its members.
How does it work?
First the number of clusters (k) is chosen and k centers are placed at random. Every data point is assigned to its nearest center. Then each center moves to the average position of the points in its cluster. The assign-and-move steps repeat until the centers stop changing noticeably. Because the result can depend on the random starting positions, the algorithm is often run several times with different starts. The number of clusters has to be specified in advance.
Why does it matter?
Being simple, fast and scalable to large datasets, it is widely used for customer segmentation, image compression and exploratory analysis. On the other hand, it assumes clusters are roughly round and similar in size, and results can mislead when that does not hold. Interpreting the clusters is left to the analyst.
Example
An online store might split its customers into four clusters by purchase frequency and basket size, then offer a different campaign to each group.
FAQ
How is k chosen?
Usually several values of k are tried, and approaches such as the elbow method look for the point where the gain in clustering quality levels off. The business context also guides the decision.
Is k-means the same as k-nearest neighbors?
No. K-means clusters unlabeled data (unsupervised), while k-nearest neighbors uses labeled examples to classify or predict (supervised). The k means different things in each.