K-Nearest Neighbour Explained-Part 1

Understand how a KNN algorithm works and the science behind the KNN Algorithm Explained with an Experiment!

Paras Varshney
9 min readApr 19, 2020
Source: Voronoi Digram

In this story, we would be taking a deep dive into the “K-Nearest Neighbours Algorithm” or better known as K-NN, and would dig deeper into understanding the core concepts behind its working. We would run some experiments to analyze the key features and also look into how the K-NN algorithm performs on various datasets and what could be the optimal “K-value” for a particular dataset.

Understanding KNN

K-NN is a Supervised machine learning algorithm which means that the input and the output values for the training data are given and the machine learns from these values to predict the output value for a query point vector of d-dimension, Xq. K-NN is a non-parametric method used to solve both Classification and Regression type of problems. The input of the K nearest neighbor is the set of data points termed as training data which has both the input values(x’s) and output labels(y). The output of the KNN algorithm decides whether it is a regression or classification problem.

What are Regression and Classification problems here?

The only difference between a…

--

--

Paras Varshney
Paras Varshney

Written by Paras Varshney

Ex-Data Scientist at LogicAi • Researcher at EganLab

No responses yet