I was trying to forecast a time-series with exogenous variables and have been successful in forecasting with SARIMAX models, I was trying to do the same using RNN models (specifically LSTM model) but was unable to find any way to implement an exogenous variable (which I have the complete history of), but this variable affects the time-series and thus needs to be accounted for. Greatly appreciate your help Thank you
-
care to elaborate a bit more on how you're successfully including exogenous variables in your SARIMAX models and how/where it seems you're finding difficulty including it similarly in your RNN models? – rigsby Jun 11 '20 at 22:11
-
Hi, @rigsby. I used the exog attribute in the SARIMAX function: model=SARIMAX(train_data,exog=exogenous_train, order=..,seasonal_order=...) and then to predict I used the forecast which gave me the option of defining an exogenous variable for the prediction explicitly: fc = model.forecast(steps, exog=exogenous_test). However, I cannot seem to figure out how to do the same in the LSTM models. – user13730526 Jun 11 '20 at 22:20
1 Answers
Check cond-rnn. It is a library that implements what you are looking for.
Useful if you have time series data with other inputs that do not depend on time. For example, weather data from two different cities: Paris and San Francisco. You want to predict the next temperature based on historical data. But at the same time, you expect the weather to change based on the city. You can either:
Combine the auxiliary features with the time series data (ugly!).
Concatenate the auxiliary features with the output of the RNN layer. It's some kind of post-RNN adjustment since the RNN layer won't see this auxiliary info.
Or just use this library! Long story short, initialize the RNN states with a learned representation of the condition (e.g. Paris or San Francisco). This way you model elegantly P(x_{t+1}|x_{0:t}, cond).
And it is really easy to use
outputs = cond_rnn.ConditionalRNN(units=NUM_CELLS, cell='LSTM')([inputs, cond])

- 1,205
- 10
- 19