A weighted kNN predictor in Python