Recognizing hand-written digits:

This example shows how scikit-learn can be used to recognize images of hand-written digits, from 0–9.

Digits dataset:

Note: if we were working from image files (e.g., ‘png’ files), we would load them using matplotlib.pyplot.imread.


We can then split the data into train and test subsets and fit a support vector classifier on the train samples. The fitted classifier can subsequently be used to predict the value of the digit for the samples in the test subset.

Below we visualize the first 4 test samples and show their predicted digit value in the title.

classification_report builds a text report showing the main classification metrics.

We can also plot a confusion matrix of the true digit values and the predicted digit values.

Confusion Matrix

“I am thankful to mentors at for providing awesome problem statements and giving many of us a Coding Internship Exprience. Thank you"