我正在尝试对具有几个随机分布的峰值的时间序列进行预测。我确切地知道什么时候出现高峰,我通过假期数据框告诉先知。当我在拟合和预测后查看组件时,假期全为零。有什么我想念的吗?
这是我正在运行的代码:
# 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)
答案 0 :(得分:0)
这是大熊猫的问题。您必须从1.1.0(或更高版本)降级,因为它会破坏先知假期。有人建议将fbprophet更新为> = 0.7,但我在使用pystan时遇到了多个错误(使用fbprophet 0.7.1)。我现在使用pandas-1.0.5和Fbprophet 0.6。一切都按预期进行。