Nan Hanagud

6/29/2017

- What is Prophet
- Features

- Open Source (CRAN and PyPI)
- Time Series forecasting with model fitting in STAN
- CRAN Package : install.packages(‘prophet’)
- Start here https://facebookincubator.github.io/prophet/
- Intro for use in R and Python
- Read the paper

- Optimized for business forecasts
- seasonality, irregular holidays, historical trend changes, growth saturation points

- Customizable in ways intuitive to non-experts
- specify irregular holiday schedules, growth capacities, tweak parameters to fit

- Best with daily data with min one year of historical data.

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

g(t): growth function : Logistic growth model with non-constant carrying capacity with changepoints or linear growth model with changepoints. Changepoints are used to model changing rates of growth.

s(t): seasonality (weekly or yearly)

h(t): holidays

ε: error

- Fictional Sales Data
- A mostly 5 day week operation
- Standard US holidays are observed

- 2 Columns - ds and y (date and value)
- For a logistic growth model a “cap” field is needed at every row.

```
## ds y
## Min. :2015-01-01 Min. : 0
## 1st Qu.:2015-08-07 1st Qu.: 2
## Median :2016-03-13 Median : 9839
## Mean :2016-03-13 Mean : 7305
## 3rd Qu.:2016-10-18 3rd Qu.:10925
## Max. :2017-05-25 Max. :14694
```

Create a training set - let’s use 2 years so we can let it detect growth/seasonality.

```
df_train<- df[df$ds < as.Date("2017-01-01"),]
summary(df_train)
```

```
## ds y
## Min. :2015-01-01 Min. : 0
## 1st Qu.:2015-07-02 1st Qu.: 2
## Median :2016-01-01 Median :10015
## Mean :2016-01-01 Mean : 7384
## 3rd Qu.:2016-07-01 3rd Qu.:11023
## Max. :2016-12-31 Max. :14694
```

- Default assumption: Linear
- Can also specify a logistic growth model. Must provide a cap (historical and future)

`m <- prophet(df_train) future <- make_future_dataframe(m, periods=30) forecast <- predict(m,future)`

`m <- prophet(df_train) future <- make_future_dataframe(m, periods=90) forecast <- predict(m,future)`