This is a very basic neural network consisting of two perceptrons designed to assign points to quarters on the coordinate system. Unfortunately, it's not ideal and it fails sometimes so I have to figure out how to fix it.
$ node perceptron-demo.js
$ node network-demo.js
Using my Network means that you want to give your own coordinates and get the quarter which the point belongs to. Follow these two steps below and have fun.
const networkTrainingSet = generateNetworkTrainingSet();
console.time('NetworkTrainingIterations');
for (let i = 0; i < 3e2; i++) {
i % 10 === 0 && console.log('NetworkTraining iteration', i);
network.train(networkTrainingSet);
}
console.timeEnd('NetworkTrainingIterations');
console.log(weightsX, weightsY);
const networkTestSet = generateTestSet(1e7);
network.test(networkTestSet);
network.getQuarter([1, 2]); // => Quarter I
network.getQuarter([1.093, -223.7492]); // => Quarter IV
network.getQuarter([-0.093, 23]); // => Quarter II
network.getQuarter([-95, -23.97]); // => Quarter III