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

5 Reasons Why PLCs Drive Billion Dollar Markets

What are the Differences Between Z-test and T-test?

Unearthing Value in Planet Data: Bridging the Gap Between Geospatial Data and Machine Learning

The most complete guide of Convolutional Neural Network

Topic DL02: Understanding Backpropagation

Using Open-AI’s GPT-2 To Generate New Netflix Movie/TV Descriptions

Over view of last weeks topic

Reinforcement Learning 3: Finite Markov Decision Processes (part-1)

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

Bourdaina Wireframe

Struggling to start a new habit? Use this idea from Physics to think about it differently

‘Pieces of Her’ Trailer: Netflix Mystery Series

‘Pieces of Her’ Trailer: Netflix Mystery Series

How to create a sidebar navigation system using reactBootstrap