Facebook先知未来数据框

问题描述

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

gvSubmissionHeaders.DataKeys[CurrectRowNum]["cTableColumnID"]

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

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

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

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)

如何在未来的数据帧中获得明年的前4个月?是否有用于调整年份的特定参数?

解决方法

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

仅供参考,这是先知如何创建未来数据框:

    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”