Forecasting Using Facebook's Prophet Library
Forecasting Using Facebook's Prophet Library
1 of 11 11/8/2021, 2:24 PM
Forecasting Using Facebook’s Prophet Library | by Christoph... https://medium.com/analytics-vidhya/forecasting-using-face...
2 of 11 11/8/2021, 2:24 PM
Forecasting Using Facebook’s Prophet Library | by Christoph... https://medium.com/analytics-vidhya/forecasting-using-face...
drive.mount(‘/content/drive’, force_remount=True)
3 of 11 11/8/2021, 2:24 PM
Forecasting Using Facebook’s Prophet Library | by Christoph... https://medium.com/analytics-vidhya/forecasting-using-face...
df = pd.read_csv(‘../datasets/air_passenger.csv’)
df.head()
4 of 11 11/8/2021, 2:24 PM
Forecasting Using Facebook’s Prophet Library | by Christoph... https://medium.com/analytics-vidhya/forecasting-using-face...
df[‘ds’] = pd.to_datetime(df[‘ds’])
train = df[:-nobs]
test = df[-nobs:]
5 of 11 11/8/2021, 2:24 PM
Forecasting Using Facebook’s Prophet Library | by Christoph... https://medium.com/analytics-vidhya/forecasting-using-face...
future = prophet.make_future_dataframe(periods=nobs,
freq=’MS’)
6 of 11 11/8/2021, 2:24 PM
Forecasting Using Facebook’s Prophet Library | by Christoph... https://medium.com/analytics-vidhya/forecasting-using-face...
forecast = prophet.predict(future)
fig1 = prophet.plot(forecast)
fig1 = prophet.plot(forecast)
7 of 11 11/8/2021, 2:24 PM
Forecasting Using Facebook’s Prophet Library | by Christoph... https://medium.com/analytics-vidhya/forecasting-using-face...
forecast)
8 of 11 11/8/2021, 2:24 PM
Forecasting Using Facebook’s Prophet Library | by Christoph... https://medium.com/analytics-vidhya/forecasting-using-face...
# Remember nobs = 12
9 of 11 11/8/2021, 2:24 PM
Forecasting Using Facebook’s Prophet Library | by Christoph... https://medium.com/analytics-vidhya/forecasting-using-face...
y_pred = forecast.iloc[-nobs:][‘yhat’]
y_true = test['y']
rmse(y_pred, y_true)
10 of 11 11/8/2021, 2:24 PM
Forecasting Using Facebook’s Prophet Library | by Christoph... https://medium.com/analytics-vidhya/forecasting-using-face...
11 of 11 11/8/2021, 2:24 PM