What does kmax and ks in train.kknn refer to?

Can someone explain to me how train.kknn works? In particular, I am wondering what kmax and ks are? Are they referring to the k of the nearest neighbor model? Or are they referring to the k of k-folds?

I looked up the documentation but did not find anything more specific (https://cran.r-project.org/web/packages/kknn/kknn.pdf).

>Solution :

what kmax and ks are?

kmax is the maximum number of k that you want to test. For example, if you set kmax = 11, train.kknn will try all values of k from 1 to 11 and choose the one that gives the best performance.

ks is a vector that specifies the exact values of k that you want to test. For example, if you set ks = c(3, 5, 7), train.kknn will only try these three values of k and choose the best one.

Are they referring to the k of the nearest neighbor model? Or are they referring to the k of k-folds?

You can specify some parameters when you use train.kknn, such as kmax and ks. They both refer to the k of the nearest neighbor model, not the k of k-folds.

You can examine the examples in the link below;

Train.kkn RDRR

Leave a Reply