Skip to main content

Module k_nearest_neighbors

Module k_nearest_neighbors 

Source
Expand description

k-nearest-neighbours classification.

See the book entry k-nearest neighbours.

Structs§

KNearestNeighbors
Classifies a point by a vote among its k closest training points (Euclidean distance). The model is “lazy”: fitting just stores the data. With distance_weighted each neighbour’s vote counts 1/distance so nearer points matter more (an exact match decides alone). Prediction is brute force, O(n·d) per query; use a k-d tree from the geometry crate for large 2D/3D sets.