Skip to contentScholarGate
LibraryBookshelfDeskReview StudioAssistant
Sign in
On this page
IntuitionHow it worksWhen to use itStrengths & limitationsCommon pitfallsApplicationsFrequently asked🔒 Read the full methodSourcesRelated methods
Cite this pageSpotted an issue on this page? Report or suggest a fix →
Home›Machine learning›K-Nearest Neighbors
Machine learning

K-Nearest Neighbors

K-Nearest Neighbors (KNN) Classification and Regression · Also known as: KNN, K-En Yakın Komşu (KNN), nearest neighbor classifier, instance-based learning

K-Nearest Neighbors (KNN), formalized by Cover and Hart in 1967, is a non-parametric, instance-based method that classifies or predicts a new observation by looking at the k closest examples in the training data. For classification it takes a majority vote among those neighbors; for regression it averages their values.

ScholarGate
  1. Machine learning
  2. v1
  3. 1 Sources
  4. PUBLISHED
Cite this page →
Tools & resources
Download slides
Learn & explore

Read the full method

Members only

Sign in with a free account to read this section.

Sign in

Method map

The neighbourhood of related methods — select a node to explore.

K-Nearest Neighbors
Decision TreeLogistic RegressionNaive BayesRandom ForestSupport Vector MachineLinear Discriminant Anal…Support Vector Regression

When to use it

Use KNN for classification or prediction on tabular data with continuous, binary, or ordinal features and at least about 30 observations. It assumes no particular distribution, but it does require that features be normalized and that the number of features stay small relative to the sample size (p far less than n is preferred). In small or high-dimensional samples the curse of dimensionality dominates — neighbor distances become uninformative — and a parametric model such as logistic regression or Naive Bayes is the better choice.

Strengths & limitations

Strengths
  • Conceptually simple and easy to explain: no training-time equation, the data is the model.
  • Non-parametric — makes no assumption about the underlying distribution.
  • Naturally handles multi-class problems and complex, nonlinear decision boundaries.
  • Works for both classification and regression with the same basic idea.
Limitations
  • Sensitive to feature scaling; without standardization, large-scale features dominate the distance.
  • Degrades quickly in high dimensions (curse of dimensionality), where neighbor distances lose meaning.
  • Every prediction requires scanning the whole training set, which is slow at prediction time on large data.
  • Needs at least a moderate sample size; in small samples nearest-neighbor distances are not meaningful.

Frequently asked

How do I choose the value of k?

k should be selected with cross-validation rather than guessed — for example by trying a range of values and using the elbow method to find where error stops improving. A small k follows the data closely but is noise-sensitive, while a larger k smooths the decision boundary.

Why must I standardize the features?

KNN decides who is 'nearest' using distance, which is scale-sensitive. If one feature is on a much larger numeric scale than the others, it dominates the distance and distorts the neighbor set. Standardizing features (for example with a StandardScaler) is required so each feature contributes fairly.

Why does KNN struggle with many features?

In high-dimensional spaces all points become roughly equidistant — the curse of dimensionality — so 'nearest' neighbors are no longer meaningfully close. KNN performance drops quickly, and a parametric model such as Naive Bayes or logistic regression is usually preferable. Keeping p far smaller than n helps.

Is there a training step?

Not in the usual sense. KNN is instance-based (lazy): it simply stores the training data and does all the work at prediction time, when it computes distances to find the nearest neighbors of a new point.

Sources

  1. Cover, T.M. & Hart, P.E. (1967). Nearest Neighbor Pattern Classification. IEEE Transactions on Information Theory, 13(1), 21–27. DOI: 10.1109/TIT.1967.1053964 ↗

How to cite this page

ScholarGate. (2026, June 1). K-Nearest Neighbors (KNN) Classification and Regression. ScholarGate. https://scholargate.app/en/machine-learning/knn

Related methods

Decision TreeLogistic RegressionNaive BayesRandom ForestSupport Vector Machine

Which method?

Set this method beside its closest kin and read them side by side — the library lays the books on the table; the choice is yours.

  • Decision TreeMachine learning↔ compare
  • Logistic RegressionResearch Statistics↔ compare
  • Naive BayesMachine learning↔ compare
  • Random ForestMachine learning↔ compare
  • Support Vector MachineMachine learning↔ compare
Compare side by side →

Referenced by

Linear Discriminant Analysis (Classification)Support Vector MachineSupport Vector Regression

Similar methods

Regularized k-nearest neighborsEnsemble K-nearest neighborsBayesian k-nearest neighborsExplainable K-Nearest NeighborsSemi-supervised K-nearest neighborsActive learning K-nearest neighborsOnline K-nearest neighborsK-Means Clustering

Related reference concepts

Classification AlgorithmsK-Means ClusteringCross-ValidationSupport Vector ClassificationClassification and Discriminant AnalysisSupervised Learning

Spotted an issue on this page? Report or suggest a fix →

ScholarGate — K-Nearest Neighbors (K-Nearest Neighbors (KNN) Classification and Regression). Retrieved 2026-07-20 from https://scholargate.app/en/machine-learning/knn · Dataset: https://doi.org/10.5281/zenodo.20539026
Quick facts
Originator
Cover, T.M. & Hart, P.E.
Year
1967
Type
Instance-based (non-parametric) learning
Task
Classification & regression
Related methods
Decision TreeLogistic RegressionNaive BayesRandom ForestSupport Vector Machine
ScholarGate

A content-first reference library for research methods — what each one is, how it works, and where it comes from.

Open data (CC-BY)

Explore

  • Library
  • Search the library…
  • Browse by field
  • Fields
  • Journey
  • Compare
  • Which method?

Reference

  • Subjects
  • Atlas
  • Glossary
  • Methodology
  • Philosophy

Your tools

  • Bookshelf
  • Desk
  • Chat

Company

  • About
  • Pricing
  • Contact
  • Suggest a method

Entries are compiled from published sources for reference. Verifying the accuracy and suitability of any information for your own use remains your responsibility.

© 2026 ScholarGate · A research-method reference library
  • Privacy
  • Cookies
  • Terms
  • Delete account