0
$\begingroup$

I have a time series problem with 15 minutes as a timestep.The complete data will be from 2016-09-01 00:00:15 to 2016-12-31 23:45:00.

I have 5 variables(v1,v2,v3,v4,v5) in the data frame and I want to predict the fifth variable (v5) for the next timestep.

I prepare the data set and prepare the information as 5-time lags. like if the time is t in the row I create the values for (t-1) to (t-5) as lags for v1 to v5 and also add two variables which are an hour and a weekday/weekend as a boolean.

So in total, I have 27 features (5 lags for 5 variable + hour + weekday/weekend). My shape of train_X is (3000, 1, 27) and train_y(3000, 1) for the 3000 observation/rows.

I also reshaped the train X like below:

train_X = train_X.reshape((train_X.shape[0], 1, train_X.shape[1]))

since I am predicting it for only one timestep at once .And then I build the model like below :

model = Sequential()
model.add(LSTM(20, input_shape=(5,27),recurrent_dropout=0.2,return_sequences=True))
model.add(LSTM(10, input_shape=(5,27),recurrent_dropout=0.1,return_sequences=False))
model.add(Dense(1, kernel_initializer="uniform", activation="linear"))    
model.compile(loss='mean_squared_error', optimizer='adam')

I have taken the timestep is 5 (because I input 5 lags for a row) and 27 (total feature count ).

Is this correct? I tried and throw an error like below:

ValueError: Error when checking input: expected lstm_21_input to have shape (5, 27) but got array with shape (1, 27)

$\endgroup$

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.