K-Nearest Neighbor(KNN)


  1. Definition
  2. Working of K-NN
  3. Distance Metrics in K-NN
  4. Advantages of K-NN
  5. Disadvantage of K-NN
  6. Application of K-NN
  7. References

Definition :-

K-Nearest Neighbors

Working Of K-NN

K-Nearest Neighbors working

Distance Metrics in K-NN :-

  1. Euclidean Distance :- It is used to represent the shortest distance between the two points.
Euclidean Distance Equation
Manhattan Distance Equation


  1. K-NN is robust to noisy training data.
  2. K-NN is a simple, easy to interpret and understand Algorithm.
  3. There is no assumption about data in K-NN, so it is very useful for non-linear data.
  4. It has no training step because it does not explicitly build any model. New data are classified to the majority class based on the nearest neighbor.
  5. Since K-NN does not require training before making predictions, new data can be added seamlessly.

Disadvantages :-

  1. K-NN has no capability to deal with missing value.
  2. Main problem with this algorithm is to choose the optimal value of K.
  3. K-NN is a slow algorithm because as the size of the dataset will increases its speed will decline.
  4. As the number of variables grows K-NN finds it difficult to predict the output of new data points.
  5. K-NN is very sensitive to outliers and it also does not perform well on imbalanced data.

Application of K-NN Algorithm :-

  • Used for pattern recognition.
  • Used in Finance as well as in Agricultural Fields.
  • Used for Facial Recognition, Fingerprint detection.
  • Used for gene expression, protein-protein predictions.

References :-

  • Wikipedia
  • TutorialsPoint
  • Few Other sources




Machine Learning Enthusiast. LinkendIn: https://www.linkedin.com/in/imakash3011/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Benefits of Using Kafka to Handle Real-time Data Streams

How can we digitize the experience?

Chem: Dimensionality Reduction & Clustering

Forget Complex Traditional Approaches to handle NLP Datasets, HuggingFace Dataset Library is your…


A compilation of online education platforms

World’s Opinion Page — and COVID 19!

Data Scientist Vs Machine Learning Engineer: Which Career option to Choose?

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akash Patel

Akash Patel

Machine Learning Enthusiast. LinkendIn: https://www.linkedin.com/in/imakash3011/

More from Medium

Evaluation Metrics for Classification- beyond Accuracy

Confusion Matrices for Evaluating 4-Key Classifier Performance with problem sovled.

Predicting Patient No-Shows

Predicting Landslide Fatalities with a Random Forest Regression Model