# Nearest Neighbors

A nearest neighbors classifier guesses a new example's class by finding the k training examples closest to it and letting them vote, with KNeighborsClassifier(n_neighbors=5) storing the training rows instead of learning a rule, a small k following every quirk, a large k blurring the classes together, and a tied vote, which in the lesson's run went to the class listed first.

![Cheat sheet: Nearest Neighbors](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/a8dedc0197444604995a948098df2059.webp)

- Category: Machine Learning
- Level: Journeyman
- Tags: ai, Euclidean Distance, Instance-Based Learning, k-Nearest Neighbors, Majority Vote, python
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/ml-nearest-neighbors-cheat-sheet
