Contents
Is cross validation necessary for kNN?
The answer is NO. In order to confidently say that we can achieve an accuracy of approximately 90% on future unseen data, I need to first test this model on unseen data.
What is kNN cross validation?
Cross-validation is when the dataset is randomly split up into ‘k’ groups. One of the groups is used as the test set and the rest are used as the training set. The model is trained on the training set and scored on the test set. Then the process is repeated until each unique group as been used as the test set.
How to solve the problem of cross validation?
In order to solve this problem, I introduce you to the concept of cross-validation. In cross-validation, instead of splitting the data into two parts, we split it into 3. Training data, cross-validation data, and test data.
Are there any drawbacks to KNN cross validation?
Now, we are using the entire 80% of our data to compute the nearest neighbors as well as the K value in KNN. Just one drawback with k-fold cross-validation is that we are repeating the computations for each value of K (of KNN). So it basically increases the time complexity.
What is the k value in cross validation?
So, k value in k-fold cross-validation for the above example is 4 (i.e k=4), had we split the training data into 5 equal parts, the value of k=5. k = number of parts we randomly split our training data set into. Now, we are using the entire 80% of our data to compute the nearest neighbors as well as the K value in KNN.
How to use nearest neighbors in a regression?
In a nearest-neighbors model the concepts of “training set” and “test set” do not apply in the same way that they do for a regression. An approximation of the above procedure would be to split the dataset into 10 folds, choose 1 fold as the “test set”, and search for nearest neighbors in the remaining 9 (repeating for each fold).