Handwritten Digit Recognition using Edit Distance-Based KNN

Bernard Marc, Élisa Fromont, Amaury Habrard, Marc Sebban2014

TL;DR

This paper describes a practical machine learning project for first-year Master's students focused on building a handwritten digit recognition system. The system leverages Freeman codes for digit representation and an edit-distance-based K-Nearest Neighbors (KNN) classifier, emphasizing both theoretical understanding and practical implementation skills.

What Problem Does This Paper Address?

The paper addresses the challenge of teaching core machine learning concepts, particularly supervised classification, to students with a solid programming background but potentially limited theoretical mathematical foundations. The goal is to provide a hands-on project that bridges the gap between theory and practice, allowing students to implement and optimize a classification system, understand data representation, and develop a user interface. This project aims to make abstract ML concepts more tangible and engaging.

Methods

The core of the recognition system relies on two main components:

  • Freeman Codes: This method converts a handwritten digit (drawn on a screen) into a string representation. It involves tracing the boundary of the digit using eight-connectivity directions, each encoded by a number. This string representation is then used as the feature vector for classification.
  • Edit Distance-Based K-Nearest Neighbors (KNN): The system uses the K-Nearest Neighbors algorithm for classification. Instead of traditional numerical feature vectors, the "distance" between two digits is calculated using an edit distance metric on their Freeman code strings. This metric quantifies the minimum number of operations (insertion, deletion, substitution) needed to transform one string into another.

To address potential computational challenges with large datasets, the paper also outlines two optimization algorithms for the KNN classifier:

  • Dataset Cleaning: This involves removing outliers and examples from the Bayesian error region to smooth decision boundaries.
  • Irrelevant Example Removal: This algorithm aims to reduce the dataset size by deleting redundant or less informative examples, potentially speeding up the search for nearest neighbors.

Datasets

The paper does not specify any pre-existing, publicly available datasets used for training or evaluation. Instead, it emphasizes that students are required to create their own dataset. This involves populating a database with handwritten digits (and potentially letters) drawn by users. Students can choose to store this data as images, Freeman codes in text files, or XML files. The paper highlights the importance of diverse data collection from multiple individuals to ensure robust classification.

Key Insights and Ideas

  • Bridging Theory and Practice: The project successfully demonstrates how to integrate theoretical ML concepts (KNN, edit distance) with practical software development (GUI, data management) in an educational setting.
  • String Representation for Images: Using Freeman codes as a string representation for image data is an effective way to apply sequence-based algorithms like edit distance to visual recognition tasks.
  • Importance of Data Diversity: The authors stress that creating a representative dataset is crucial for achieving good classification accuracy, especially when dealing with variations in handwriting styles.
  • Optimization is Key: For real-time recognition, optimizing the KNN algorithm and the dataset is essential. The paper introduces practical techniques for dataset reduction and cleaning.
  • Student Engagement: The project is highly welcomed by students, likely due to its hands-on nature and the tangible outcome of a working recognition system.

Key Results

The paper focuses on the pedagogical aspects and the project's implementation rather than presenting specific quantitative performance metrics from a controlled experiment. However, it states that students typically achieve "sufficiently" good accuracy, often around 80%, with a representative dataset. The project's success is also measured by students' ability to implement and demonstrate the system, often adding "side games" like Sudoku or letter games to showcase its performance.

Limitations and Future Work

  • Dataset Creation Burden: The requirement for students to create their own dataset can be time-consuming and may lead to variations in dataset quality and size across different groups.
  • Limited Theoretical Depth: While the project covers practical aspects, the students' mathematical and theoretical background is noted as being less extensive, which might limit their exploration of more complex ML algorithms.
  • Programming Language Choice: While students can choose their language, the paper notes that most opt for Java Swing, which might implicitly steer the project's technical direction.

Future work could involve:

  • Testing the performance of other distance metrics (e.g., L1, L2, Mahalanobis) on different image representations.
  • Exploring more advanced dataset reduction techniques and their impact on accuracy.
  • Investigating different string representations for digits beyond Freeman codes.

Summary updated

Abstract

We discuss the project given for the last 5 years to the 1st year Master students who follow the Machine Learning lecture (60h) at the University Jean Monnet in Saint Eti-enne, France. The goal of this project is to develop a GUI that can recognize digits and/or letters drawn manually. The system is based on a string representation of the dig-its using Freeman codes and on the use of an edit-distance-based K-Nearest Neighbors classifier. In addition to the machine learning knowledge about the KNN classifier (and its optimizations to make it efficient) and about the edit distance, some programming skills on how to develop such a GUI are required.
BibTeX
@misc{marc2014handwritten,
  author = {Bernard Marc and Élisa Fromont and Amaury Habrard and Marc Sebban},
  title = {{Handwritten Digit Recognition using Edit Distance-Based KNN}},
  year = {2014},
}

Loading related content...

Figure