I'm looking to use the k-Nearest Neighbors (kNN) algorithm. What are the possible methods for determining the best K? From what I have read, looking at many different values(say 10-100) should work, but that's a big range.

How can I reduce the range of possible K's I should test?

  • $\begingroup$ Don't you mean k? $\endgroup$
    – DuttaA
    Commented Aug 15, 2018 at 5:58
  • $\begingroup$ You could use GridSerchCV, RandomSearchCV, or BayesianOptimization to find the best hyperparameters if you are using Python $\endgroup$
    – ebrahimi
    Commented Aug 15, 2018 at 6:13
  • 1
    $\begingroup$ The K in kNN is a hyperparameter. You should look for: how to optimize a hyperparameter. $\endgroup$ Commented Aug 15, 2018 at 8:03
  • $\begingroup$ how do you tune any ML algorithm? Do a grid search on a small subset of the data in question. $\endgroup$ Commented Aug 15, 2018 at 14:25
  • $\begingroup$ ebrahimi and Mohammad Athar those both sound like answers not comments. If you post it as an answer then others can vote it up in agreement $\endgroup$
    – kbrose
    Commented Aug 15, 2018 at 16:14


Browse other questions tagged or ask your own question.