brain.js icon indicating copy to clipboard operation
brain.js copied to clipboard

Best way to train and test LSTMTimeStep network with array of floating point numbers?

Open imkane opened this issue 3 years ago • 1 comments

So I have an array of numbers like this (~150 distinct numbers):

[ 307.655296, 308.34, 308.62, 308.0020728, 308.0799444, 307.835, 307.72921, 307.899735, ...]

My goal is to be able to predict the next number in the sequence. But I'm unsure how many input numbers are ideal to get the best result :thinking:

For training, I:

  1. Normalize array so each value is < 1
  2. Initiate network: const net = new brain.recurrent.LSTMTimeStep(netOptions)
  3. Train network: net.train(trainArray, trainingOptions)
  4. Get to a low training error of ~0.001

But now when I run net.run(testArray) I don't know how many values in the testArray are needed? 1, 2, 4, ... 10, etc? It seems like the more numbers the better, but I'm not sure what the rule of thumb is, or the proper way to go about this.

For example, even using 6 values from the trainArray in the testArray I only get about 60% accurate results.

Thanks in advance!

imkane avatar Nov 27 '22 19:11 imkane

So I have an array of numbers like this (~150 distinct numbers):

[ 307.655296, 308.34, 308.62, 308.0020728, 308.0799444, 307.835, 307.72921, 307.899735, ...]

My goal is to be able to predict the next number in the sequence. But I'm unsure how many input numbers are ideal to get the best result 🤔

I'm also learning brain.js / ML, so i'm wondering if we can potentially learn from each other's experiences as ( based on your github profile ) it seems we have the same goal in mind ( :

feel free to get in touch ( see my profile ) if you would like to exchange some ideas!

For training, I:

  1. Normalize array so each value is < 1
  2. Initiate network: const net = new brain.recurrent.LSTMTimeStep(netOptions)
  3. Train network: net.train(trainArray, trainingOptions)
  4. Get to a low training error of ~0.001

would you mind sharing your trainingOptions ? I'm curious about how you go to 0.001 !

But now when I run net.run(testArray) I don't know how many values in the testArray are needed? 1, 2, 4, ... 10, etc?

How are you splitting the training data from the testing data ?

It seems like the more numbers the better, but I'm not sure what the rule of thumb is, or the proper way to go about this.

Have you watched Neural Networks with JavaScript - Full Course using Brain.js created by @robertleeplummerjr himself?

Have you looked into Cross Validation ?

For example, even using 6 values from the trainArray in the testArray I only get about 60% accurate results.

What you mean by 60% accurate results? How do you measure that "percentage" ?

Thanks in advance!

🚀

hems avatar Dec 26 '22 02:12 hems