179 questions
No questions match those filters.
How do k-Nearest Neighbors and k-Means differ, beyond b...
This is one of the questions in the full AI/ML interview bank. Pro unlocks all 1789 questions; Premium includes the same bank plus the highest daily Practice limit.
See plansThey solve unrelated problems and only share the superficial trait of a distance-based hyperparameter k. k-NN is supervised: it’s a classification or regression method that requires labeled training data and predicts a new point’s label by looking at the k closest labeled points and taking a majority vote or average. It’s a lazy learner — it does no work at training time beyond storing the data, and pays the full computational cost at prediction time, computing distances to every stored example.
k-Means is unsupervised: it has no labels at all and instead partitions unlabeled data into k groups by iteratively assigning each point to its nearest of k centroids and then recomputing each centroid as the mean of its assigned points, repeating until assignments stop changing. k-NN’s k controls the bias-variance tradeoff of a classifier — small k means low bias/high variance, large k means the opposite. k-Means’ k is the number of clusters you’re asking the algorithm to find, typically chosen with something like an elbow-method plot of within-cluster variance, and has nothing to do with classification accuracy. The confusion is common enough in interviews that just naming it explicitly (supervised vs unsupervised, lazy classifier vs iterative partitioner) is worth stating up front before diving into either algorithm’s details.