0
$\begingroup$

Can I ask a very simple question about LSTM time-series data prediction?

I have 1258 data points which are Amazon's historical stock price by day unit. And I build the below data structure in order to train the model.

trainX.shape : (840, 28, 1)
trainY.shape : (840, 1)
testX.shape : (360, 28, 1)
testY.shape : (360, 1)

For this training, I took a single feature that is 'close value' and just ignore other features (eg. open, high, low, volume so on..)

and below is the model structure that I use.

nNeuron = 512
batch_size = 40
seq_length = 28
input_data_column_cnt = 1
dropout = 0.7
epoch_num = 100

model = Sequential()
model.add(LSTM(nNeuron, batch_input_shape = (batch_size, seq_length, input_data_column_cnt), return_sequences = True, stateful = True, dropout = dropout))
model.add(LSTM(nNeuron, input_shape=(batch_size, input_data_column_cnt), return_sequences = True, dropout = dropout))
model.add(LSTM(nNeuron, return_sequences = True, stateful = True, dropout = dropout))
model.add(LSTM(nNeuron, return_sequences = True, stateful = True, dropout = dropout))
model.add(Dense(1))
model.add(Activation('softsign'))
model.summary()

model.compile(loss = 'mean_squared_error', optimizer = 'adam')

early_stopping = [ EarlyStopping(monitor = 'loss', patience = 5, mode = 'auto'),
                  ModelCheckpoint(filepath = 'test_mode.h5', monitor = 'loss', save_best_only = True)]

hist = model.fit(trainX, trainY, epochs = epoch_num, batch_size = batch_size, verbose = 1, callbacks = early_stopping)

Above model is working now.

My Question is, If I want to predict multi-step data(for example, I want to predict 7 days of future data), the data structure above should be like this?

    trainX.shape : (840, 28, 1)
    trainY.shape : (840, 7)
    testX.shape : (360, 28, 1)
    testY.shape : (360, 7)

Due to my stupid English skill, I cannot fully understand many blog tutorials. Sorry for the low-level question.

Thank you.

$\endgroup$

0

Your Answer

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

Browse other questions tagged or ask your own question.