Git Product home page Git Product logo

time-serie-sales-forecasting-with-prophet's Introduction

Sales-forecasting-with-Prophet-and-Time-series

Use Facebook Prophet model to forecast Sales including seasonality patterns

In this notebook, Prophet model is used to forecast Sales at store level with high seasonality effects.

Dataset

The dataset used collects daily historical sales data from 1,115 Rossmann stores over 31 months resulting into 1+ million transaction records. In addition to transactions, the dataset includes information about promotions, competition and holiday periods at store level. This info is used to incorporate holidays during forecasting step. The dataset is available on kaggle here.

Facebook Prophet

At its core, the Prophet procedure is an additive regression model with four main components:

  • A piecewise linear or logistic growth curve trend. Prophet automatically detects changes in trends by selecting changepoints from the data.
  • A yearly seasonal component modeled using Fourier series.
  • A weekly seasonal component using dummy variables.
  • A user-provided list of important holidays.

Key points:

  • Prophet will provide a components plot which graphically describes the model it has fit.
  • The input to Prophet is always a dataframe with two columns: ds and y. The ds (datestamp) column should be of a format expected by Pandas, ideally YYYY-MM-DD for a date or YYYY-MM-DD HH:MM:SS for a timestamp. The y column must be numeric, and represents the measurement we wish to forecast.
  • A quick introduction is available here.

Project structure

  1. Exploration and cleaning of the data.
  • Sales reveal a high seasonality at multiple timescale: during the year, within a month and also during a typical week. The seasonality is illustrated below.

  • The analysis also indicates a positive impact from promotions on sales and customer frequentation.

  1. Forecasting using Prophet
  • without information on holidays
  • including detailed information on holiday periods
  1. Performance evaluation
  • Prophet performs very well when seasonality is high. The model's performance is evaluated using RMSE metric (root mean square error). It shows that the error remains constant over the projected horizon.
  • 90 days horizon example:

Results

Forecast over 90 days example:

The additive model analyzes variations at multiple levels:

  • long-term base trend
  • seasonal patterns (yearly, monthly, weekly and daily)
  • impact from holidays. In the last picture below, we see the holiday pattern (national and state-wise, it includes also all school holidays) with spikes which may influence sales. These are integrated as an input into the forecasting model.

Performance evaluation with 15 days horizon:

Dependencies

  • Facebook Prophet (pip install fbprophet)

Next

  • benchmark prediction performance against other models :
    • DeepAR (Amazon for powerful time series forecasting)
    • LSTM network
    • XGBoost
    • StatModels
    • Others

time-serie-sales-forecasting-with-prophet's People

Contributors

laurentveyssier avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.