After recently completing the Machine Learning course from Stanford University on Coursera I’ve been preparing to give a small introduction to machine learning at work. Part of that is showing some demos of machine learning tools.

I made a character recognition neural network using the PyBrains Python library, it’s a great library and very fast but the documentation is very poor and examples are hard to come across. With enough digging I managed to put together something very simple and short.

In this example it reads in small PNG files of letters, extracts all of the pixel values and creates a 1D array of the values, this is used to train the neural network through back propagation. I test the network on one of the inputs. Each input is classified with a number in the addSample function, this takes the flattened array and a number (unfortunately it does not take a string as a classification). If you run the application you will see that, for example when using b.png as a test, it will return a value close to 2.

You can download the images I used here – Machine Learning Training Characters.