Skip to content

btq/brain

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 (-: so here's a more involved, realistic example: Demo: training a neural network to recognize color contrast

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 jake:

npm install jake -g

jake build
jake minify

About

js neural networks and classifiers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published