【问题标题】:Time series forecasting- wrong result时间序列预测 - 错误的结果
【发布时间】:2021-11-28 09:59:09
【问题描述】:

我之前没有做过任何时间序列预测,我尝试根据每小时的日期时间段预测来自呼叫中心的总呼叫数据量。当我绘制预测时,数据被正确绘制,但预测偏离了。

这是我使用的代码。和入门的差不多。


df.rename(columns={'date':'ds','count':'y'},inplace=True)
df["ds"] = pd.to_datetime(df["ds"])
new_data=df[['ds','y']]

#input data to prophet model and forecast 
model = Prophet()
model.fit(new_data)
future = model.make_future_dataframe(periods=15)
forecast = model.predict(future)
fig = model.plot(forecast, xlabel='ds', ylabel='y')
plt.title('forecasting')
plt.show()

而且数据正在被使用,

       ds              y
2021-10-01 13:00:00   2871
2021-10-01 14:00:00   2545
2021-10-01 15:00:00   2426
2021-10-01 16:00:00   2446
2021-10-01 17:00:00    299

想知道我是否没有正确设计先知模型,代码或数据格式错误。

【问题讨论】:

  • 您查看过用于每日预测的 API 吗?您的数据是否完整且没有 NaN 等?对于每小时预测,您的数据是从 00:00:00 到 23:00:00。
  • 没有任何 NaN 值,它在时区 00.00 到 23.00。

标签: python pandas time-series forecasting facebook-prophet


【解决方案1】:

您正在处理非每日数据,并且您不想按小时粒度进行预测,但make_future_dataframe 默认情况下预测每日数据,正如您在 the prophet github 上看到的那样。

在您的代码中使用 model.make_future_dataframe(periods=15*24, freq='H') 以获取未来 15 天的每小时粒度图。

您可以使用prophet documentation for non daily data

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-13
    • 1970-01-01
    • 2023-03-14
    • 2020-10-05
    • 2013-09-26
    • 1970-01-01
    相关资源
    最近更新 更多