Note: The Prophet Algorithm is not a Neural Network. It is build to act as a benchmark to understand how the Neural Networks perform.

Facebook Prophet is an open-source algorithm for working with time series data. 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.
To understand the Math behind Prophet click here
#Load data and library
data = read.csv("data.csv")[,3]
date = read.csv("data.csv")[,1]
date = as.Date(date, format = "%d/%m/%Y")
library(ggplot2); library(forecast); library(prophet)
# Train and Test Dataset
train = ts(data[1:236], start = c(2001,1), frequency = 12)
test = as.numeric(tail(data, 12))We will use the first 236 values to train the model and the remaining 12 will be used to test forecasting power of Prophet for this dataset.
Prophet requires that the dates (in proper Date format) are located in a column named “ds” and values of the series in a column titled “y”.
df = data.frame(ds = date[1:236], y = data[1:236])
m = prophet(df)
future = make_future_dataframe(m, periods = 12, freq = 'month')forecast = predict(m, future)
plot(m, forecast) 
prophet_plot_components(m, forecast)
pred = tail(forecast$yhat, 12)
upper = tail(forecast$yhat_upper, 12)
lower = tail(forecast$yhat_lower, 12)
result = cbind(as.character(tail(date,12)), # Dates
as.numeric(round(test,2)), # Actual
as.numeric(lower), # Lower CI
as.numeric(round(pred,2)), # Prediction
as.numeric(upper)) # Upper CI
library(Metrics)
round(c(rmse(result$actual, result$pred),
mape(result$actual, result$pred)) ,5) ## [1] 78693.33947 0.07425
| U.S. Consumption of Electricity Generated by Natural Gas | ||
|---|---|---|
| Date | Actual1 | Predicted1 |
| Sep 1, 2020 | 1,006,071.14 | 1,015,378.18 |
| Oct 1, 2020 | 924,056.16 | 916,235.46 |
| Nov 1, 2020 | 737,935.17 | 841,314.31 |
| Dec 1, 2020 | 839,912.60 | 868,872.25 |
| Jan 1, 2021 | 833,783.30 | 864,478.30 |
| Feb 1, 2021 | 759,358.16 | 803,540.79 |
| Mar 1, 2021 | 715,165.06 | 869,791.23 |
| Apr 1, 2021 | 724,125.84 | 854,196.11 |
| May 1, 2021 | 787,027.16 | 920,158.92 |
| Jun 1, 2021 | 1,051,774.78 | 1,046,561.33 |
| Jul 1, 2021 | 1,199,673.32 | 1,233,024.69 |
| Aug 1, 2021 | 1,223,327.98 | 1,230,582.84 |
| Source: US Energy Information Adminstration | ||
|
1
Thousand Mcf
|
||