Hi,
I had setup fbprophet for use in a JupyterLab environment on Win10 2 weeks ago and everything was going fine. I had to do the setup again this week and now the holidays are not being recognized anymore. I can reproduce this on another machine as well. It seems there was a release of some new package version in a dependency that seems to break this, but I can't figure out which.
This is the environment.yaml I use to create the conda environment:
name: fbprophet-jupyter
channels:
- conda-forge
- msys2
- defaults
dependencies:
- python=3.7
- cython
- jupyterlab
- nodejs
- cx_oracle
- sqlalchemy
- plotly
- matplotlib==3.2.2
- fbprophet
matplotlib is set to 3.2.2 since the 3.3.0 release also slowed down plotting in fbprophet a lot. But that's another issue ;)
Any pointers or help are welcome and thank you for the awesome tool 馃憤
Best regards
Michael
Just some update: I tried this with the official miniconda docker image (https://hub.docker.com/r/continuumio/miniconda/) as well, to be sure it is not some weird settings in my Windows/Anaconda. I can reproduce it there as well. Used the same environment file to create the environment, ran a jupyter lab and executed the following code:
%matplotlib inline
import numpy as np
import pandas as pd
from fbprophet import Prophet
dates = pd.date_range('2018-01-01', '2019-12-31')
annual = np.sin(2 * np.pi * (dates.dayofyear.values / 366 - 0.28))
noise = 15 * np.random.rand(annual.size)
def is_holiday(ds):
date = pd.to_datetime(ds)
return 1 if date.dayofweek==1 and date.day<8 else 0
holiday_noise = np.array([45*is_holiday(ds) for ds in dates])
data = 10 + (5 * annual) + noise + holiday_noise
s = pd.Series(data, index=dates)
df = s.to_frame().reset_index()
df = df.rename(columns={"index": "ds", 0: "y"})
df["my_holiday"] = df.ds.apply(is_holiday)
holidays = pd.DataFrame({'holiday': 'my_holiday',
'ds': [date for date in dates if date.dayofweek==1 and date.day<8],
'lower':0,
'upper':0})
m = Prophet(holidays=holidays)
m.fit(df)
future = m.make_future_dataframe(periods=31)
forecast = m.predict(future)
fig_forecast = m.plot(forecast)
This produced the following plot/output:

On the other hand, if I passed the holiday as an additional regressor it works:
m2 = Prophet()
m2.add_regressor("my_holiday")
m2.fit(df)
future2 = m2.make_future_dataframe(periods=31)
future2["my_holiday"] = future2.ds.apply(is_holiday)
forecast2 = m2.predict(future2)
fig_forecast2 = m2.plot(forecast2)

This confuses me a bit, since as far as I understand the holidays parameter is just a convenient wrapper around the additional regressor interface for allowing easier definition and providing lower and upper bounds.
Really hope you can help.
Edit: Tried it with a python:3.7 image and pip install jupyterlab fbprophet as well. Same results.
Can confirm this issue. It is probably related to prophet's requirements.txt using >= versioning. Some package seems to break the holidays logic.
So I went through the code, only thing that could break it is pandas. So I reverted that to 1.0.5 and it is working again. Don't know what in the new release is breaking it, but at least with this we can reset it.
Most helpful comment
So I went through the code, only thing that could break it is pandas. So I reverted that to 1.0.5 and it is working again. Don't know what in the new release is breaking it, but at least with this we can reset it.