Facebook Prophet

What is Facebook Prophet? Prophet is a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well.

While advancements in data science often increase the infamous “skills gap” surrounding the field, Prophet was intentionally designed to lower the cost of entry for analysts — who possess an “in-the-loop” understanding of the problems they are trying to solve — with automated of time series forecasting.

The procedure makes use of a decomposable time series model with three main model components: trend, seasonality, and holidays.

y(t) = g(t) + s(t) + h(t) + e(t)

g(t) = trend models non-periodic changes; linear or logistic

s(t) = seasonality represents periodic changes; i.e. weekly, monthly, yearly

h(t) = ties in effects of holidays; on potentially irregular schedules ≥ 1 day(s)

The error term e(t) represents any idiosyncratic changes which are not accommodated by the model; later we will make the parametric assumption that e(t) is normally distributed.

Load Packages

packages <- c("tidyverse", "prophet")

packages <- lapply(packages, FUN = function(x) {

if(!require(x, character.only = TRUE)) {install.packages(x)

library(x, character.only = TRUE)}})

Load Dataset

df <- data.frame(date=time(LakeHuron), level=as.matrix(LakeHuron))

Format time series data

df$date <- as.numeric(df$date)

df$date <- as.Date(df$date, format = "%Y-%m-%d")

Prophet expects input data to have 2 columns, ds and y.

df <- df %>% dplyr::select(date, level)

names(df) <- c('ds', 'y')

Examine structure


'data.frame':98 obs. of 2 variables:

$ ds: Date, format: "1875-01-01" "1876-01-01" "1877-01-01" ...

$ y : num 580 582 581 581 580 ...

Making a Forecast

Forecasts need somewhere to go, so we need to first make a Prophet model (m) based on our data (df), and have it make an empty future dataframe (future) for our desired number of periods (days in our case) that will be forecast (let’s do a year).

m <- prophet(df)

future <- make_future_dataframe(m, periods=365)

# head(future, 5)

Make Forecast Prediction

forecast <- predict(m, future)

Visualize Forecast

Visualizing the forecast is made easy with plot();

plot(m, forecast)

Decomposing a Forecast

While there’s a lot put out by the forecast, we can focus on a few keys like;

To understand the forecast more intemently, we can plot its components with;

prophet_plot_components(m, forecast)


Sabalico Logo
Sabali Mail Logo
Domain Search Logo
Test Speed Logo
Website On Logo
Page Load Logo
Code Editor Logo
Format Code Logo
HTML Validator Logo
CSS Validator Logo
ASCII Table Logo
HTML Symbols Logo
Emoji Symbols Logo
Encode File Logo
Sitemap Generator Logo
Generator Password Logo
QR Code Generator Logo
Barcode Generator Logo
Online Sign Logo
Dictionary Online Logo
Counter Word Logo
Text Convert Logo
Lorem Ipsum Generator Logo
Sprite Sheet Logo
Edit Picture Logo
Resize Image Logo
Image Compress Logo
Image Color Logo
Image Crop Logo
Combine Images Logo
Favicon Generator Logo
Color Palette Logo
Color Picker Logo
Color Mix Logo
Color Convert Logo
CSS Gradient Logo
To-Do List Logo
Calendar Free Logo
Generator Meme Logo
Word Spinner Logo
Phone Country Logo
Sabalytics Logo
Senty Logo
World Map Logo
SEO Guide Logo
Keyword Tool Logo
What is my IP Logo
My Device Logo
My Browser Logo
My Location Logo
Time Zone Logo
Day Map Logo
My Weather Logo
My Galaxy Logo
The Moon Logo
Periodic Table Logo
rStatistics Logo
Unit Convert Logo
Data Convert Logo
Coordinate Converter Logo
Temperature Convert Logo
2020 Election Logo
Sabali Finance Logo
Currency Convert Logo
Free Calculator Logo
Finance Calculator Logo
Loan Calculator Logo
Calculator Mortgage Logo
Stock Calculator Logo
Bond Calculator Logo
Tax Calculator Logo
Tip Calculator Logo
Gas Mileage Logo
History of Humanity - History Archive Logo
History of Humanity - History Mysteries Logo
History of Humanity - Ancient Mesopotamia Logo
History of Humanity - Egypt History Logo
History of Humanity - Persian Empire Logo
History of Humanity - Greek History Logo
History of Humanity - Alexander the Great Logo
History of Humanity - Roman History Logo
History of Humanity - Punic Wars Logo
History of Humanity - Golden Age of Piracy Logo
History of Humanity - Revolutionary War Logo
History of Humanity - Mafia History Logo