Index Ai Academy
Phase 3 · Machine learning · Models

Nearest neighbors

Predict from the most similar examples.

About 25 minutes · Free account required

Open this lesson Create a free account

Why it matters

"Customers like this one usually..." is the oldest prediction method there is, and k-nearest neighbors makes it precise: find the k most similar customers with known outcomes and go with the majority. It's the logic behind lookalike audiences and "people who bought this also bought", and it's exactly what retrieval does in RAG, just with embeddings and a vector database instead of a customer table.

What you'll be able to do

  • Predict by finding the most similar past examples and letting them vote
  • Explain why scaling is essential for distance-based models
  • Choose k, and see how it trades overfitting against underfitting
  • Connect nearest neighbors to embedding search and lookalike audiences

Before this lesson

Next in this phase: Overfitting and underfitting