Prophet: Can't find function 'add_country_holidays'

Created on 16 Jan 2019  路  4Comments  路  Source: facebook/prophet

I am on 0.4 version of Prophet in RStudio, trying to add the country specific holiday, and get the error saying "Error in add_country_holidays(m, country_name = "de"): could not find function "add_country_holidays". The code I used are:

m2 <- prophet(predict_dat, 
             yearly.seasonality = TRUE, 
             weekly.seasonality = TRUE,
             daily.seasonality = FALSE 
)
add_country_holidays(m2, country_name = "de")

Anyone know how to fix this?

Most helpful comment

Germany is included (https://github.com/dr-prodigy/python-holidays), but do note that the name is case sensitive, so be sure to use 'DE' as indicated in the holidays package list.

This last error is probably what it indicates, that country holidays must be added prior to model fitting. I'm guessing that you did something like

m = Prophet()
m.fit(df)
m.add_country_holidays(country_name='DE')

but it should be

m = Prophet()
m.add_country_holidays(country_name='DE')
m.fit(df)

See https://facebook.github.io/prophet/docs/seasonality,_holiday_effects,_and_regressors.html#built-in-country-holidays, for example.

All 4 comments

I Suppose that there isn't a class for holidays in Germany. Please do cross check once and correct me if I am wrong.

I Suppose that there isn't a class for holidays in Germany. Please do cross check once and correct me if I am wrong.

I have tried "US", "United States", "us" (the one used in tutorial, and it now gave me this error. I am not sure what's going on.

Error in add_country_holidays(m, country_name = "us") :
Country holidays must be added prior to model fitting.

Germany is included (https://github.com/dr-prodigy/python-holidays), but do note that the name is case sensitive, so be sure to use 'DE' as indicated in the holidays package list.

This last error is probably what it indicates, that country holidays must be added prior to model fitting. I'm guessing that you did something like

m = Prophet()
m.fit(df)
m.add_country_holidays(country_name='DE')

but it should be

m = Prophet()
m.add_country_holidays(country_name='DE')
m.fit(df)

See https://facebook.github.io/prophet/docs/seasonality,_holiday_effects,_and_regressors.html#built-in-country-holidays, for example.

Got it, thank you!

Was this page helpful?
0 / 5 - 0 ratings