A Simple Overview of Nearest Neighbour Algorithms

Learning based on observation and regularities

Dinusha Dissanayake
4 min readApr 23, 2022
Source: Unplash by Chang Duong

I’m sure you have heard the term

“You are the average of five people you associate with”

before. Nearest Neighbour technique in data science uses a similar concept. It helps to assign a value to a new data point by assessing the classes/values of its nearest neighbours.

These neighbouring data has known labels. In our example, your five associating persons might be helpful people who go out of their way to aid others. They’re used as training data for this algorithm, which makes it a supervised algorithm. As a result, this algorithm will categorize you also as a helpful person.

In theory, when a data point has a categorical label, we classify it based on the class labels of its closest neighbors. If the nearest neighbors are from different classes, the class of the majority of the neighbors will be assigned.
For instance, out of 5 people you associate with only 4 are helpful people thats the label of majority of people you are with. So you will be assigned as one of them.

When a data point has a numerical value to be assigned, we get the average value of the data point’s nearest neighbours…

--

--