我正在尝试对具有多个随机分布峰值的时间序列进行预测。我确切地知道峰值何时出现,我用假期数据框告诉 Prophet。当我在拟合和预测之后查看组件时,假期都是零。有什么我想念的吗?
这是我正在运行的代码:
# create dummy data
from pandas import util
df= util.testing.makeTimeDataFrame(nper=150)
df['Amount']=np.random.randint(low=200, high=300, size=150)
df['ds']=df.index
df.drop(['A','B','C','D'],axis=1,inplace=True)
df.loc['2000-02-14','Amount'] = np.random.randint(low=1200, high=1300, size=1)
df.loc['2000-02-15','Amount'] = np.random.randint(low=1200, high=1300, size=1)
df.loc['2000-02-16','Amount'] = np.random.randint(low=1200, high=1300, size=1)
df.loc['2000-02-17','Amount'] = np.random.randint(low=1200, high=1300, size=1)
df.loc['2000-02-18','Amount'] = np.random.randint(low=1200, high=1300, size=1)
# load holidays dataframe
holidays=pd.DataFrame([['2000-02-14','Forbes Article ']],columns=['ds','holiday'])
holidays['ds']=pd.to_datetime(holidays['ds'])
# instantiate Prophet model
model1=Prophet(holidays=holidays)
# log transform the y variable to try to convert from non-stationary to stationary
df['y']=np.log(df['Amount'])
# Split data between train and test
split=int(len(df) * 0.8)
# Make train and test variables, with 'train, test'
train, test = df[0:split], df[split:len(df)]
# fit Prophet model with training data
model1.fit(train)
# run predict on all data - test and train
forecast = model1.predict(df)
# plot outcomes
model1.plot_components(forecast)