2
$\begingroup$

I have a dataset of approximately monotonically increasing values (in a time-series). I am using keras and LSTM to train the model and perform the testing on the most recent values in the dataset. For example:

  • Training set data from 2009 to 2018
  • Test set data form 2018 to 2019 (will have higher values than train set by default )

It just so happens that - due to the increasing nature of the values - the LSTM has never been trained with these large values before. This is making the model perform poorly on new data.

However, when I shuffle the data beforehand i.e. the test set does contain values that the LSTM might have trained on before, the model generalizes better and performs better as well.

  1. Is this normal?
  2. Is there a way to combat this issue without shuffling?
  3. I am using stateless LSTM, so if I standardize the LSTM time windows independently could this be a good solution?

The below is a chart of the dataset: (Not the whole dataset but the large majority of it. Its a good indication of the trend) enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ Could you attach plot showing the data over time? $\endgroup$
    – Tim
    Commented Jul 1, 2020 at 14:30
  • $\begingroup$ @Tim just added the chart $\endgroup$ Commented Jul 1, 2020 at 14:41
  • $\begingroup$ Predict the returns, not the price. $\endgroup$
    – Sycorax
    Commented Jul 1, 2020 at 15:33

1 Answer 1

1
$\begingroup$

You may be suffering from a common issue of neural networks failing to generalize to numerical inputs unseen in training.

The best display of this behavior I know is the figure from this paper:

Caption from the paper: MLPs learn the identity function only for the range of values they are trained on. The mean error ramps up severely both below and above the range of numbers seen during training.

To solve this, you can change the input format of your data so that the higher values aren't "unseen" in the training. You could have it take in and predict relative increases/decreases instead of the absolute value. I think this is what you meant by your third suggestion? ("standardize the time windows").

$\endgroup$
3
  • 1
    $\begingroup$ This is an interesting suggestion, but I wonder if the results from the paper, which pertain to MLPs, would be true to OP's network, which is an lstm network. $\endgroup$
    – Sycorax
    Commented Jul 1, 2020 at 16:01
  • 1
    $\begingroup$ They do. Here's another paper on this type of issue, applied to recurrent networks (including LSTM) and translation task: arxiv.org/pdf/1711.00350.pdf $\endgroup$ Commented Jul 1, 2020 at 16:05
  • $\begingroup$ @SimonAlford Thanks for this confirmation. I was thinking of doing this exact thing. Yes, that is what I meant by the poorly worded "standardize the time windows". I was in need of confirmation that this is a neural network issue. $\endgroup$ Commented Jul 1, 2020 at 16:23

Your Answer

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

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