1
$\begingroup$

I have a big database with 40k recors and 2 classification classes. In this big database the 76% of records belong to the first class.

I've used a 70-30 split partition with stratified sampling, and the K-nn gives the best accuracy on k = 20.

1) Is it too big value for k ?

2) Is it possible that this big value for k is due to the disproportion of the 2 classes in the database , even if i used a stratified sampling ?

$\endgroup$
1
$\begingroup$

There is generally a trade of in k-NN:

  1. k should be large enough to cancel out any noise.

  2. k shouldn't be too large to create big biased boundaries.

One rule of thumb is to select an odd k value to avoid ties in binary class problems. Small and big value of k is subjective to the underlying structure of the data set itself, that's why we check over a range of k values. Both of the above gets settled if done a good job with cross validation. So the most important question you need to focus is:

Have you chosen the right metric for model selection, keeping the imbalance of classes into consideration?

I would recommend you to first identify the class that is more important for you to predict correctly. Then, look at the confusion matrix and ponder upon different metrics (eg. recall, precision etc.) before finalizing a model/ k value.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks so much. If you were forced to use knn and split validation, with the information i wrote in the first post, k=20 can be a good value ? Or it's anyhow too big ? $\endgroup$ – Qwerto May 13 '18 at 16:06
  • 1
    $\begingroup$ It depends on the underlying structure of the data and k = 20 can be a possible solution. One rule of thumb is s to select an odd k value to avoid ties in binary class problems. Also, Small and big value of k is subjective to the data set itself, that's why we check over range of k values. $\endgroup$ – Mankind_008 May 13 '18 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.