whiz v0.1.3
whiz
Artificial Neural Networks are used to predict results based on patterns. One such library is whiz
.
Caution
It is highly recommended that you install (or update) to the latest version (0.1.3)
, as there is big bug fix in the training method. Thanks!
Usage
This library can only be used as node package.
npm install whiz
You could choose to use this package with either node.js or io.js.
Creating an Object
You should create an object with required arguments to use the Neural Network.
var whiz = require('whiz');
var net = new whiz.NeuralNetwork(2,3,1);
The function takes 3 arguments, number of inputNodes, hiddenNodes & outputNodes
.
Training the Neural Network
To train the neural network, use the following code snippet.
net.train([{input: [0, 0], output: [0]},
{input: [0, 1], output: [1]},
{input: [1, 0], output: [1]},
{input: [1, 1], output: [0]}]);
Here, the neural network is trained with XOR inputs.
Note that the number of input nodes & output nodes given during training should match with numbers given during the creation of the object.
This method returns the output predicted at the end of training, which can be logged using console.log();
.
Testing the Neural Network
After training the neural network sufficiently, we can classify the unclassified inputs by,
net.test([{input: [0, 1]}]);
This method also returns the output predicted, which can be logged using console.log();
.
console.log(net.test([{input: [0, 1]}]));
Optional Methods
Set Learning Rate
This method is used to set the learning rate of the neural network. It can be accessed by,
net.setLearningRate(0.5);
Get Learning Rate
This method is used to get the learning rate of the neural network. It can be accessed by,
net.getLearningRate();
This method return the learningRate, which can also be logged using console.log();
.
Changelog
0.1.3:
Fixed errors with training. Now, the neural network predicts more accurately.