Pandas Facebook Prophet未来数据框架

Pandas Facebook Prophet未来数据框架,pandas,time-series,forecasting,facebook-prophet,fbprophet,Pandas,Time Series,Forecasting,Facebook Prophet,Fbprophet,我有过去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',

我有过去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个月?是否有调整年份的特定参数?

该问题是因为日期格式,即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
因此,它推断出日期格式并在未来的数据帧中进行推断

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)

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