# Range of values for hyperparameters of the KNN

Algorithm : Classification by k-nearest neighbors with Euclidean distance (neighbors.KNeighborsClassifier).

Determine the important hyperparameters (2 maximum) that can significantly influence learning outcomes. Also give the range of values that should be tested for each of these hyperparameters in order to make a good fit for the configuration of the classifiers on the Pendigits game.

The hyperparamaters for the KNN might be the number of neighbors and weights. How can we give a range of values that make a good fit?

## 1 Answer

Two hyperparameters are K (i.e. the number of neighbors to consider) and the choice of which Distance Function to employ.

For K, you could iterate from 1 though $$N$$, i.e. the number of datapoints in your dataset. Whether choosing an extremely large number of data points (close to $$N$$) is a sensible thing to do or not, might be a different question, but $$[1,N]$$ is at least the range of all values that you can possibly test in an exhaustive search for fitting your hyperpameters.

For the distance function, you could test distance functions from different families of distance functions. Two commonly mentioned ones are e.g. Euclidean distance and Manhattan distance. But also here, you might consider more than just those two.

• Pay attention that the distance function itself might also involve a hyperparameter. One example in this respect is the Minkowski metric... May 1, 2021 at 9:58