> ML_ALGORITHM // K-NEAREST-NEIGHBORS_v1.0
k-Nearest Neighbors (k-NN)
Instance-based lazy learning algorithm that assigns labels or values based on majority vote or distance-weighted average of the k closest neighbors.
Instance-Based Learningclassical-supervisedhigh-intrinsicsmall (<1k)
Back to All AlgorithmsComputational Complexity
Training Complexity:O(1) lazy learning
Inference Complexity:O(n * p) linear search or O(log n) via KD-Tree/HNSW
Hardware Profile
CPU Friendly:Yes
Requires GPU:No
Memory Footprint:high
Interpretability & Data
Interpretability Tier:high-intrinsic
Training Data Needs:small (<1k)
Interpretability Assessment
Predictions can be explained by presenting the exact nearest historical neighbor instances.
Suitable Tasks & Supported Modalities
Suitable Tasks:
binary classificationmulticlass classificationregressionimputation
Supported Modalities:
tabularimage
Implementing Libraries
Foundational Literature
Nearest Neighbor Pattern ClassificationThomas M. Cover, Peter E. Hart (1967) · IEEE Transactions on Information Theory
Common Pitfalls & Warnings
- Distance metric collapse in high dimensions (curse of dimensionality)
- Severe inference latency degradation as dataset size grows
