Book Image

Forecasting Time Series Data with Prophet - Second Edition

By : Greg Rafferty
5 (1)
Book Image

Forecasting Time Series Data with Prophet - Second Edition

5 (1)
By: Greg Rafferty

Overview of this book

Forecasting Time Series Data with Prophet will help you to implement Prophet's cutting-edge forecasting techniques to model future data with high accuracy using only a few lines of code. This second edition has been fully revised with every update to the Prophet package since the first edition was published two years ago. An entirely new chapter is also included, diving into the mathematical equations behind Prophet's models. Additionally, the book contains new sections on forecasting during shocks such as COVID, creating custom trend modes from scratch, and a discussion of recent developments in the open-source forecasting community. You'll cover advanced features such as visualizing forecasts, adding holidays and trend changepoints, and handling outliers. You'll use the Fourier series to model seasonality, learn how to choose between an additive and multiplicative model, and understand when to modify each model parameter. Later, you'll see how to optimize more complicated models with hyperparameter tuning and by adding additional regressors to the model. Finally, you'll learn how to run diagnostics to evaluate the performance of your models in production. By the end of this book, you'll be able to take a raw time series dataset and build advanced and accurate forecasting models with concise, understandable, and repeatable code.
Table of Contents (20 chapters)
1
Part 1: Getting Started with Prophet
5
Part 2: Seasonality, Tuning, and Advanced Features
14
Part 3: Diagnostics and Evaluation

To get the most out of this book

To run the code examples in this book, you will need Python 3.x installed. All examples in this book were made using Prophet version 1.1 in Jupyter notebooks. macOS, Windows, and Linux are all supported. Although all examples in this book will be written in Python, everything is also fully compatible with R and you may use that language if you prefer, although this book will not cover R syntax. Please refer to the official Prophet documentation for R syntax (https://facebook.github.io/prophet/).

Chapter 2, Getting Started with Prophet, will walk you through installing Prophet, and installing either Anaconda or Miniconda is strongly recommended in order to correctly install all of Prophet’s dependencies. It is possible to install Prophet without using Anaconda, but it can be very difficult depending upon the specific configuration of your machine, and this book assumes that Anaconda will be used.

In order to follow the examples, you must at least be familiar with the pandas library for data processing and Matplotlib for making plots. In a few cases, the numpy library will be used to simulate random data but following the examples will not require that you know the NumPy syntax. All of these libraries will be installed automatically as Prophet dependencies, if not already installed. All datasets used in this book are hosted and can be downloaded from this book’s GitHub repository here: https://github.com/PacktPublishing/Forecasting-Time-Series-Data-with-Prophet-Second-Edition.

Software/hardware covered in the book

OS requirements

Prophet

Windows, macOS, or Linux (any)

Python 3.7+

Prophet supports parallelization with Dask but while setting Prophet up to run on a Dask cluster will be covered, installing and using Dask is beyond the scope of this book. If interested, I encourage you to refer to the Dask documentation at https://docs.dask.org/en/stable/. Similarly, this book will cover how to build interactive Prophet visualizations in Plotly but putting those together into a Dash dashboard will be left up to the reader to learn elsewhere. The Dash documentation at https://dash.plotly.com/ is a great place to start.

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to copying/pasting code.