-1

I don't understand how I can change my model parameters in order to have more accurate results. Here below find my code of my Multi-step LSTM forecast of stock prices (predicting 8 days)

# set up the model
model = Sequential()
model.add(LSTM(50, return_sequences=True, input_shape=(X.shape[1], X.shape[2])))
model.add(LSTM(50, return_sequences=False))
model.add(Dense(25))
model.add(Dense(1))

model.compile(loss='mse', optimizer='adam', metrics=['mse', 'mae', 'mape','accuracy'])

history=model.fit(X, Y, epochs=60, batch_size=128, validation_split=0.2, verbose=0)

# plot metrics
pyplot.plot(history.history['accuracy'])
pyplot.show()

enter image description here

# plot metrics
pyplot.plot(history.history['mse'])
pyplot.plot(history.history['mae'])
pyplot.plot(history.history['mape'])
pyplot.show()

enter image description here

Could you please indicate me how to change my epoch and batch_size? Does my model even make sense given the very low accuracy (first diagram)?

Thank you!

KAP
  • 29
  • 6

2 Answers2

0

I think it might be because you didn't add an activation function. You can try like this:

model.add(Dense(25, activation='sigmoid'))
model.add(Dense(1, activation='sigmoid'))
ki-ljl
  • 499
  • 2
  • 9
0

Accuracy is a metric used for classification models, however your model is a regression model. See this link for more information about metrics for different types of DL models: https://machinelearningmastery.com/custom-metrics-deep-learning-keras-python/

On your second graph, two of the metrics appear flat, but that's because of the scale of the chart. If you plot them in separate charts, you will see that all three metrics are reducing.

LeonardoVaz
  • 281
  • 1
  • 7