Is it possible to do multivariate multi-step forecasting using FB Prophet? Is it possible to do multivariate multi-step forecasting using FB Prophet? python python

Is it possible to do multivariate multi-step forecasting using FB Prophet?


You can add additional variables in Prophet using the add_regressor method.

For example if we want to predict variable y using also the values of the additional variables add1 and add2.

Let's first create a sample df:

import pandas as pddf = pd.DataFrame(pd.date_range(start="2019-09-01", end="2019-09-30", freq='D', name='ds'))df["y"] = range(1,31)df["add1"] = range(101,131)df["add2"] = range(201,231)df.head()            ds  y   add1 add20   2019-09-01  1   101 2011   2019-09-02  2   102 2022   2019-09-03  3   103 2033   2019-09-04  4   104 2044   2019-09-05  5   105 205

and split train and test:

df_train = df.loc[df["ds"]<"2019-09-21"]df_test  = df.loc[df["ds"]>="2019-09-21"]

Before training the forecaster, we can add regressors that use the additional variables. Here the argument of add_regressor is the column name of the additional variable in the training df.

from fbprophet import Prophetm = Prophet()m.add_regressor('add1')m.add_regressor('add2')m.fit(df_train)

The predict method will then use the additional variables to forecast:

forecast = m.predict(df_test.drop(columns="y"))

Note that the additional variables should have values for your future (test) data. If you don't have them, you could start by predicting add1 and add2 with univariate timeseries, and then predict y with add_regressor and the predicted add1 and add2 as future values of the additional variables.

From the documentation I understand that the forecast of y for t+1 will only use the values of add1 and add2 at t+1, and not their values at t, t-1, ..., t-n as it does with y. If that is important for you, you could create new additional variables with the lags.

See also this notebook, with an example of using weather factors as extra regressors in a forecast of bicycle usage.


To do forecasting for more than one dependent variable you need to implement that time series using Vector Auto Regression.

In VAR model, each variable is a linear function of the past values of itself and the past values of all the other variables.

for more information on VAR go to https://www.analyticsvidhya.com/blog/2018/09/multivariate-time-series-guide-forecasting-modeling-python-codes/


I am confused, it seems like there is no agreement if Prophet works in multivariate way, see the github issues here and here. Judging by some comments, queise's answer and a nice youtube tutorial you can somehow make a work around to multivariate functionality, see the video here: https://www.youtube.com/watch?v=XZhPO043lqU