Friday, July 11, 2014

The Writing in the Pixels


For the past few months I have been tackling the classic machine learning problem of classifying handwritten digits. As all nerds do I really enjoy visualizations of data. Here are two that I thought would be fun to share!

Visualizing handwritten digits:

Figure 1: Axes Determined by Principal Components of 0

This is a scatter plot of 0's and 1's. The 0's are green and marked as O's and the 1's are blue and marked as 1's.

Figure 2: Axes Determined by Principal Components of 1
And here is another one! Ditto for the legend.

Figure 3: Axes Determined by Principal Components of 0 and 1
And here is another that I added after first writing this post. This one is the 0's and 1's plotted against the first three principal components of the 0's and 1's. Ditto for the legend.


Assuming that these scatter plots came from the same handwritten digit examples, which they did, you might be wondering about two things. First, how can one create a 3 dimensional scatter plot of what is originally a 784 dimensional vector and second how could you possibly end up with two different scatter plots from the same examples?

The answer to the first question is that these are scatter plots of the first three principal components of the handwritten digits. This is also the key to the second answer. Two different scatter plots may be obtained because the principal components used are different, in the first figure the digits are plotted against the first three principal components of the 0's and in the second figure the digits are plotted against the first three principal components of the 1's.

I think I am going to try to make the scatter plots interactive by
embedding a python script using Brython, but I've never used Brython and it supports Python 3 while up to date I have been using Python 2.7, so I'll have quite a bit of learning to do to make that happen!

No comments:

Post a Comment