Recognizing Handwritten Digits with scikit-learn

Recognizing Handwritten Digits

by Sayantan Bhattacharyya

Language used: Python

Libraries used: Matplotlib, Scikit-learn


 

Overview:

Recognizing handwritten text is a problem that can be traced back to the first automatic machines that needed to recognize individual characters in handwritten documents. Think about, for example, the ZIP codes on letters at the post office and the automation needed to recognize these five digits. Perfect recognition of these codes is necessary to sort mail automatically and efficiently. Included among the other applications that may come to mind is OCR (Optical Character Recognition) software. OCR software must read handwritten text, or pages of printed books, for general electronic documents in which each character is well defined. But the problem of handwriting recognition goes farther back in time, more precisely to the early 20th Century (1920s), when Emanuel Goldberg (1881–1970) began his studies regarding this issue and suggested that a statistical approach would be an optimal choice.

To address this issue in Python, the scikit-learn library provides a good example to better understand this technique, the issues involved, and the possibility of making predictions.

Solution:

Step 1:

Load the required libraries.

Step 2:

Loading the dataset



       

Step 3:

This dataset consists of 1,797 images that are 8x8 pixels in size. Each image is a handwritten digit in grayscale.

The images of the handwritten digits are contained in a digits.images array. Each element of this array is an image that is represented by an 8x8 matrix of numerical values that correspond to a grayscale from white, with a value of 0, to black, with the value 15.



The numerical values represented by images, i.e., the targets, are contained in the digit.targets array.



Now we visualise some training data .

Step 4:

Intializing our model.

In machine learning, support-vector machines(SVM) are supervised learning models with associated learning algorithms that analyze data for classification and regression analysis.



Now we are predicting using the model....



 I am thankful to mentors at https://internship.suvenconsultants.com for providing awesome problem statements and giving many of us a Coding Internship Exprience. Thank you www.suvenconsultants.com

Comments