Why to use odd value of k in knn algorithm


I was studying the knn algorthim on iris data set in which there 150 data point but while I have taken the square root of 150 points I get 12.14 when I have searched the google it said the value of k should be odd but I am unable understand why ?


It is advisible to take odd values for binary classification to avoid the ties i.e. two classes labels achieving the same score.


@Steve so what happens if there is a tie between two class labels.

For eg : i have k =4 and we have two points from class 1 and two points from class 2.In this scenario, should i select class 1 or class 2? .

Your help will be much appreciated!

If i am not wrong either class will be picked on each iteration that we run. That’s the reason it is always advised to choose an odd number for K