Figure 3.
Illustration of a kNN classification model. For k = 1, the model will classify the blue query instance as a member of the red class; for k = 3, it will again be assigned to the red class, this time by a 2–1 vote; however, since the fourth and fifth nearest neighbors are both green, a k = 5 model would classify it as part of the green class by a 3–2 majority.