AIN 311 MACHINE LEARNING BLOG 5— KNN MODEL
This week, we prepared our KNN model. In our CNN models, we had achieved the target accuracy of 70%. In our KNN model, we are reaching the targeted accuracy as well. Now, let me provide you with a bit more detail about our KNN model.
OPTIMAL K CHOICE
As we mentioned before, we divided our dataset into three different groups: train, validation, and test. Using the validation data, we calculated accuracy for different K values. For each K value, we plotted the obtained accuracy values.
As you can see in the graph, we reached the best accuracy when the value of K was 1. Therefore, we assigned the value 1 as the K value for our KNN model and trained the model.
TESTING FOR KNN MODEL
After selecting the optimal K value and completing the training phase, it was time for the testing phase. Once again, using our optimal K value (1), we conducted our testing phase and achieved an accuracy of 0.73. To observe the distribution of correct and incorrect predictions, we utilized the confusion matrix and displayed the distribution of predictions.
DISPLAYING KNN MODEL INCORRECT PREDICTIONS WITH IMAGES
We displayed the predictions made by the KNN model using images. However, since it was not possible to display all predictions, we randomly selected 9 data points and attempted to identify which classes generally experienced mismatches in the predictions.