Detecting Retail Sales Trends with Machine Learning


Navigation: Retail Anaplan Group Home | Forum | Get Started - Content Directory

Retail Knowledge | Detecting Trend

Using machine learning to detect a sales trend is a science and an art. Obviously no computer program or set of calculations could ever know everything that’s going on with your business. The creative side of detecting a trend is built upon your familiarity with the way your business or customer behaves. While some of these nuances can be reduced to numbers other conditions cannot be predicted easily and will continually require your input. To get you started, I will show you some high level techniques using minimal math that you can use to teach 

Anaplan to detect sales trends.

At the heart of machine learning is the ability to use historical information to self-correct, or learn from, prior decisions. When you measure the difference between your forecasted sales and your actual sales, you are measuring the forecast error.

Forecasting error is the difference between your forecasted sales and the actual sales.

One rather simple method for sales trend detection is to make the distinction between two forecasting concepts:

  • Magnitude measures the |absolute| value of your forecast errors, which is nothing more than the difference between your forecast and actual. If the average direction calculation is small compared to the magnitude then the trend is very small. Conversely, if the direction calculation is close to the magnitude then the trend is quite large.
  • Direction measures the sign, or how high or how low, your forecasts are from actual. A positive or negative sign will tell you what direction is the trend. If your average signed errors are equally high as they are low, then the direction will equal zero and no trend will be detected.

Combining these two will give your trend calculation both direction and velocity:


Say we have a product that has sales and forecasts for the last eight weeks that looks like this:.


For the first four weeks our forecast algorithm is working great. Then, on week 5, we had a very large forecast error of 29. This is where the art of machine learning comes in. We need to give Anaplan some smarts about how to handle the errors. Since this is only one week, we can tell the program to slightly nudge up our forecast.

On week 6 and 7, we missed it again in the same direction. Now we teach our software to chase the trend a little faster, so that by week 8, we’re very close to forecasting the sales correctly.

Had the errors averaged out to zero over the last four weeks, we teach Anaplan to interpret the errors as noise.

This is how many machine learning algorithms work for detecting trend. In the example, I showed you a very simple model of how we can use week to week sales to auto-correct the next week’s forecast. As you can imagine there are a lot of nuances to deal with and your business knowledge will help you tremendously. Try not to over-fit though. It’s tempting, I admit, but the computing effort will go up exponentially compared to the benefit you will get.

For further reading on this topic I suggest reading the post on variable response smoothing. This article will give you the details and the math needed to fully implement a machine learning program.

0 Kudos
Version history
Last update:
‎11-08-2020 12:36 PM
Updated by:
About the Author
  • Jared’s passion for retail trace back to his high school days when he sold cinnamon toothpicks to his classmates and when he learned firsthand the concept of inventory management, cost of goods sold and how to make a tidy profit. After being introduced to retail planning solutions as a buyer at Target Stores, he’s been on a personal journey ever since to help retail practitioners reach their potential by using software solutions that effectively enable their processes. Recently named a 2022 Master Anaplanner and Community Boss, Jared provides retailers, wholesalers, and ecommerce planners the rigor, training, and positive thinking needed to help them fully optimize their Anaplan platform. Prior to starting Retailitix, a consultancy focused on Anaplan for the retail industry, Jared was a retail IT executive for Target, Tuesday Morning, Payless, and Ascena.