是否可以使用FB Prophet进行多变量多步预测? [英] Is it possible to do multivariate multi-step forecasting using FB Prophet?

查看:1856
本文介绍了是否可以使用FB Prophet进行多变量多步预测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个多变量(100多个变量),多步(t1到t30)的预测问题,其中时间序列频率是每1分钟一次.问题需要预测100多个变量之一作为目标. 我很想知道是否可以使用FB Prophet的Python API做到这一点.我能够仅使用目标变量和日期时间变量以单变量方式进行操作.任何帮助和指导表示赞赏.请让我知道在这个问题上是否需要任何进一步的输入或澄清.

I'm working on a multivariate (100+ variables) multi-step (t1 to t30) forecasting problem where the time series frequency is every 1 minute. The problem requires to forecast one of the 100+ variables as target. I'm interested to know if it's possible to do it using FB Prophet's Python API. I was able to do it in a univariate fashion using only the target variable and the datetime variable. Any help and direction is appreciated. Please let me know if any further input or clarity is needed on the question.

推荐答案

您可以使用例如,如果我们想同时使用附加变量add1add2的值来预测变量y.

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

首先创建一个示例df:

Let's first create a sample df:

import pandas as pd
df = 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 add2
0   2019-09-01  1   101 201
1   2019-09-02  2   102 202
2   2019-09-03  3   103 203
3   2019-09-04  4   104 204
4   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"]

在训练预测器之前,我们可以添加使用其他变量的回归器.在这里,add_regressor的参数是训练df中附加变量的列名.

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 Prophet
m = Prophet()
m.add_regressor('add1')
m.add_regressor('add2')
m.fit(df_train)

然后predict方法将使用其他变量进行预测:

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

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

请注意,其他变量应具有用于您将来(测试)数据的值.如果没有它们,可以先使用单变量时间序列预测add1add2,然后使用add_regressor预测y并将预测的add1add2作为附加变量的未来值变量.

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.

从文档中我了解到,对于t + 1的y预测将仅使用t + 1处的add1add2值,而不使用t,t-1等处的值. .,tn,与y一样.如果这对您很重要,则可以使用滞后时间创建新的其他变量.

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.

这篇关于是否可以使用FB Prophet进行多变量多步预测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆