Wednesday, July 4, 2007

Pattern Regognition in Flash

!- Please note that you need to have a decent computer and browser to run this application or it'll crash.

A while ago, I made a pattern-recognition application in Flash and I decided to improve it by adding some sort of save and load functionality. The engine itself uses an Artificial Neural Network (ANN) to determine an output based on a series of inputs which, in this case, represents each pixel of a 50*50 bitmap. Here's screen shot:


Before you get your hands dirty, here's a run through of how it works:

What the program does is associate two different shapes with either 'yes' or 'no' but it's not that easy, you need to teach it! To start you'll need to decide two shapes that you'll use, the more different they are, the faster the machine will learn to identify them. A good set of shapes is a tick and a cross to signify 'yes' and 'no' respectively but you can use whatever you like.

To start, just draw the shape for 'yes' inside the small white square and click 'think.' Once it's done thinking it should output either 'Yes' or 'No' in the box labeled 'Response'. If it says 'No', correct the machine by pressing the 'Yes' button, the output will most likely change to 'Yes', but if it doesn't, don't keep correcting it. Then, clear the drawing area (the clear button) and draw the shape for 'No', click 'Think', and again, correct the machine if it's wrong. If it gives you the right answer, do not correct it by feeding it the right answer again. Repeat this MANY more times and, eventually, you'll notice that it gets pretty accurate.

Now, another thing which might be of interest is the big text area right under the 'Brain Data' label - this is to upload and show the neural structure of the machine. If you wish to save the machine's brain, click the 'show' button, be patient, this may take a while... Once it's done, click in the text area and press 'Ctrl+A' to select all, then copy it. Paste the text in a text file. Just for the record, if you were to paste it inside a word document, if would take-up about 50 pages when using Times New Roman at size 12.

If you want to upload your neural data, copy it from the text file and paste it inside the text area then press the 'Upload' button; again, be VERY patient and don't do anything while it's uploading, I haven't optimized the application and it can freeze very easily.

Once, that's done, you should be able to carry on with teaching your artificial brain to perfect its skill.

Ok, here's the link: ANN
Also, I've already created a brain if you don't have the patience to train your own from scratch. It associates a tick with 'Yes' and a circle with 'No.' It's about 80 to 90% accurate with me, I guess it depends on handwriting. Try to make well formed ticks that look like 'v's: Tick vs Cirle
Just open-up the word document, then, click on the text and press 'Ctrl-a', then copy and go to the application. Click inside the text box (make sure it is empty to start with) then paste and click 'Upload'.

Cheers.

1 comment:

Jon said...

http://www.modset.net/