Computer Program which is able to recognize handwritten digits or letters could be arguably regarded “Hello World” equivalent for machine learning or deep learning , so sharing results of my attempt using couple of open sourse machine learning platform for enterprise Keras (uses Googles TensorFlow computational library) and H20


Lot of information is available onlline on the subject of Deep Learning , essentially this exercise shall use hand-written digits data made available by MNIST.Machine Learning or Deep Learning exercise is to classify these images into 10 categories ( Number 0 to 9)

The Training data set of 42,000 handwritten numbers have been encoded into grayscale images of handwritten digits (28 pixels by 28 pixels - for a total of 784 pixels in total)

How does the training data look ?

Shown below are 10 of 784 pixel values (0 to 255) of each number along with its correct number label

Table 1: Sample Data of 6 numbers
label pixel0 pixel1 pixel2 pixel3 pixel4 pixel5 pixel6 pixel7 pixel8 pixel9
1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0

How do first hand-written 6 numbers actually look ?

Deep Learning Model was trained on 48,000 samples with 5 hidden dense layers and batch of 160 and 20 epochs and tanh activation function

Note:Finding the best model for most accuracy is a iterative process of closely monitoring results of each training run with different parameters akin to feature engineering, monitoring loss and accuracy for every epoch

All computations performed in H2O environment of highly optimized Java machine learning library Code

How did Deep Learning Model fare for 8398 samples of Test Data

Confusion Matrix for the test data set

Table 2: Error in correctly Recognizing
0 1 2 3 4 5 6 7 8 9 Error Rate
0 830 1 0 2 1 1 2 0 2 1 0.0119048 10 / 840
1 1 884 7 1 0 0 2 3 1 0 0.0166852 15 / 899
2 2 3 822 4 4 3 6 5 9 1 0.0430733 37 / 859
3 2 4 11 822 1 10 1 5 9 3 0.0529954 46 / 868
4 2 2 1 0 795 1 2 0 2 11 0.0257353 21 / 816
5 2 1 2 31 1 717 11 1 2 6 0.0736434 57 / 774
6 5 0 2 0 1 2 795 0 2 0 0.0148699 12 / 807
7 0 2 6 5 3 0 0 853 4 12 0.0361582 32 / 885
8 0 3 3 9 1 4 6 0 759 2 0.0355781 28 / 787
9 1 0 1 9 9 2 0 6 8 827 0.0417149 36 / 863
Totals 845 900 855 883 816 740 825 873 798 863 0.0350083 294 / 8,398

How Accurate is this model in predicting ?

Model Accuracy 96.5 %

Models performance on predicting following test data

Model Predicted these numbers as

## > 2 > 5 > 3 > 2 > 6