Applying k nearest neighbour