# Is there an upper bound for k in nearest neighbors-based methods?

When applying a nearest neighbors-based method to a data of, for instance, 2000 points, what is the largest number of neighbors that can be considered ? I am using a nearest neighbors method in an unsupervised fashion for anomaly detection.

It's up to you to find the number of neighbors that you want to consider. If you have 2000 data points, this are the 2000 'neighbors' of which you will select a number of k neighbors for taking the average and using that average as prediction.
So the maximum number of k is the number of data points in your training set. In your case this is 2000.
• If you want to know whether your k is well performing, you should define what your performance measure is. For this we should understand what problem you are trying to solve. Please give some more detail on this. Cross-validation is often used to tune hyper parameters. And often this is validated on a test data set which is about 30% of the observations of training data. But again this is a very general remark and it may be irrelevant in your case, especially since you talk about unsupervised methods. – Joos Korstanje Oct 9 '18 at 12:43