Can Prophet be used for multivariate time series and how it can be used
@kumarvrsec #101 is probably duplicate of this issue with already some activity. If yes, close this one and switch discussion over #101 so issues list is kept relatively clean.
There is no direct answer available in those issues.
This is on the to-do list in #49. There isn't a general way to do this in Prophet.
As @IronistM points you you could try to use extra regressors to do this, by forecasting one time series (let's call it A) and then including it (and its forecast) as an extra regressor for forecasting another (call it B). Because we are using the _forecast_ of A to get a forecast for B, I think this would only be useful if A is for some reason easier to forecast than B. An example of a situation where this would be the case is if we wanted to forecast a total, as well as different subgroups of that total (e.g. demographic buckets). We could first forecast the total (A), and then use it as an extra regressor when we forecast each of the subgroups. Because the total has more data, it could be easier to forecast and could improve the subgroup forecast. How well this works would really depend on the situation.
Thank you very much for the explanation.I tried for one mutlivariate time series data(date,data1,data2 as columns) of 150 points.First I tried to forecast for data 1 for extra 10 periods.Then I thought of using the data1 along with forecasted data as causal to do the forecasting for data 2.But,I haved faced the issue in adding the data1 column as regressor even I have put standardize as 'auto'.Is there anyway different way of adding timeseries as regressor,as the example is provided only for binary in the documentation (which I tried to replicate for time series also).
Can you please help me on this,if possible by example.Thanks
@kumarvrsec I don't understand fully what the issue is. standardize='auto' is the default value. What problem are you running into adding data1 as a regressor?
We'll add a non-binary example to the documentation soon, but there is really no difference between having a binary or non-binary regressor in terms of the commands.
The issue is,the regressor command is not identifying the data 1
@kumarvrsec if you could post code that I can run that reproduces this example, and also paste the actual error message and stack trace that you are getting that'd be helpful.
I saw the code in an email notif but for some reason it isn't showing up here. Anyway, make sure you add the multivariate column as a regressor, and not just causal
Can prophet be used to predict multiple series like sales of each item instead of just one?
I saw the code in an email notif but for some reason it isn't showing up here. Anyway, make sure you add the
multivariatecolumn as a regressor, and not justcausal
Hi Bletham,Please find the main part of code and there are three variables 'date', 'y' and 'z' .First,I tried to predict 'y' for first 120 points and then predicted for 32 points and then used 'y' as causal to predict 'z' as I tried to follow the code in the documentation.Is there any customization to be done.Can you please help.Thank you.
`m = Prophet(daily_seasonality = True,yearly_seasonality= True,weekly_seasonality=True)
m.fit(df[0:120])
future = m.make_future_dataframe(periods=32)
forecast = m.predict(future)
def multivariate(ds):
date = pd.to_datetime(ds)
if date.weekday() == 6:
return 1
else:
return 0
df['multivariate'] = df['ds'].apply(multivariate)
dff=df.rename(columns={'y':'causal','z':'y'})
p=Prophet(daily_seasonality = True,yearly_seasonality= True,weekly_seasonality=True)
p.add_regressor('causal')
p.fit(dff[0:120])
future1 = m.make_future_dataframe(periods=32)
kk=forecast['yhat'][120:]
kk=pd.DataFrame(kk,columns=['y'])
z=pd.concat([pd.DataFrame(df['y']),kk],ignore_index=True)
future1['causal']=z
forecast1=p.predict(future1)
forecast1[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
fig = m.plot_components(forecast1)
multivariate_data.xlsx
`
@kumarvrsec is the code not working? Can you paste the error if so? I'm not sure what the question is. As I noted before, you are not adding the multivariate column as an extra regressor (only causal) but I'm not sure if you're doing that intentionally.
@wendingp Not directly. You can check out my last comment in #49 for something you could try. Otherwise, the best you could do with Prophet is forecast each independently.
@bletham There is no error output given.The program is considering other variable as regressor.I think I am making error in adding the regressor in a correct manner.Can you please provide some pseudo code to do it.Thanks.
p.add_regressor('multivariate') should do it from what I can tell.
I'm going to close this and if there are more general discussion about multivariate time series it can be directed to #49.
Most helpful comment
Can prophet be used to predict multiple series like sales of each item instead of just one?