Re: [R] k-nearest neighbour classification

2015-10-13 Thread Adams, Jean
Ah, I see what you're after. I don't know of a built in function to search for the best number of nearest neighbors. You may have to run the code for each k separately, then compare the resulting errors. Jean On Tue, Oct 13, 2015 at 9:13 AM, Neverstop wrote: > I know that knn.cv(train=predict

Re: [R] k-nearest neighbour classification

2015-10-13 Thread Neverstop
I know that knn.cv(train=predictors.training, cl=classes.training, k=3, prob=TRUE) works but by doing so I fix the tuning paramer k to be 3. Isn't cross validation a technique to choose the optimal tuning parameter trying a range of different values for the tuning parameter? -- View this messag

Re: [R] k-nearest neighbour classification

2015-10-13 Thread Adams, Jean
The argument k should be a scalar, not a vector. So, for example, this works: knn.cv(train=predictors.training, cl=classes.training, k=3, prob=TRUE) Jean On Tue, Oct 13, 2015 at 3:59 AM, Neverstop wrote: > Hi, I'm trying to perform a cross validation to choose the optimal k in the > k-neares

[R] k-nearest neighbour classification

2015-10-13 Thread Neverstop
Hi, I'm trying to perform a cross validation to choose the optimal k in the k-nearest-neighbors algorithm for classification. I'm using the knn function of the package class. Reading the R documentation, I've found out that there