Safeguarding Demand Forecasting with Causal Graphs

Author:Murphy  |  View: 25497  |  Time: 2025-03-22 21:04:25

What is this series of articles about?

Welcome to my series on Causal AI, where we will explore the integration of causal reasoning into machine learning models. Expect to explore a number of practical applications across different business contexts.

In the last article we covered enhancing marketing mix modelling with Causal AI. In this article we will move onto safeguarding demand forecasting with causal graphs.

If you missed the last article on marketing mix modelling, check it out here:

Enhancing Marketing Mix Modelling with Causal AI

Introduction

In this article we will delve into how you can safeguard demand forecasting (or any forecasting use case to be honest) with causal graphs.

The following areas will be explored:

  • A quick forecasting 101.
  • What is demand forecasting?
  • A refresher on causal graphs.
  • How can causal graphs safeguard demand forecasting?
  • A Python case study illustrating how causal graphs can safeguard your forecasts from spurious correlations.

The full notebook can be found here:

causal_ai/notebooks/safeguarding demand forecasting with causal graphs.ipynb at main ·…

Forecasting

Forecasting 101

Time series forecasting involves predicting future values based on historical observations.

User generated image

To start us off, there are a number of terms which it is worth getting familiar with:

  1. Auto-correlation – The correlation of a series with it's previous values at different time lags. Helps identify if there is a trend present.
  2. Stationary – This is when the statistical properties of a series are constant over time (e.g. mean, variance). Some forecasting methods assume stationarity.
  3. Differencing – This is when we subtract the previous observation from the current observation to transform a non-stationary series into a stationary one. An important step for models which assume stationarity.
  4. Seasonality – A regular repeating cycle which occurs at a fixed interval (e.g. daily, weekly, yearly).
  5. Trend – The long term movement in a series.
  6. Lag – The number of time steps between an observation and a previous value.
  7. Residuals – The difference between predicted and actual values.
  8. Moving average – Used to smooth out short term fluctuations by averaging a fixed number of past observations.
  9. Exponential smoothing – Weights are applied to past observations, with more emphasis placed on recent values.
  10. Seasonal decomposition – This is when we separate a time series into seasonal, trend and residual components.
User generated image

There a a number of different methods which can be used for forecasting:

  • ETS (Error, Trend, Seasonal) – An exponential smoothing method that models error, trend and seasonality components.
  • Autoregressive models (AR models) – Models the current value of the series as a linear combination of it's previous values.
  • Moving average models (MA models) – Models the current value of the series as a linear combination of past forecast errors.
  • Autoregressive integrated moving average (ARIMA models) – Combines AR and MA models with the incorporation of differencing to make the series stationary.
  • State space models – Deconstructs the timeseries into individual components such as trend and seasonality.
  • Hierarchical models – A method which handles data structured in a hierarchy such as regions.
  • Linear regression – Uses one or more independent variable (feature) to predict the dependent variable (target).
  • Machine Learning (ML) – Uses more flexible algorithms like boosting to capture complex relationships.

If you want to dive further into this topic, I highly recommend the following resource which is well known as the go-to guide for forecasting (the version below is free

Tags: AI Causal Inference Data Science Machine Learning Programming

Comment