【问题标题】:Facebook Prophet Future DataframeFacebook Prophet 未来数据框
【发布时间】:2021-02-02 05:35:22
【问题描述】:

我有过去 5 年的月度数据。我正在使用它来创建使用 fbprophet 的预测模型。我最近5个月的数据如下:

data1['ds'].tail()

Out[86]: 55   2019-01-08
56   2019-01-09
57   2019-01-10
58   2019-01-11
59   2019-01-12

我已经在此基础上创建了模型并制作了未来的预测数据框。

model = Prophet(
    interval_width=0.80,
    growth='linear',
    daily_seasonality=False,
    weekly_seasonality=False,
    yearly_seasonality=True,
    seasonality_mode='additive'
)

# fit the model to data
model.fit(data1)

future_data = model.make_future_dataframe( periods=4, freq='m', include_history=True)

2019 年 12 月之后,我需要下一年的前四个月。但它会在 2019 年的同一年增加接下来的 4 个月。

future_data.tail()

    ds
59  2019-01-12
60  2019-01-31
61  2019-02-28
62  2019-03-31
63  2019-04-30

如何在未来的数据框中获得下一年的前 4 个月?有什么具体的参数可以调整年份吗?

【问题讨论】:

    标签: pandas time-series forecasting facebook-prophet


    【解决方案1】:

    问题是由于日期格式,即 2019-01-12 的格式为“%Y-%m-%d” 因此,它会为接下来的 4 个期间创建具有月末频率(以“m”表示)的数据。

    以下是 Prophet 创建未来数据帧的方式仅供参考:

        dates = pd.date_range(
            start=last_date,
            periods=periods + 1,  # An extra in case we include start
            freq=freq)
        dates = dates[dates > last_date]  # Drop start if equals last_date
        dates = dates[:periods]  # Return correct number of periods
    

    因此,它推断日期格式并在未来的数据帧中进行推断。

    解决方法:将训练数据中的日期格式改为“%Y-%d-%m”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多