CruxBit
Back to catalog

Draw-and-Predict Digit Classifier Using K-Nearest Neighbors

Added Jun 2025 3 design docs

Handwritten digit recognition is the classic first pattern recognition problem, and it lands hardest when the input is your own handwriting rather than rows of a benchmark file. This project closes that loop: draw a digit on screen, and watch a model you trained yourself read it. The intern trains a K-Nearest Neighbors classifier on the MNIST dataset with scikit-learn, then builds a Streamlit application with a drawing canvas where users sketch a digit with the mouse. The app preprocesses the sketch to match MNIST's format — grayscale conversion, centering, and resizing to 28 by 28 pixels — and returns the predicted digit, optionally alongside the most similar training examples so the algorithm's reasoning by proximity becomes visible. Users quickly discover which sloppy sevens and ambiguous fours fool the model, and can reason about why. The intern learns how images become feature vectors, the mechanics and limits of distance-based classification, and the often-underestimated importance of matching inference preprocessing to training data — all wrapped in an application that makes an excellent live demo for their portfolio.

Related projects

You might also like