0.0.2 • Published 8 years ago

toynetjs v0.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

toynetjs

A simple neural network classifier that allow you to traning a supervised model.

How to use

install

npm install toynetjs

code

import {NetWork} from 'toynetjs';

//1. Set the hidden layers like follows:
var l1 = {activation:"sigmoid",numNeurons:2};
var l2 = {activation:"sigmoid",numNeurons:2};

//2. Set config to the network  
var config = {
    layers:[l1,l2],
	lossFunc:'logit',
    maxIter:2000,//option
    errorTol:0.1//option
}
//3. build a network using config you set:
var network = new NetWork(config);

//4. prepare the input array X (size of (n_samples, n_features)) ,and the output array y  (n_samples, n_y_features). Note that they are both 2D arrays.

var X = [[1,2],[-1,-2]]; 
var y = [[1],[0]];

//5. Fit data to build the model
network.fit(X,y);

//6.get predict
var testX = [[1,2],[-1,-3]]
console.log(network.predict(testX));