--- title: Adapters for Prophet keywords: fastai sidebar: home_sidebar nb_path: "nbs/adapters.prophet.ipynb" ---
import sys
sys.version_info >= (3, 7)
df = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/examples/example_wp_log_peyton_manning.csv')
Usually, a Prophet pipeline without external regressors looks like this.
m = Prophet()
m.fit(df)
future = m.make_future_dataframe(365)
forecast = m.predict(future)
fig = m.plot(forecast)
With the class AutoARIMAProphet
you can simply replace Prophet
and you'll be training an auto_arima
model without changing the pipeline.
%%capture
m = AutoARIMAProphet()
m.fit(df)
future = m.make_future_dataframe(365)
forecast = m.predict(future)
fig = m.plot(forecast)
Usually Prophet
pipelines include the usage of external regressors such as holidays.
playoffs = pd.DataFrame({
'holiday': 'playoff',
'ds': pd.to_datetime(['2008-01-13', '2009-01-03', '2010-01-16',
'2010-01-24', '2010-02-07', '2011-01-08',
'2013-01-12', '2014-01-12', '2014-01-19',
'2014-02-02', '2015-01-11', '2016-01-17',
'2016-01-24', '2016-02-07']),
'lower_window': 0,
'upper_window': 1,
})
superbowls = pd.DataFrame({
'holiday': 'superbowl',
'ds': pd.to_datetime(['2010-02-07', '2014-02-02', '2016-02-07']),
'lower_window': 0,
'upper_window': 1,
})
holidays = pd.concat((playoffs, superbowls))
%%capture
m = Prophet(holidays=holidays)
m.add_country_holidays(country_name='US')
m.fit(df)
future = m.make_future_dataframe(365)
forecast = m.predict(future)
fig = m.plot(forecast)
The class AutoARIMAProphet
allows you to handle these scenarios to fit an auto_arima
model with exogenous variables.
%%capture
m = AutoARIMAProphet(holidays=holidays)
m.add_country_holidays(country_name='US')
m.fit(df)
future = m.make_future_dataframe(365)
forecast = m.predict(future)
fig = m.plot(forecast)