Reader small image

You're reading from  Forecasting Time Series Data with Facebook Prophet

Product typeBook
Published inMar 2021
Reading LevelBeginner
PublisherPackt
ISBN-139781800568532
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Greg Rafferty
Greg Rafferty
author image
Greg Rafferty

Greg Rafferty is a data scientist in San Francisco, California. With over a decade of experience, he has worked with many of the top firms in tech, including Google, Facebook, and IBM. Greg has been an instructor in business analytics on Coursera and has led face-to-face workshops with industry professionals in data science and analytics. With both an MBA and a degree in engineering, he is able to work across the spectrum of data science and communicate with both technical experts and non-technical consumers of data alike.
Read more about Greg Rafferty

Right arrow

Creating the Prophet cross-validation DataFrame

To perform cross-validation in Prophet, first you need a fitted model. So, we'll begin with the same procedure we've completed throughout this book. This dataset is very cooperative so we'll be able to use plenty of Prophet's default parameters. We will plot the changepoints, so be sure to include that function with your other imports before loading the data:

import pandas as pd
import matplotlib.pyplot as plt
from fbprophet import Prophet
from fbprophet.plot import add_changepoints_to_plot
df = pd.read_csv('online_retail.csv')
df['date'] = pd.to_datetime(df['date'])
df.columns = ['ds', 'y']

This dataset does not have very complicated seasonality, so we'll reduce the Fourier order of yearly seasonality when instantiating our model, but keep everything else default, before fitting, predicting, and plotting. We'll use a 1-year future forecast:

model...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Forecasting Time Series Data with Facebook Prophet
Published in: Mar 2021Publisher: PacktISBN-13: 9781800568532

Author (1)

author image
Greg Rafferty

Greg Rafferty is a data scientist in San Francisco, California. With over a decade of experience, he has worked with many of the top firms in tech, including Google, Facebook, and IBM. Greg has been an instructor in business analytics on Coursera and has led face-to-face workshops with industry professionals in data science and analytics. With both an MBA and a degree in engineering, he is able to work across the spectrum of data science and communicate with both technical experts and non-technical consumers of data alike.
Read more about Greg Rafferty