Keras Time Series: Suggestion for including static and dynamic variables in LSTM

Question:

I am working on a banking related use case where I need to forecast savings account balances of customers. I have both time dependent data of last 12 months as well as static data.

Time dependent data like savings account balances, term deposit balances, mutual fund balances, credit txns done, debit txns done, etc. on a monthly basis.

Static data includes age, gender, region, occupation, marital status, etc.

I am trying to forecast next 3 months savings account balances using LSTM but getting poor rmse. Please find below the LSTM architecture I am currently using along with the python code:Network Architecture

# Model Development
main_input = Input(shape=(X_train_dynamic.shape[1], X_train_dynamic.shape[2]))
encoded1 = LSTM(10,return_sequences=True,activation='tanh')(main_input)
encoded = LSTM(10,activation='tanh')(encoded1)
auxiliary_input = Input(shape=(X_train_static.shape[1],))
output_auxiliary = Dense(10, activation='tanh')(auxiliary_input)
x = concatenate([encoded, output_auxiliary])
decoded = RepeatVector(y_train.shape[1])(x)
#decoded = RepeatVector(y_train.shape[1])(encoded)
main_output = LSTM(1, return_sequences=True,activation='tanh')(decoded)   # return_sequences=True gives Many to Many relationship
model = Model(inputs=[main_input,auxiliary_input], outputs=[main_output])
#model = Model(inputs=[main_input, auxiliary_input], outputs=[main_output])
model.compile(optimizer='adam', loss='mean_squared_error')
history = model.fit([X_train_dynamic, X_train_static], [y_train],
                validation_data=([X_test_dynamic, X_test_static], y_test), 
                epochs=50, batch_size=128)

I am not getting good results for this architecture and open to try out new things if there are reasonable chances of success following that. I am unable to share the exact dataset but happy to provide anything else that might help.

Asked By: Deven

||

Answers:

If you are only getting poor results on testing/validation data, then it is worth while adding dropout layers or regularization parameters for your layers. However, if the problem itself is with training data, then maybe apply some bias reduction techniques.

Answered By: BERT

What is shape of your output (y_train and y_test)? I am kind of stuck in the same area but not getting ahead because of shape errors.

Answered By: user19208810
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.