Facebook Prophet Library
Facebook Prophet Library
Literature Review of Facebook Prophet Library for Time series Analysis
So for people like me who loves to watch an explanation before diving deep into a paper, i would suggest this simple but powerful intro to fbprophet library. Fortune-Telling with Python: An Intro to Facebook Prophet.
The next important article that i religiously went through was the release article mentioned in research fb blog. Prophet - Forecasting at Scale. Some very important parts are discussed at length in this blog about the functionalities of FB prophet.
Prophet is an Additive regression model with 4 main components.
- 
    
A piece wise linear or logistic growth curve trend. Prophet automaticaly detect changes in trends by selecting change points from the data.
 - 
    
A yearly seasonal component modelled using Fourier series.
 - 
    
A weekly seasonal component using dummy variables.
 - 
    
A user provided list of important holiday.
 
So after a little bit of research about introductory blogs and videos its time to look into the research paper of facebook-prophet it is available in this link facebook-prophet.
Introduction - talks about the importance of forecasting, time required for an analyst to become an expert forecaster, how fb prophet helps an analyst in his forecasting tasks. Fb-prophet intends to use the analyst in the loop approach where the model can be adjusted through various analyst friendly parameters.
Features of Business Time Series - Seasonal effects are visible in a time series, there might be a weekly cycle, yearly cycle, or a vacation based cycle. seasonal effects naturally arises and can be expected in a time series generated by human actions.
Prophet Forecasting Models - Forecasts are made at three points in the history using only portion of the time series up to that point. Forecasts  for each day are grouped and coloured by day of the week to visualize weekly seasonality. A Decomposible time series with 3 main model components are trend, seasonality and holidays. They are combined to an equationy(t)=g(t)+s(t)+h(t)+e where g(t) is the trend function, s(t) is the seasonality,  h(t) is the holiday . The formula looks very much similar to a Generalized Additive Model.
Here we have time as regressor with nonlinear functions of time as components. The GAM formulation has the advantage that it is easy to decompose and easy to accommodate components easily. Time series problem is considered as a curve fitting exercise instead of identifying the temporal dependence structure of the time series data.
Trend Modelling - trend can be a saturating growth model and piece wise linear model.
- Saturating growth model is typically modelled using a logistic growth model with a time varying factor ‘capacity’. we incorporate trend changes in growth model by explicitly defining changepoints where growth rate is allowed to change.
 - Similarly for linear piece wise model, a linear equation which changes withrespect to a time varying capacity and change points is formulated.
 
Changepoint Selection - changepoints could be specified by the analyst (as a parameter -list of change point dates). the list affects the trend and induces a change in trend.
Trend Forecast Uncertainty - when the model is extrapolated past the history to make a forecast, the trend will have a constant rate. uncertainities are induced into the model by extending the Generalized additive model. the future will see same average frequency and magnitude of rate changes.
Seasonality - Due to human behaviour business time series often have multi period seasonality. Fourier transform is used to capture the seasonality. the parameters required to fit a fourier transform is obtained by constructing a matrix of seasonality vector for each value of t.
Holiday and Events - They provide predicatable shocks in most real world time series analysis. this is kept as a parameter where any analyst could pass the list to create a model which looks into the seasonality factor.
Model Fitting -  so once seasonality, holiday features for each observation are combined into a matrix X and change point indicators a(t) in a matrix A, the entire model can be expressed in a few lines of Stan Code. The Stan actualy provides an easy interface to perform probablistic calculations like penalized maximum likelihood function(L-BFGS), approximate Bayesian inference  with variational inference, etc. Prophet uses decomposable model and allows us to look at each component of the forecast separately.
Analyst in Loop Modeling - Analyst can alter the model to apply there expertise and external knowledge with limited statistical knowledge.
- Capacity - analyst may have the external data for market size and can apply that knowledge directly by specifying capacities.
 - Changepoints - Analyst might know about certain shock days where abnormal values might come up. this can be directly specified.
 - Holidays and Seasonality - Holidays and seasonalities could be specifically mentioned.
 - Smoothing Parameters - By adjusting the smoothing parameter an analyst can select from a range of more global or locally smooth models.
 
The effort of the analyst could help in including judgemental and statistical forecasting and we can have a balance of both.
Automating the Evaluation of Forecast
- By use of baseline forecast - simplistic forecast is used to compare a set of baseline methods.
 - Modelling Forecast Accuracy - Forecast is made over a certain days like 90,180 days etc.
 - Let y(t)