Overview
K-Nearest Neighbors stores examples and answers new queries by finding nearby examples under a distance measure.
Predicts from the labels or values of the closest training examples.
Compact metadata for implementation and discovery.
K-Nearest Neighbors stores examples and answers new queries by finding nearby examples under a distance measure.
Quick facts
Runtime and memory behavior at a glance.
Best
O(d)
Average
O(nd)
Worst
O(nd)
Space
O(n)
distance(a, b) = sqrt(sum((a_i - b_i)^2))Measures closeness between a query point and stored examples.
Show a query point surrounded by its closest examples.
K-Nearest Neighbors operates in O(nd) time and O(n) space within the Instance-Based Learning family. Key governing relation: distance(a, b) = sqrt(sum((a_i - b_i)^2)). Often compared with Naive Bayes and DBSCAN.
What each reference supports for this entry.
Statistical learning reference for the model family and tradeoffs of K-Nearest Neighbors.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
k-nearest neighbors and Naive Bayes are baseline classifiers with very different modeling assumptions.