Last active
September 21, 2023 08:27
-
-
Save tomsoderlund/437c0c9c9aa268bae13314a4e887c788 to your computer and use it in GitHub Desktop.
Basic prediction using neural networks (Synaptic.js)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Adapted from Lian Li’s (@chimney42) example: | |
https://slidr.io/Chimney42/machine-learning-with-synaptic | |
https://www.youtube.com/watch?v=M5glN6XjDv8 | |
You need to include synaptic.js - visit https://caza.la/synaptic/ | |
See my own tests at https://codepen.io/tomsoderlund/pen/MvLZLW | |
*/ | |
// 1. Learn | |
var learningDataSet = [ | |
{ input: [43.2, 54.2], output: [1, 0, 0] }, | |
]; | |
var network = new Architect.Perceptron(learningDataSet[0].input.length, 6, 6, learningDataSet[0].output.length); | |
var trainer = new Trainer(network); | |
trainer.train(learningDataSet, { rate: 0.0003, iterations: 100 }); | |
// 2. Predict | |
var predictionDataSet = { input: [32.42, 634.4] }; | |
predictionDataSet.output = network.activate(predictionDataSet.input); | |
console.log(predictionDataSet); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See my own Synaptic.js test at https://codepen.io/tomsoderlund/pen/MvLZLW