如何使用FBProphet来预测未来的日子,以获取多元数据?

发布于 2025-01-17 10:16:35 字数 1506 浏览 3 评论 0原文

我使用多元数据训练了 fbprophet 模型,其中 80% 是训练数据,20% 是测试。我想使用相同的多变量方法来训练和预测未来 5 天的数据。是否可以?

多变量训练,没有未来的数据帧,通过使用 pm2.5 作为 y 值以及多变量 pm1 和 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)

这是 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

这是预测:

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

并查看预测结果与实际值:

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


在这里我尝试创建未来5 天的数据帧并预测数据:

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

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

但我收到此错误

ValueError: Regressor 'pm1' missing from dataframe

如何使用相同的多元模型来预测未来的 pm2.5 数据?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖 2025-01-24 10:16:35

您需要额外的回归量的“未来”数据

选项:

  1. 天真地,使用最后一个已知值作为未来值
  2. 创建未来值的“场景”,例如“5% 增长”
  3. 使用 Prophet(或任何预测器)(独立)预测值,然后使用这些未来值来预测 Y。即,在没有额外回归量的情况下将 PM1 预测为“Y”,然后 PM10 也是如此

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文