In [26]:
%matplotlib inline
import pandas as pd
import numpy as np
from fbprophet import Prophet
In [27]:
df = pd.read_csv('analytics-2017.pycon.ca-audience-overview_20170123-20170526.csv',
sep='\t', parse_dates=['Date'])
df.tail()
Out[27]:
In [28]:
df.set_index('Date').plot()
Out[28]:
In [29]:
df['Sessions'] = np.log(df['Sessions'])
df.set_index('Date').plot()
Out[29]:
In [30]:
df.columns = ['ds', 'y']
df.head()
Out[30]:
In [31]:
prophet = Prophet()
prophet.fit(df)
Out[31]:
In [32]:
future = prophet.make_future_dataframe(periods=365)
In [33]:
forecast = prophet.predict(future)
In [34]:
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
Out[34]:
In [35]:
np.exp(forecast[['yhat', 'yhat_lower', 'yhat_upper']].tail())
Out[35]:
In [36]:
prophet.plot(forecast)
Out[36]:
In [37]:
prophet.plot_components(forecast)
Out[37]:
In [ ]: