Page 21 - Data Science Algorithms in a Week
P. 21
Classification Using K Nearest Neighbors
Let us label the grid with distances around the neighbors to see which neighbor with a
known class is closest to the point we would like to classify:
We can see that the closest neighbor with a known class is the one with the temperature 15
(blue) degrees Celsius and the wind speed 5km/h. Its distance from the questioned point is
three units. Its class is blue (cold). The closest red (warm) neighbor is distanced four units
from the questioned point. Since we are using the 1-nearest neighbor algorithm, we just
look at the closest neighbor and, therefore, the class of the questioned point should be blue
(cold).
[ 9 ]