Recognizing Handwritten Digits With Scikit-Learn

Project 2 entails working on Recognizing handwritten digits is a challenging problem in recent years because we face many problems in recognizing different styles of writing of different peoples as it is not an Optical character recognition. Handwritten digit recognition is the ability of a computer to recognize the human handwritten digits from different sources like images, papers, touch screens, etc. and classify them into 10 predefined classes (0–9). It is used in many real world scenarios like number plate recognition, postal mail sorting, form data entry, bank check processing, etc.We are going to recognize Handwritten single digits(0–9) correctly using the digits data set from Scikit-Learn, which is a Python Library that provides numerous datasets that are useful for testing many problems of data analysis and prediction of the results and other machine learning tasks by using a classifier called Logistic Regression.Digits data set consists of 1,797 images that are 8x8 pixels in size. Each image is a handwritten digit in grayscale as shown below.


Step 1: Importing the Libraries and Dataset

At first, we need to import necessary libraries for our model and loading the dataset digits. To import the svm module of the scikit-learn library, we can create an estimator of SVC type and then choose an initial setting, assigning the values C and gamma generic values. These values can then be adjusted in a different way during the course of the analysis.


Step 2: Analyzing Dataset


The numerical values represented by images, i.e., the targets, are contained in the digit.targets array. And also the dataset is a training set consisting of 1,797 images. We can determine if that is true.

Step 3: Visualizing the images and labels in our Dataset

This dataset contains 1,797 elements, and so let us consider the first 1,791 as a training set and will use the last six as a validation set. We can see in detail these six handwritten digits by using the Matplotlib library.

Step 4 : Fitting svc model


Step 5 : Predicting svc model

It is able to recognize the handwritten digits, interpreting correctly all six digits of the validation set.


Step 6 : Training and Testing Digits Dataset

This entails splitting the Dataset into training and test sets to make sure that after we train our model, it is able to be used again on a new data.


Step 7: Importing Logistic Regression


Step 8: Making an instance of the Model



Step 9: Training the Model


Step 10 : Predicting the labels of new data and measuring performance of our model


Step 11 : Checking Accuracy by Confusion Matrix

Seaborn Is made use of in this project to plot the confusion matrix. 



Step 12 : Using different test size and checking accuracies by using a confusion matrix

-----0.10



-----0.30



Conclusion:As we can clearly see above, accuracy score from our models is very high.Approximately 95% is the least accuracy score.Hence we can easily conclude that our model works for more than 95% of the time.

URL to the project jupyter notebook script file onajite1/Recognizing-Handwritten-Digits-With-Scikit-Learn (github.com)

 








 


Comments

Post a Comment