0
$\begingroup$

I have created an LSTM model which is trained on an 8-hour time frame for a cryptocurrency. When the training is finished I see that it is learning the pattern but there is some bias in it. How to handle this?

This is my model:

'''Build LST model'''
model = Sequential()
model.add(LSTM(50, return_sequences = True, input_shape=(x_train.shape[1:])))
model.add(Dropout(0.2))
model.add(LSTM(50, return_sequences = False))
model.add(Dense(25))
model.add(Dropout(0.2))
model.add(Dense(1))
'''Compile the Model'''
model.compile(optimizer='adam', loss='mean_squared_error')
model.fit(x_train, y_train, batch_size=1, epochs=50,verbose = 2)

enter image description here

$\endgroup$
5
  • 1
    $\begingroup$ How do you train the model exactly? You mention that the model is trained on an 8 hours time frame, does this mean that this graph is entirely made of test set predictions after training? (I doubt it) $\endgroup$
    – Erwan
    Jun 23 at 18:57
  • $\begingroup$ By 8 hour I mean input is a vector of length 8(t,t-1,t-2 ... t-7). Yes this graph is after the training I predicted on the test data(which is again reshape in the form of t .. t-7 time steps) $\endgroup$ Jun 24 at 4:55
  • $\begingroup$ How do you split between the training and test data? With time series like this you need to separate the time periods, for example if the training data is from 0h to 8h, the test data should be for example from 8h to 16h. There shouldn't be any overlap between the training and test data times. This graph looks like the points were picked randomly from the same period of time. $\endgroup$
    – Erwan
    Jun 24 at 9:44
  • $\begingroup$ I have taken 1000 hours of data into the memory. Then I split 800 for training and the rest 200 for testing(As you can see in the image). There is no overlap between training and testing. $\endgroup$ Jun 24 at 11:15
  • $\begingroup$ Sorry but it's practically impossible that the model would predict so accurately a non-periodic curve. I think there is a confusion, are you sure you used the predict() method to generate this graph? I don't know exactly what is happening but this doesn't look at all like a realistic prediction on a test set. My guess is that it shows the curve of the validation set when the validation data hasn't been correctly specified and is picked randomly instead (the default). $\endgroup$
    – Erwan
    Jun 24 at 13:44

Your Answer

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

Browse other questions tagged or ask your own question.