How to predict future days with fbprophet for multivariate data?

Viewed 253

I have trained the fbprophet model using multivariate data for 80% of train data and 20% test. I would like to train and predict data for 5 days into the future, using the same multivariate approach. Is it possible?

Multivariate training, without future dataframe, by using pm2.5 as the y value and as multivariate pm1 and pm10:


from fbprophet import Prophet

model=Prophet(interval_width=0.9)
model.add_regressor('pm1',standardize=False)
model.add_regressor('pm10',standardize=False)
model.fit(train_df)

This is the train_df:


ds  y   pm1 pm10
0   2021-01-24  19.323319   12.384626   22.172108
1   2021-01-25  5.711776    2.999815    6.212837
2   2021-01-26  12.394315   7.606718    14.562972
3   2021-01-27  9.960435    5.717829    11.890615
4   2021-01-28  13.411006   7.969926    15.812078
... ... ... ... ...
305 2021-12-08  16.802191   9.904556    20.286678
306 2021-12-09  26.608724   15.943576   33.398380
307 2021-12-10  29.786922   18.679419   36.415258
308 2021-12-11  28.983176   18.338050   36.787327
309 2021-12-12  11.622958   7.090400    14.120572
310 rows × 4 columns

This is the prediction :

forecast=model.predict(test_df)
forecast=forecast[['ds','yhat']]

And viewing the results of prediction vs real values:

result = pd.concat((forecast['yhat'], test_df), axis=1)


Here I tried to create the future dataframe for 5 days and to predict data:

future = model.make_future_dataframe(periods= 5, freq='D')

forecast_future = model.predict(future)
forecast_future[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()

But I am getting this error

ValueError: Regressor 'pm1' missing from dataframe

How could I use the same multivariate model to predict pm2.5 data into the future?

1 Answers

You need "future" data for your additional regressors

Options:

  1. Naively, use the last known value for future values
  2. Create "scenarios" for future values, such as "5% growth"
  3. Predict the values (independently) using Prophet (or any forecaster), then use those future values to predict Y. Ie, predict PM1 as "Y" without additional regressors, then same for PM10
Related