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

Recent developments

The public release of Prophet has inspired a lot of open source activity around forecasting packages. Although Prophet remains the most widely used tool, there are several competing packages to keep an eye on.

NeuralProphet

Prophet has become so popular due to its ease of learning, quick predictions from data, and customizability. However, it does have some shortcomings; the key one among these is that it is a linear model. As discussed earlier in this chapter, neural networks are often used when forecasting tasks require a non-linear model, although an analyst must be very knowledgeable about both time series and applied machine learning to apply these models effectively. NeuralProphet (https://github.com/ourownstory/neural_prophet) aims to bridge this gap and allows an analyst with expertise only in time series to build a very strong neural model.

Oskar Triebe at Stanford University has built and optimized NeuralProphet for several years with the help of the open source community, but at the time of writing, NeuralProphet is still in the beta phase. It switches out Prophet’s dependency on the Stan language with PyTorch, thus enabling deep learning methods. NeuralProphet models time series autocorrelation with an Autoregressive Network (AR-Net) and models lagged regressors with a Feed-Forward Neural Network. The programming interface has been designed to be nearly identical to Prophet’s, so learning how to build models in NeuralProphet will be quite familiar to anyone already familiar with Prophet.

Google’s “robust time series forecasting at scale”

Not to be outdone, in April 2017, just 2 months after Facebook announced Prophet was being made open source, Google described their solution to the forecasting problem in their blog post Our quest for a robust time series forecasting at scale (https://www.unofficialgoogledatascience.com/2017/04/our-quest-for-robust-time-series.html). Unlike Prophet, Google’s package is not open source, so few details are publicly available. A key difference between Prophet’s and Google’s approaches is that Google’s forecasting package uses an ensemble method to forecast growth trends. In the time series context, this means that Google fits multiple forecast models, removes any outliers, and takes the weighted average of each individual model to arrive at a final model. At the time of writing, Google has not announced any plans to release its forecasting package to the open source community.

LinkedIn’s Silverkite/Greykite

Compared to Facebook and Google, LinkedIn is a relative newcomer to the open source forecasting community. In May 2021, LinkedIn announced their Greykite forecasting library for Python (https://github.com/linkedin/greykite), which uses their own Silverkite algorithm (the Prophet algorithms are also options within Greykite’s modeling framework). Greykite was developed to provide some key benefits to forecasting at LinkedIn: the solution must flexible, intuitive, and fast. If that sounds familiar, it’s because those are the very same qualities Facebook targeted when developing Prophet.

Whereas Prophet uses a Bayesian approach to fit a model, Silverkite uses more traditional models such as a ridge, elastic net, and boosted trees. Both Prophet and Silverkite can model linear growth, but only Silverkite can handle square root and quadratic growth. Prophet, however, can model logistic growth, something that Silverkite cannot do. Possibly the most exciting aspect of Silverkite from an analyst’s point of view is that domain expertise can easily be added to a model via external variables. Silverkite uses sklearn for its API, so any user familiar with that library should have no trouble ramping up with Silverkite.

Uber’s Orbit

At the same time that LinkedIn announced the Greykite library, Uber announced their own forecasting package, Object-Oriented Bayesian Time Series (Orbit) (https://github.com/uber/orbit). As the name suggests, Orbit is Bayesian just like Prophet. Orbit, however, was designed to be more generalizable than Prophet, bridging the gap between typical business problems and more complex statistical solutions.

Although Uber’s benchmarking indicates that Orbit performs well on all types of forecasting problems, its bread-and-butter use case is in marketing mix models, a technique to quantify the impact of several marketing inputs on sales. Orbit was implemented with two main types of Bayesian structural time series: Local Global Trend (LGT) and Damped Local Trend (DLT) models. Uber claims this approach shows competitive results compared to other models, including Prophet, with improved metrics ranging from 12% to 60%. Like Greykite, Orbit uses the sklearn paradigm to help new users onboard.