【问题标题】:Holidays effect in FBProphet model is all zeroFBProphet 模型中的假期效应全为零
【发布时间】:2021-02-09 01:10:45
【问题描述】:

我有一个预测公司出货量的 Prophet 模型。当我添加特殊事件(促销和假期)时,它们似乎对模型的预测没有影响。难道我做错了什么?在我检查的所有示例中,假期总是对 Prophet 模型产生影响。

from fbprophet.make_holidays import make_holidays_df
import datetime
country_name= 'ES'
festivos=make_holidays_df([2017,2018,2019,2020],'ES')
festivos['dia']=0
for index, row in festivos.iterrows():
    festivos.loc[index,"dia"]='Festivo ' + str(datetime.datetime.weekday(festivos.iloc[index]["ds"]))
festivo2=pd.DataFrame({'holiday':festivos['dia'],'ds':festivos['ds'],'lower_window':-9,'upper_window':1,})
festivo1=pd.DataFrame({'holiday':festivos['holiday'],'ds':festivos['ds'],'lower_window':-9,'upper_window':1,})
festivo=pd.concat((festivo2,festivo1))
festivo=pd.DataFrame(festivo)
festivo
ph_home = Prophet(holidays=festivo)
ph_home.add_country_holidays(country_name='ES')
ph_home.fit(home_train)
fut_home= ph_home.make_future_dataframe(periods=6,freq='M')
pred_home=ph_home.predict(fut_home)
fig1 =ph_home.plot(pred_home)
a = add_changepoints_to_plot(fig1.gca(), ph_home, pred_home)
fig1=ph_home.plot_components(pred_home)
pd.concat([home_train.set_index('ds')['y'],pred_home.set_index('ds')['yhat']],axis=1).plot(figsize=(15,10))

Holidays effect in my Prophet model

The DataFrame I am using to train the prophet model

【问题讨论】:

  • 您可以发布您的数据样本吗?我将您的代码与 FBProphet 示例数据一起使用,它按您的预期工作。
  • 我使用的数据具有我猜预言模型所要求的正确形状:

标签: python facebook-prophet


【解决方案1】:

看起来是因为您的每月汇总。见最后注here。

With data that has been aggregated to weekly or monthly frequency, holidays that don’t fall on the particular date used in the data will be ignored

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-04-19
    • 1970-01-01
    • 2020-07-01
    • 1970-01-01
    • 2018-01-19
    • 2011-08-08
    • 1970-01-01
    • 2021-03-18
    相关资源
    最近更新 更多