philipperemy / cond_rnn

Conditional RNNs for Tensorflow / Keras.
MIT License
225 stars 32 forks source link

Predicted time series for multiple users #20

Closed mohit-awana closed 3 years ago

mohit-awana commented 3 years ago

Hi Philippe,

I was going through this repository and found it very interesting. Great work ! :)

I am trying to predict sales for multiple stores . My goal is to make a single LSTM model to predict sales from these parallel time series having multiple features.

My input features for training would be: +----------+-------+--------------+-------+ | Date | Store | DayOfTheWeek | Sales | +----------+-------+--------------+-------+ | 1/1/2019 | A | 2 | 100 | | 1/2/2019 | A | 3 | 200 | | 1/3/2019 | A | 4 | 150 | | 1/1/2019 | B | 2 | 300 | | 1/2/2019 | B | 3 | 550 | | 1/3/2019 | B | 4 | 1000 | +----------+-------+--------------+-------+

and my output for training would be

+----------+-------+--------------+-------+ | Date | Store | DayOfTheWeek | Sales | +----------+-------+--------------+-------+ | 1/4/2019 | A | 5 | 220 | | 1/4/2019 | B | 5 | 700 | +----------+-------+--------------+-------+

Problem is that LSTM takes input as 3D i.e (n_sample, n_timesteps, n_features) and I can pass a single time series for a specific store.

But I need to identify how can I predict parallel multivariate time series? Is there any other way to define in Input LSTM layer that there are for above problem 2 time series with 2 features each i.e (2*2).

Thank you in advance.

philipperemy commented 3 years ago

If you have two time-series A and B and you think B(t) depends on A(0),...,A(t-1), then you can feed (n_sample, n_timesteps, n_features2) where n_features2 contains a concatenation of [A(0),B(0)] up to [A(t-1),B(t-1)]. This does not depend on conditional LSTM. The purpose of conditional LSTM is to condition on something that does not change with time. For example, the store A will always be store A.

mohit-awana commented 3 years ago

Ok, Thanks for your quick input.