New Upload weather data from web services into TM1/Planning Analytics — Read the post →

Timeseries Forecasting with Facebook Prophet and TM1/Planning Analytics

Welcome to the last part of the articles series about Data Science with TM1/Planning Analytics and Python. In Part 1 we loaded weather data from the NOAA web service into our TM1 cubes. In Part 2, by analyzing the data with Pandas and Plotly, we learned that:

  • There are strong seasonal trends throughout the year

  • Public Holidays and weekends have a negative impact on the bike shares

  • Temperature and Bike shares are strongly correlated in every city

Objective

In this article, we are going to explain how to use Facebook's Prophet to create a two year demand forecast for bike sharing, based on four years of actuals from our TM1 cube.

Prophet

The idea behind the Prophet package is to decompose a time series of data into three components:

  • Trends — non-periodic and systematic trends in the data

  • Seasonal effects — modelled as daily or yearly periodicities in the data

  • Holidays / one-off effects — one-off effects for days like Black Friday, Christmas, etc.

Based on historic data, Prophet fits a model where each of these components contribute additively to the observed time series.

Step 1: Data Wrangling

The dataframe that Prophet needs has two columns: ds (dates) and y (numeric values).

Step 2: Fitting the model

Instantiate Prophet with public holidays from TM1 (via MDX) and fit the model:

Under the hood Prophet uses Stan to run the statistical calculations as fast as possible.

Step 3: Forecast the next 2 years

Create a dataframe with future dates and run the prediction:

Step 4: Analysing the forecast

The black dots correspond to the historic number of bike shares each day (2014-2018). The dark blue line represents the estimated number of shares. The light blue lines correspond to the 80% confidence interval.

To get further understanding of the fitted model, we can plot each of the model components:

Conclusion:

  • An overall global trend of growth from 2015, that slowed down slightly after 2016

  • Public holidays lead to a fall in the usage of the bikes

  • A strong weekly seasonality: bikes are used mostly during the week — presumably for commuting

  • A strong yearly seasonality with a peak in summer/autumn and a drop in winter

Step 5: Send the data back to TM1

Rearrange the data to match the TM1 cube dimensions and write values:

Years from 2014 to 2017 are actual data and the forecast starts in 2018.