0
$\begingroup$

I have time series data and am fitting a (LSTM) neural network. The time series data include let's say a brain wave (var1) as well as the previous state (prev_state) and I want to predict a state (y_pred) based on the data and values over several steps before. The problem I run into is I can fit a neural network, or any type of model, on the training data but the training data already has all the correct state values; but when predicting one record at a time over the same training data everything gets thrown off and the model can get stuck in one state because a state prediction is used as input to the next record.

For example:

Training Data:
Var1    prev_state    y_true
22.2    1             0
20.1    0             1
25.1    1             1
28.5    1             1
30.0    1             1

Predicting not one a time but with already states known:
Var1    prev_state    y_pred
22.2    1             0
20.1    0             1
25.1    1             0 (HERE THE MODEL MADE THE WRONG PREDICTION BUT IT'S OK BECAUSE THE TRAINING DATA ALREADY KNOWS THE TRUE STATE IN THE NEXT RECORD)
28.5    1             1
30.0    1             1
Predicting one at a time and then inserting the prediction in the input of the next record:
Var1    prev_state    y_pred
22.2    1             0
20.1    0             1
25.1    1             0 (HERE THE MODEL MADE THE WRONG PREDICTION AND IN THE NEXT RECORDS ENTIRE PREDICTION SEQUENCE GETS THROWN OFF)
28.5    0             0
30.0    0             0

Is this a problem with over or under fitting? Not sure how to approach this. I'm wondering if the setup is just plain wrong and I'm wasting my time.

$\endgroup$
1
$\begingroup$

There are two ways to approach your problem:

  • At training time, use Teacher Forcing to train the model, this insures that the next step is trained on the correct previous state, even if the predicted previous state was off. Presumably your use case requires multi-step prediction so there's no way around the unceertainty that gets introduced by the recursive estimation at inference time, but hopefully your model is good enough so that it is not a problem.
  • Use what Ben Taieb et al. call MIMO or DIRMO to forecast the whole sequence in one shot instead of doing recursive forecasting. See the paper for details.
$\endgroup$
  • $\begingroup$ Thank you. I will look into this. $\endgroup$ – iuppiter Jul 24 '20 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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