Recognizing Handwritten Digits with scikit-learn
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 our data-set. After that, we will use the remaining Data-set as our test data and check our training machine's accuracy.

Both predicted, and target values are the 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 our models' accuracy 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.
Contributed by
Vikash Patel
Comments
Post a Comment