k-Nearest Neighbors

Predicts from the labels or values of the k closest training observations.

Method

Choose distance metric and k; index training vectors; retrieve neighbors; vote or distance-weight predictions.

Applications

Recommendation, similarity search, anomaly detection, medical decision support.

Advantages

Simple, non-parametric, adapts to local patterns.

Limitations

Inference can be slow; distance loses meaning in high dimensions; sensitive to scaling.

Alternatives

Metric learning, approximate nearest-neighbor search, SVM, tree models.

Example

New flower with petal 5cm: neighbours mostly setosa -> classify setosa.

Sources

Educational reference only, not professional advice.

All algorithms