facebook / prophet

Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth.
https://facebook.github.io/prophet
MIT License
18.47k stars 4.53k forks source link

New release of 'holidays' causes error #2036

Open mjbeattie opened 3 years ago

mjbeattie commented 3 years ago

The holidays package updated to 0.11.3.1 today. Prophet isn't working with the package and is throwing 'ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()', from...'

Installing older holidays (version 0.11.2) clears the error.

tcuongd commented 3 years ago

Heya, at first glance it looks like this bug: https://github.com/facebook/prophet/issues/2035#issuecomment-931444919 which should have been fixed with 0.11.3.1 Could you make sure that you're on the latest holidays version? (import holidays; holidays.__version__;)

Otherwise could you post the code you were running when you hit the error? I've run the full modelling pipeline with holidays on my machine and things seem to work ok:

import pandas as pd
df = pd.read_csv('examples/example_wp_log_peyton_manning.csv')

from prophet import prophet
import holidays
holidays.__version__
# 0.11.3.1

from holidays.utils import list_supported_countries
from copy import deepcopy
m = Prophet()
for c in list_supported_countries():
      m1 = deepcopy(m)
      print(c)
      m1.add_country_holidays(country_name=c)
      m1.fit(df)

I've also instantiated the custom holiday classes in the Prophet package, which also work:

import prophet.hdays as prophet_holidays
import numpy as np
years = np.arange(1995, 2045)
for var in vars(prophet_holidays):
    if re.search(r'^[A-Z]{2,3}$', var):
        print(var)
        hday = getattr(prophet_holidays, var)(years=years)