k-nearest-neighbor implementation in python