Hyperparameters
| Parameter | Description | Typical Values |
|---|---|---|
| n_neighbors (k) | Number of neighbors | 3-10, or √n |
| metric | Distance metric | ’euclidean’, ‘manhattan’ |
| weights | Voting weights | ’uniform’, ‘distance’ |
| algorithm | Search algorithm | ’auto’, ‘ball_tree’, ‘kd_tree’, ‘brute’ |
| leaf_size | For tree algorithms | 30 (default) |
Search Algorithms
| Algorithm | Best For | Time Complexity |
|---|---|---|
| Brute Force | Small datasets | O(n) per query |
| KD-Tree | Low dimensions (<20) | O(log n) per query |
| Ball Tree | High dimensions | O(log n) per query |