【问题标题】:Predicting Future With FBProphet使用 FBProphet 预测未来
【发布时间】:2021-04-14 18:14:17
【问题描述】:

我一直在使用 fbprophet 进行时间序列预测。我有以下数据框:

我尝试使用以下代码进行未来预测,并希望预测未来 30 年:

p_model = Prophet()

df_plot = df_grouped.copy()
df_plot = df_plot.reset_index()
total_vehicles = df_plot.groupby(['year'])['all_motor_vehicles_miles'].sum()
total_vehicles = total_vehicles.reset_index()
total_vehicles['total_miles'] = total_vehicles['all_motor_vehicles_miles'] * 365

total_vehicles[['y', 'ds']] = total_vehicles[['total_miles', 'year']]

p_model.fit(total_vehicles)
future = p_model.make_future_dataframe(periods=30, freq='Y')
forecast = p_model.predict(future)
forecast.head()

但是,在策划这个时,先知预测的是过去而不是未来 2020 年到 2050 年的未来,我不确定为什么?

有人知道为什么会出现这种情况以及如何解决吗?干杯

【问题讨论】:

    标签: python time-series facebook-prophet prophet


    【解决方案1】:

    问题在于我的日期不是正确的日期时间格式。只需确保类型是正确的,然后将其放入先知中即可得到正确的答案。

    total_vehicles['year'] = pd.to_datetime(total_vehicles['year'], format='%Y')
    

    【讨论】:

      猜你喜欢
      • 2019-04-19
      • 2021-03-06
      • 2019-08-09
      • 2017-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-24
      相关资源
      最近更新 更多