K-Nearest Neighbors (KNN) for recognizing handwritten digits

Beijing Institute of Technology | Ming-Jian Li

The following Python code is a companion code for the course on Artificial Intelligence and Simulation Science. It functions to convert an image of a handwritten digit, and use a KNN model to recognize the number. The dataset is in data.zip (click to download) .

The following figure is a handwritten digit:

The prediction by KNN is:

I guess the number is: 6