Predicting 5 next value based on sequence of numbers

Viewed 561

I am trying to find a way to predict the next 5 numbers based on a sequence of numbers.

training set:

enter image description here

prediction:

enter image description here

I want to use LSTM to learn the training set to predict the next 5 numbers in the test set. Do you have any idea how can I do this with LSTM?

1 Answers

A simple solution is to create a LSTM layer of 3 hidden states to learn.

Create sequence training set for LSTM from your data mentioned in the question, for example:

7 9 27 13 10 -> 60, will turn into these samples:
[7 9 27] -> 13
[9 27 13] -> 10
[27 13 10] -> 60

For a long input sequence, eg. [1 2 3 4 5 x1 x2 x3], with x1 x2 x3 are any last 3 values:

  • Feed [x1 x2 x3] to the model to find x4
  • Feed [x2 x3 x4] to the model to find x5
  • Repeat again until you have enough predicted values, those'll be [x4 x5 x6 x7 x8]

Harder solution is to

  • Create a LSTM layer with the number of hidden states of max_len(sequence).
  • Pad those sequences not enough length by zeros
  • Train the model with expected values on the right column

Inference:

  • From input sequence, pad zeros to have enough length
  • Feed to model
  • Feed 5 times, after each feed, append the result to input sequence and get max_len items at tail to feed again
Related