0

I am trying to run a forecast on a time series that has several randomly distributed peaks. I know exactly when the peaks occur and I am telling Prophet that with the holidays dataframe. When I look at the components after fit and forecast, the holidays are all zeroes. Is there something that I am missing?

Here is the code that I am running:

# 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)
  • 1
    In case anyone else ends up here, I found the problem. This is a known issue with FBProphet: https://github.com/facebook/prophet/issues/1617 – Nancy Kecso Aug 25 '20 at 13:53

1 Answers1

0

It's a problem with pandas. You have to downgrade from 1.1.0 (or above) because it breaks prophet holidays. Some people suggested updating fbprophet to >= 0.7 but I've experienced multiple errors with pystan (with fbprophet 0.7.1). I'm with pandas-1.0.5 and Fbprophet 0.6 now. Everything works as expected.