What is K-Nearest Neighbors? — AI Glossary

What it is: A model that finds the most similar past cases and copies what happened to them.
Who it is for: Beginners choosing between model types in an AI tool.
Best if: Similar situations tend to produce similar outcomes.
Skip if: Your new data looks nothing like your old data. Want one practical AI workflow every morning? Subscribe to our free daily newsletter.

What is k-nearest neighbors?

It looks at today, finds the handful of past days that most closely resemble it, and reports what happened next on those days. The k is simply how many neighbours it consults.

There is no equation being fitted. It is closer to looking things up than to learning a rule.

Why does it matter?

It copes well when the relationship is not a straight line, and when one global rule cannot serve everything at once. Three different stocks with different volatility mean the same reading means different things, and comparing like with like handles that.

A larger k averages over more cases, which is what a model does when it has found a real regularity rather than memorising noise.

Where it breaks

It only knows the neighbourhoods it was shown. Move it to conditions unlike anything in its training and it will not find close matches, so it either goes quiet or answers with false confidence.

That failure is easy to misread as the model being cautious. It is the model being lost.

Related terms

Learn more on Beginners in AI

Sources and further reading

Last reviewed: August 2026. AI terminology evolves quickly — verify specifics on the official source pages above.

Get Smarter About AI Every Morning

Free daily newsletter — one term, one tool, one tip. Plain English.

Free forever. Unsubscribe anytime.

You may also like

Two ways to go further

The AI Prompt Library

1,000+ ready-to-use prompts for Claude, ChatGPT, and Gemini. Stop staring at a blank box.

Get it for $39 →

2-Hour Live AI Crash Course

A private, beginner-friendly session across Claude, ChatGPT, Gemini, and the wider landscape.

Book for $125 →