k-Means vs k-Nearest Neighbors
Both have a k and both measure closeness, so people often swap them. They do different jobs. In k-means, k is how many groups to find in data with no labels. In k-nearest neighbors, k is how many labelled neighbours vote on a new example's group.
k-Means Clustering
It splits data into k groups. It moves k centre points until they stop.
k-means clustering is a method that splits data into k groups, where k is a number you choose. It starts by dropping k centre points at random. Each example joins the group of its nearest centre. Then each centre moves to the middle of its group. These two steps repeat until the centres stop moving.
k-Nearest Neighbors (k-NN)
It finds the closest cases it knows. Then it copies what most of them say.
k-nearest neighbors answers by looking at the closest examples it has stored. For a new example, it finds the k closest ones in the training data, where k is a small number you pick, like 5. If most of those neighbours are in one group, the new example goes in that group too. It does almost no work during training. All the work happens when a question comes in.
In one line
- k-Means Clustering
- It splits data into k groups. It moves k centre points until they stop.
- k-Nearest Neighbors (k-NN)
- It finds the closest cases it knows. Then it copies what most of them say.