Original article was published on Artificial Intelligence on Medium
Recognizing Handwritten Digits with scikit-learn
In today’s blog we are going to analyze the digits data-set of the Sci-Kit learn library. We are going to train a Support Vector Machine and then we will be predicting the values of a few unknown Handwritten digits.
Let us start by importing our libraries
Our data-set is stored in digits
Following is an example of a digit in our dataset. It consists of 64 pixels (8X8).
The 1792nd element in our data-set
Let us train our SVM with the first 1790 images in out data-set. After that we will use the remaining Data-set as our test data and check the accuracy of our training machine.
Both predicted and target values are same
As we can see we have achieved 100% accuracy. Let us now define a function that will find the accuracy of our SVM and train our model with varying data-set. We will start with 3 elements in our training data and work our way up to 1790 data and store the accuracy of our models in a dictionary
The values dictionary holds all the accuracies
Let us plot our dictionary.
accuracy vs size of training-set
As we can clearly see for well above 95% of our models the achieved accuracy is 100% . Hence we can easily conclude that our model works for more than 95% of the time.