AI Glossary
K-Nearest Neighbors (KNN)
K-Nearest Neighbors is a machine learning algorithm that makes predictions based on the most similar examples in a dataset.
Overview
Humans often solve problems by looking for similar situations from the past.
If something resembles a previous experience, we naturally use that experience to guide our decision.
K-Nearest Neighbors, commonly called KNN, follows a similar idea.
When a new piece of data appears, the algorithm searches for the most similar examples within the dataset. It then uses those nearby examples to help make a prediction.
The “K” represents how many neighboring examples the model considers.
If most nearby examples belong to a particular category, the new data point is often assigned to that same category.
One reason KNN is frequently taught to beginners is that its logic is easy to understand. Instead of building complex mathematical rules, it relies on similarity between examples.
This makes it an excellent introduction to how machine learning can learn patterns from data.
Why It Matters
KNN demonstrates one of the simplest ways machines can make decisions using data.
It helps learners understand the role of similarity in machine learning.
Real-World Example
A streaming platform might recommend movies by identifying users with viewing habits similar to yours.
Related Concepts
- Classification
- Similarity
- Prediction
- Dataset
- Machine Learning