Recognizing Handwritten Digits

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. In Python, the scikit-learn library provides a good example to better understand this technique, the issues involved, and the possibility of making predictions.

H ere how the scikit-learn can be used to recognize the image of handwritten digits

Scikit-learn is probably the most useful library for machine learning in Python. The sklearn library contains a lot of efficient tools for machine learning and statistical modeling including classification, regression, clustering and dimensionality reduction

The scikit learn library that is has a four-step modeling pattern that is given below:

In scikit-learn four-step modeling pattern
1. Import the model
2. Making the instance
3. Training the model
4. Predicting the new label data

Import Libraries

Import Numpy, Pandas, Matplotlib, Seaborn

Load Daraset

This dataset is made up of 1797 8x8 images. Each image, like the one shown below, is of a hand-written digit. In order to utilize an 8x8 figure like this,

Here we load and Print the Digits dataset

Anakyze the Content

After loading the dataset, you can analyze the content. First, you can read lots of information about the datasets by calling the DESCR attribute.

Use print(Digits.DESCR)

For a textual description of the dataset, the authors who contributed to its creation and the references will appear as shown.

Here I used the shape, size and target method to extract the data about the dataset.

Visualizing the Image and Label in the Data


Now split the Data into train and test data.

Skicit-Learn has 4 step Modeling patterns in Machine Learning.

Import the Model

An estimator that is useful in this case is sklearn.svm.SVC, which uses the technique of Support Vector Classification (SVC).

Thus, you have to import the svm module of the scikit-learn library.

Creating an Instance of the model

An estimator of SVC type and then choose an initial setting, assigning the values C and gamma generic values.

Training the model

Prediciting the model


Check the model is good or not through the metrics library

In metrics, the library had a lot of pre-defined library like as precision, recall f1score accuracy this is called classification report

Here I use the accuracy score this model tells the model is good or not.


From this article, we can see that the svc estimator has learned correctly and able to recognize the handwritten digits using scikit learn. In my accuracy score is 100.0%. I hope this is helpful to you all. Please let me know any defective this blog let me know I will change it.




Master Student

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How CarDekho uses Machine Learning

Building the Mighty Transformer for Sequence Tagging in PyTorch : Part II

Vehicle (car) Detection in Real-Time and Recorded Videos in Python — Windows and macOS

E-Commerce — Automatic Building of Collection of Products

Would You Rather Be an NLP or Computer Vision Data Scientist?

Cross Validation and Its Types

The Matrix Calculus You Need For Deep Learning (Notes from a paper by Terence Parr and Jeremy…

Kickstarter — Predictive Analytics

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ajithprasanna R

Ajithprasanna R

Master Student

More from Medium


Arriving somewhere But not here!

Microghosting or ‘selective responding’ in work and friendship

Grammar in the workplace: Importance of good communication