Machine Learning Project 11 — Whose my Neighbor? — k Nearest Neighbor
Published in
4 min readSep 11, 2019
Today we will understand the k-Nearest Neighbor (kNN) classification algorithm. It is one of the most easiest algorithms.
#100DaysOfMLCode #100ProjectsInML
- Let’s say we have identified 2 categories in our dataset — say “Red Category 1” and “Green Category 2” as shown below.
- Now let’s say we add a new data point in our dataset as shown below. So the question is — does it belong to “Red Category 1” or “Green Category 2”. How do we classify this new data point?
So this is where the k Nearest Neighbor (kNN) algorithm will come in to assist us. It’s a very simple algorithm.
- First we have to decide on the number of k neighbors — the most common or default value for k is 5.
- Next, we need to find the 5 nearest neighbors to this new data point based on Euclidean distance or Manhattan distance or any other. In layman’s terms, we have to find the 5 data points that are closest…