Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News Sign UpSign In
| Download
Project: Testing 18.04
Views: 312
Kernel: Python 3 (system-wide)

Prophet on CoCalc

Forecasting at scale!

https://facebook.github.io/prophet/

import pandas as pd from fbprophet import Prophet
fn = "example_wp_log_peyton_manning.csv"
! wget -q -O $fn https://raw.githubusercontent.com/facebook/prophet/master/examples/example_wp_log_peyton_manning.csv
df = pd.read_csv(fn) df.head()
ds y
0 2007-12-10 9.590761
1 2007-12-11 8.519590
2 2007-12-12 8.183677
3 2007-12-13 8.072467
4 2007-12-14 7.893572
m = Prophet() m.fit(df)
INFO:fbprophet:Disabling daily seasonality. Run prophet with daily_seasonality=True to override this.
<fbprophet.forecaster.Prophet at 0x7f1715940048>
future = m.make_future_dataframe(periods=365) future.tail()
ds
3265 2017-01-15
3266 2017-01-16
3267 2017-01-17
3268 2017-01-18
3269 2017-01-19
forecast = m.predict(future) forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
ds yhat yhat_lower yhat_upper
3265 2017-01-15 8.199274 7.437537 8.908045
3266 2017-01-16 8.524244 7.845854 9.226016
3267 2017-01-17 8.311615 7.573729 9.070347
3268 2017-01-18 8.144232 7.485096 8.875287
3269 2017-01-19 8.156091 7.437957 8.821215
fig1 = m.plot(forecast)
Image in a Jupyter notebook
fig2 = m.plot_components(forecast)
Image in a Jupyter notebook