Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
js neural networks and classifiers
branch: master

This branch is 66 commits behind harthur:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
Jakefile.js
LICENSE
README.md
build.js
package.json

README.md

brain

brain is a limited JavaScript supervised machine learning library. Full API here. Neural network example:

var net = new brain.NeuralNetwork();
net.train([{input: [0, 0], output: [0]},
           {input: [0, 1], output: [1]},
           {input: [1, 0], output: [1]},
           {input: [1, 1], output: [0]}]);

var output = net.run([1, 0]);

The output will be [0.987] or something close like that. There's no reason to use a neural network to figure out XOR, but it's a small example (-:

Naive Bayesian classifier example:

var bayes = new brain.BayesianClassifier();

bayes.train("cheap replica watches", "spam");
bayes.train("I don't know if this works on Windows", "not");

var category = bayes.classify("free watches");

using in node

If you have node you can install with npm:

npm install brain

using in the browser

Download the latest brain.js. If you're using BayesianClassifier, you can only use the localStorage and (default) in-memory backends. If you're using the NeuralNetwork you should try to train the network offline (or on a Worker) and use the toFunction() or toJSON() options to plug the pre-trained network in to your website.

tests

Running the tests requires checking out the code and installing the dev dependencies: npm install --dev. To run the suite of tests:

node test/runtests.js

To run the other tests: browser and cross-validation tests

build

To build a browser file from the CommonJS package you'll need node-jake:

npm install jake -g

jake build
jake minify
Something went wrong with that request. Please try again.