Brain.js: Prediction

Created on 1 May 2018  Â·  12Comments  Â·  Source: BrainJS/brain.js

Is it possible to use brainjs to predict the result?

Data:
4,7,9
6,9,10
10,8,7

Return predict result.

Like: https://jsfiddle.net/9t2787k5/4/

Most helpful comment

const net = new brain.recurrent.LSTMTimeStep({
  inputSize: 1,
  hiddenLayers: [20, 5, 1],
  outputSize: 1
});

const trainingData = [
  [4,7,9],
  [6,9,10],
  [10,8,7]
];

const results = net.train(trainingData, { log: true });

 // NOTE: Actual results
console.log(results); // {error: 0.0042235056559244795, iterations: 3586}

console.log(net.run([4,7])); // 8.998400688171387
console.log(net.run([6,9])); // 9.994184494018555
console.log(net.run([10,8])); // 6.999631404876709

All 12 comments

Would you please elaborate your data sample, separated as inputs and outputs expected?

@lmktommy - did you look at the LSTM architecture in the docs ...? That's the first thing that comes to mind when I read this.

Also, I think this might work for you: https://github.com/BrainJS/brain.js/issues/192

Sorry I've been so busy, yes this can be done with the TimeStep neural network. I'll see if I can get an example up before the end of the day.

const net = new brain.recurrent.LSTMTimeStep({
  inputSize: 1,
  hiddenLayers: [20, 5, 1],
  outputSize: 1
});

const trainingData = [
  [4,7,9],
  [6,9,10],
  [10,8,7]
];

const results = net.train(trainingData, { log: true });

 // NOTE: Actual results
console.log(results); // {error: 0.0042235056559244795, iterations: 3586}

console.log(net.run([4,7])); // 8.998400688171387
console.log(net.run([6,9])); // 9.994184494018555
console.log(net.run([10,8])); // 6.999631404876709

Thank you for your explanation. I will try it soon.

On Tue, 15 May 2018 at 20:59, Robert Plummer notifications@github.com
wrote:

const net = new brain.recurrent.LSTMTimeStep({
inputSize: 1,
hiddenLayers: [20, 5, 1],
outputSize: 1
});
const trainingData = [
[4,7,9],
[6,9,10],
[10,8,7]
];
const results = net.train(trainingData, { log: true });

// NOTE: Actual resultsconsole.log(results); // {error: 0.0042235056559244795, iterations: 3586}
console.log(net.run([4,7])); // 8.998400688171387console.log(net.run([6,9])); // 9.994184494018555console.log(net.run([10,8])); // 6.999631404876709

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/BrainJS/brain.js/issues/204#issuecomment-389157347,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHlkG-rpK1zzKqnelX0MNpX0dR4vKg3iks5tytE5gaJpZM4TtjaM
.

>

Regards, Tommy Liu Sent from iPhone

robertleeplummerjr - Thank you for your reply. I would ask one more question that does the library return the prediction result? For example: I use dice as example - Set 1 [2,4,5], Set 2 [1,4,6], Set 3 [2,3,5]. Ask brain to predict Set 4. Thank you

With that limited amount of data, it might but you'll likely get overfitting. However, if you had hundreds or thousands of dice, then it'd have little issue picking them out.

I want to point out too, the above api is really a preview of things to come for v2, things will get a whole lot smarter and more interesting when it is released.

Closing because we have a solution.

Now supported with TimeStep neural networks via the run method (https://github.com/BrainJS/brain.js#runinput---prediction) and even further via the forecast method (https://github.com/BrainJS/brain.js#forecastinput-count---predictions).

Ty guys!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VEXLife picture VEXLife  Â·  4Comments

dan-ryan picture dan-ryan  Â·  4Comments

TomDobbelaere picture TomDobbelaere  Â·  6Comments

robertleeplummerjr picture robertleeplummerjr  Â·  6Comments

SCMorgan picture SCMorgan  Â·  3Comments