0
$\begingroup$

Suppose say, I have to predict the cost of stock market. I have previous data and I have made it into the following Structure :

(Xt-3,Xt-2,Xt-1)--->(Xt=Yt)

Now the order of the above data points if I use an LSTM model should be preserved which means the Day1, Day2 and Day3 should be in sequential order.

My doubt is I will be having different rows like this. Can I shuffle those for training while preserving the order within each row. Eg : Can I keep the row For 3 days of August before 3 days of July even though those 3 days will be given in sequential order. I am assuming we should as every models considers each data row as a separate training sample and adjusts its weights as per gradient descent so order should not matter even if we shuffle the rows. Am I right?

Second doubt : if I have trained my model till May 8, And I need to predict tomorrow (May 11) and my window length is 3 for LSTM

Should I predict May 9 and May 10 and then use May 8, may 9 and May 10 value to predict the next day or should I use actual values of May 9 and May 10. I read somewhere you need to retrain to make new forecast. But I dont think it's a compulsion. If I have trained my model till may 8 and then I give it the values of May 8 May 9 and May10 in sequential order, It should give me a forecast right?

$\endgroup$

1 Answer 1

1
$\begingroup$

Regarding Doubt 1:

Yes, if you shuffle those for training the order within each row will be preserved. If you shuffle the rows, that's good, and the LSTM models will consider each row as a separate sample.

Regarding Doubt 2:

If you train a model up to May 8th, you can build it so that it outputs predictions for May 9th, May 10th, May 11th, etc. You can evaluate the predictions using the actual values for May 9th and 10th or however else you think is good.

$\endgroup$
4
  • $\begingroup$ If I want to get it for May 11th. I have the data already available for May 9 and May 10. Is it better to predict May 9 and 10 and use that to predict tomorrow or use the actual values of May 9 and May 10 to predict tomorrow $\endgroup$ May 10 at 14:00
  • $\begingroup$ And Again clarifying, If I choose to retrain the row (May 8, May9 ,May10)... This row can come anywhere as long as the 3 days are fed sequentially within the row right? Even if it means this row occurs before say (Jan1 , Jan2 and Jan3) $\endgroup$ May 10 at 14:01
  • 1
    $\begingroup$ @NeverGiveUp Depends on the question you're trying to answer. If you're asking "How well can I predict 3 days in advance?" then omit the 9th and 10th. If you're asking "How well can I predict the next day?" then include them. Both are interesting. $\endgroup$
    – m13op22
    May 10 at 16:43
  • $\begingroup$ With regards to rows, you'd set stateful=False in Tensorflow. Not sure equivalent in PyTorch. But then the state for each row is not kept, thereby the order of rows isn't needed. $\endgroup$
    – m13op22
    May 10 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.