Python Forum
LSTM Model accuracy caps and I can't improve it
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LSTM Model accuracy caps and I can't improve it
#1
I am trying to do a proof of concept LSTM model for forex prediction.

After lots of reading I came up with the following model (I believe its called stacked)

model = Sequential()
model.add(LSTM(64, return_sequences=True, input_shape=(None, x_train.shape[2])))
model.add(LSTM(128, return_sequences=True))
model.add(LSTM(64, return_sequences=True))
model.add(LSTM(n_features, return_sequences=True))

model.compile(loss='mean_squared_error', optimizer='adam')
model.fit(x_train, y_train, epochs=100, batch_size=1, verbose=2, validation_data=(x_test, y_test))
Everything else I did performed worse.

Loss stops to improve after around epoch 70. And after that further training has no effect. I use MinMaxScaler on the data
    self.scaler = MinMaxScaler(feature_range=(0, 1))
    self.scaler = self.scaler.fit(self.raw)
    self.raw = self.scaler.transform(self.raw)
Without scaling the differences in the prediction become so small that the predicted line looks like a straight horizontal line.

Is there anything I can do to improve the model? How do I chose the right number of LSTM layers and hidden layer size for each one of them. Tried adding Dropout layers, as several online resources suggested and there wasn't any improvement.

If I need to provide other parts of the code just let me know.
buran write Dec-18-2020, 07:16 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
andydoc likes this post
Reply
#2
It may not be possible. The data you are training on will have random, unpredictable variation - otherwise everyone would be able to predict the price and there would be no market.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using SHAP Library for my LSTM model - "Attribute Error" vatsalmtailor 0 2,107 Jul-13-2022, 04:34 PM
Last Post: vatsalmtailor
  Increasing validation accuracy on a CNN hobbyist 4 4,169 Jun-23-2020, 01:15 PM
Last Post: hussainmujtaba
  Loss and Accuracy Figures. Hani 3 3,073 May-20-2020, 06:55 PM
Last Post: jefsummers
  Best Accuracy From Loop. AhmadMWaddah 4 2,465 Mar-17-2020, 10:25 PM
Last Post: stullis
  Why is my train and test accuracy so low? python420 0 2,064 Dec-08-2019, 08:51 PM
Last Post: python420
  Low accuracy for fake news detection model shivani 1 2,355 Oct-10-2019, 12:09 PM
Last Post: animeshagrawal2807

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020