simple knn applied to mnist using numpy
A quick and simple implementation.
TO RUN:
$ python mnist_knn_numpy.py
The program should produce the following output when run unmodified:
We have 1347 items in the training set & 449 items for test
Iteration 00 With k = 01 ==> Result: Accuracy 96.21% (432 correct predictions out of 449)
Iteration 01 With k = 03 ==> Result: Accuracy 97.10% (436 correct predictions out of 449)
Iteration 02 With k = 05 ==> Result: Accuracy 96.44% (433 correct predictions out of 449)
Iteration 03 With k = 07 ==> Result: Accuracy 95.55% (429 correct predictions out of 449)
Iteration 04 With k = 09 ==> Result: Accuracy 95.55% (429 correct predictions out of 449)
Iteration 05 With k = 11 ==> Result: Accuracy 95.77% (430 correct predictions out of 449)
Iteration 06 With k = 17 ==> Result: Accuracy 95.32% (428 correct predictions out of 449)
Iteration 07 With k = 23 ==> Result: Accuracy 95.10% (427 correct predictions out of 449)
Iteration 08 With k = 37 ==> Result: Accuracy 93.76% (421 correct predictions out of 449)
Iteration 09 With k = 49 ==> Result: Accuracy 92.87% (417 correct predictions out of 449)
(We notice that k=3 gives us a 97% accuracy for a 75/25 train/test split in the input data.)