Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prediction #204

Closed
lmktommy opened this issue May 1, 2018 · 12 comments
Closed

Prediction #204

lmktommy opened this issue May 1, 2018 · 12 comments

Comments

@lmktommy
Copy link

lmktommy commented May 1, 2018

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/

@mubaidr
Copy link
Contributor

mubaidr commented May 7, 2018

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

@josiahbryan
Copy link

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

@mubaidr
Copy link
Contributor

mubaidr commented May 14, 2018

Also, I think this might work for you: #192

@robertleeplummerjr
Copy link
Contributor

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.

@robertleeplummerjr
Copy link
Contributor

Working: https://jsfiddle.net/qvvdrvct/

@robertleeplummerjr
Copy link
Contributor

robertleeplummerjr commented May 15, 2018

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

@lmktommy
Copy link
Author

lmktommy commented May 15, 2018 via email

@lmktommy
Copy link
Author

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

@robertleeplummerjr
Copy link
Contributor

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.

@robertleeplummerjr
Copy link
Contributor

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.

@robertleeplummerjr
Copy link
Contributor

Closing because we have a solution.

@robertleeplummerjr
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants