如何使用FBProphet来预测未来的日子,以获取多元数据?
我使用多元数据训练了 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要额外的回归量的“未来”数据
选项:
You need "future" data for your additional regressors
Options: