Lightweight Neural Network Ruby Extension

[Updated: 2008-3-3]: I completed a Ruby extension to the Lightweight Neural Network C library. I really wanted to get into the thick of writing Ruby, and at the same time, I was getting into artificial neural networks, so I came up with a fun project. It's a Ruby extension for the lwneuralnet C library. The extension currently lets Ruby programmers create a simple back propagation network that can be trained to recognize patterns in its input.
Download and learn about the lwnueralnet C library here. Download the Ruby extension here.
If you have any questions or comments about the extension contact me. (I also have a pure-Ruby implementation that I'll post after it's cleaned up and ready to go. It's about 20 times slower than the C version, but it better lends itself to tweaking.) To install, download both packages and follow the directions below:

Installation

This has been tested on Mac OS X and Ubuntu 7.10. If you are on Ubuntu or Debian, you may need to do this first:
sudo apt-get install ruby1.8-dev
Move the downloaded packages to a directory you want to install them in. Enter these commands:
tar xzvf lwneuralnet-0.8.tar.gz
tar xzvf lwneuralnet-ruby.tar.gz
cd lwneuralnet-0.8
This next part was necessary on my OS X system. Edit the following file (may not be necessary on Linux): source/network.c Replace this line:
#include <malloc.h>
With these lines:

#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
Enter these commands:
make
cd ../lwneuralnet-ruby
ruby extconf.rb \
  --with-lwneuralnet-include=../lwneuralnet-0.8/source \
  --with-lwneuralnet-lib=../lwneuralnet-0.8/source
make
ruby test.rb
You should see output that begins with this:
random: 1804289383
learning_rate: 0.5
momentum: 0.400000005960464
output_error: 0.139647409319878
Calling LWNetwork#print:
The test.rb script first demonstrates the three classes and their methods. Then it sets up a network for detecting input patterns that match an XOR logic gate. It trains the network over 3000 iterations and outputs the network's output error, which lets you know how well the network was trained. It trains 50 such XOR networks, each with a randomly-selected set of weights. Some of those 50 networks never train, and those are marked as "BAD" in the test output. Perhaps by tweaking the :learning_rate and :momentum parameters, you can fix that. Have fun!
00000000000000111110000000000000
00000000000111100011000000000000
00000000011100000001000000000000
00000000110000000000100000000000
00000001100000000000100000000000
00000001000000000000100000000000
00000011000000000000100000000000
00000010000000000000100000000000
00000010000000000000100000000000
00000010000000000000100000000000
00000011000000000000100000000000
00000001000000000001000000000000
00000001100000000110000000000000
00000000110000011100000000000000
00000000011110110000000000000000
00000000000011110000000000000000
00000000000110011000000000000000
00000000000100000100000000000000
00000000001000000011000000000000
00000000011000000000100000000000
00000000010000000000110000000000
00000000010000000000011000000000
00000000010000000000001000000000
00000000100000000000001000000000
00000000100000000000001000000000
00000000100000000000001000000000
00000000100000000000001000000000
00000000100000000000001000000000
00000000100000000000010000000000
00000000010000000001110000000000
00000000010000001111000000000000
00000000011111110000000000000000

download link broken

"the Download the Ruby extension here. link is down."

also you're contact me link is broken too!

"If you have any questions or comments about the extension contact me."