This is a tutorial on kNN. Check this my github page also.