Blast Analytics and Marketing

Analytics Blog

Supporting Leaders to EVOLVE
hero image representing revenue forecasting model based on ai
Category: Analytics

A Neural Network to Help Predict Retail Sales

April 8, 2021

If you manage an ecommerce business, you might’ve noticed 2020 was a strange year. For many, online sales did something pretty interesting compared to the previous year, and some think stay-at-home orders were at the root of an observed 20+% increase in online shopping behavior.

While this is seemingly great news for retailers with an online business, there are many businesses concerned about adequately forecasting what to expect next and how to plan for supply chain management and staffing of customer service representatives.

Buying Trend, Behavior Modeling, and Predicting Future Patterns

Over the past few years, Blast Analytics’ ecommerce customers have enlisted our help to build revenue forecasting models for projections such as next business day revenues or even longer demand forecasting sometimes even down to the product stock-keeping unit (SKU) level. In this period of time where the “Buy Online Pickup In Store” trend is becoming the norm, as Blast’s Joe Christopher references in his recent blog post on digital experience measurement, it’s critical that retailers have the needed quantity of product available to avoid shortages when the demand appears.

… it’s critical that retailers have the needed quantity of product available to avoid shortages when the demand appears.

Since the data needed to forecast future revenues falls into a time series structure, the forecasting methodologies often enlist the use of tools that look at purchase patterns and trends over time.

One such recognized revenue forecasting approach is the popular seasonality-influenced autoregressive integrated moving average using exogenous data a modeling approach known as SARIMAX. Revenue forecasting models that utilize known approaches work very well when we have sufficient data historically that is representative of normal purchasing behaviors.

On the surface, how to forecast revenue is really quite straightforward: we have inputs and outputs, where the inputs are samples of historical data. We can look at this data and observe the resulting output. When we have sufficient examples of how inputs lead to specific outcomes, we have measurable confidence as to how to estimate a future outcome.

simple forecast revenue with inputs and outputs

SARIMAX is one of the more recognized time series methodologies, often used for revenue prediction forecasts. It’s a statistical process that looks at revenues over the past few years and predicts revenues that will happen today and in the near future. Of course, the modeling tool will look at a lot more than a static value from only one point in time. It’ll consider observed historic data trends and patterns considering various time intervals.

This category of revenue forecasting models do really well — up until the time where data seen today is vastly different from before. In other words, if the recent buying patterns being seen now hadn’t been in the data historically, deriving an accurate forecast will be difficult. The graph below is the time series of revenues for a single SKU from a retail client of ours. Note, there were some unprecedented spikes visually apparent that we couldn’t account for by looking at known sale days.

single sku revenue sarimax model

The Forecasting Question that Begs an Answer

What happens when buying behavior today isn’t like the buying patterns of last year, or even last month? Certainly the pandemic has recently — and may well continue into the foreseeable future — affect how consumers approach online shopping. In these unusual times, we’re starting to see traditional approaches yield less than desired results. We asked ourselves, “What can we do to better forecast sales?”

Some of the buzzwords of this decade have been “machine learning” and “artificial intelligence.” Can different tools or newer approaches do a better job of forecasting than traditional tools?

Traditional Time Series Forecasts

We observed that revenue patterns in the last few quarters of 2020 were completely different from previous historic patterns; forecasts for late November 2020 and early December 2020 were low and relatively flat when compared to the measured actual revenues.

traditional time series forecast chart

There are a lot of things you can do within the SARIMAX modeling approach to fine tune the model to be sensitive to recent trends, plus add in known periods where a sale is expected. The Facebook Prophet tool, for example, has the ability to add parametric factors to weight periodic intervals or to consider exogenous variables such as known historic holidays and sales.

Certainly, if you’re using a SARIMAX approach today, it’s best to try to run validations of newer data against the model and adjust it in methodical ways in an attempt to marginally improve its performance. A word of caution here is to note that “overfitting” can occur, which can make for a high amount of variability in the model, especially noticeable in the period of time following big sales or promotional periods. We have observed that revenue forecasting models may forecast a continuation of high sales in the days following Thanksgiving and Cyber Monday, even when the models know about those events.

A Different Approach: Neural Net

coworkers pointing at neural net on computer screen

But what about neural networks? Use of neural networks are on the rise to solve myriad real-world problems with the recognition that they mimic the human brain’s approach to learning patterns. The anticipation is they can be used to take inputs from historical data and output predictions and future values. When you start to look under the hood, you can see various configurations and designs for neural networks. For a time series problem, like our revenue prediction, we have to use the category known as recurrent neural networks (RNN), which is essentially a version that handles time intervals.

Use of neural networks are on the rise to solve myriad real-world problems with the recognition that they mimic the human brain’s approach to learning patterns.

There has even been research to jump-start a neural network system by taking inputs from known historic values plus SARIMAX predictions of future values. However, unlike SARIMAX, a neural network is a black box approach and has known issues when trying to utilize data extending too far back in time, plus adding exogenous inputs such as known holidays and sale days is all but impossible. Still, the promise of a RNN for forecasting is alluring.

RNN Time Series Forecasts

The hope is a recurrent neural network might look at the data in a very different way than other time series approaches. Being an attempt to mimic the brain by the use of hidden layers of neurons to remember various patterns uncovered in the data, perhaps what it sees, might just be better at working with data that is experiencing a high amount of irregularity.

After initial tests of an RNN for revenue forecasting, I was very pleased with the results of our neural network when run on the same revenue dataset. As mentioned, the RNN model doesn’t utilize additional outside influencers, but it did a good job anticipating trends. As I was looking at the results, it occurred to me that the forecast looked to be nicely influenced by recency — meaning the model appeared responsive to recent activities.

an rnn time series forecast chart

After running the neural network forecasts, it became clear that the approach was really good at being responsive to recent trends. This is really a good trait in many use cases, especially being used in revenue forecasting models. On the cautious side, a well-known time series expert, Aileen Nielsen, stated the following that rings true for our use case of wanting to balance a stable and yet robust revenue prediction tool:

“I don’t mind surfing a retailer’s website that uses machine learning to guesstimate my likely future actions as a buyer. But I’d like to know that the time series predictions that modeled my health outcomes or my child’s academic progressions were more thorough and were statistically validated, because a biased model could really hurt someone in these core areas.”

Neural networks appear to do a great job of patterning past behaviors and reacting quickly. SARIMAX models have the ability to use exogenous data which brings in domain-specific influencers and known seasonality trends. What I thought would be interesting is if we utilize both approaches.

What if We Use Both?

I ended up testing an equally weighted average of the two completely different approaches: SARIMAX with its stable ability to detect long historic patterns and RNN with its responsiveness to recency. Call this the “Getting a Second Opinion” approach.

At first, I was reticent. Why should I muddy the prediction value of one approach by introducing another? Couldn’t we just show both on a reporting dashboard?

Averaging the two recognizes that they’re both as right as they can be. The leap of faith is allowing each method’s forecast to nudge the other one, each analyzing historical data differently, then coming together to predict what might occur.

chart showing two revenue forecasting models combined

Get Started on Your Revenue Model

The more I looked at the results, the more it felt balanced. Our use case today, with the rise of unusual buying trends, demands that we try something new. In the end, time series revenue forecasting is simply a tool to help you plan for future needs, or to guide you in allocating resources towards future tasks. I present this outside-of-the-box concept with a level of anxiety knowing I so badly want to continue tweaking both revenue forecasting models to fine tune each of them as much as possible. I now recognize having two opinions presented from highly different methodologies is a way of presenting a single forecast, where having just one approach might have missed a notable trend.

Author’s Postscript Note: Since the writing of this post, we discovered Facebook has developed a NeuralProphet library for time series regression, whereby neural network regressors are also modeled using separate feed-forward neural networks. Of course, we don’t know if this enhancement was inspired by the interesting retail trends of 2020, but the evolution of time series tools will certainly offer us better accuracy in forecasting.

Paul Lear
About the Author

Paul is a Senior Analytics Consultant and Data Scientist at Blast. He has spent 20+ years venturing into the depths of software development, designing and implementing analytic solutions to automate business processes within all sizes of financial services institutions. Paul's experience spans software development, Business Intelligence design, eCommerce, database design, predictive modeling, and adaptive decision systems.

Connect with Paul on LinkedIn. Paul Lear has written on the Blast Digital Analytics Blog.

HIPAA and Analytics White Paper CTA

Featured White Paper

Healthcare Analytics and HIPAA: Ways to Minimize Risk and Ensure Compliance

The rise in digital data and analytics adds complexity and risk for healthcare organizations. Those that don’t comply with data privacy requirements, including Health Insurance Portability and Accountability Act (HIPAA), could face heavy fines, civil action lawsuits, and even criminal charges. Not to mention loss of patient trust.

Download the White Paper

Ready To Do More With Your Data?

If you have questions or you’re ready to discuss how Blast can help you EVOLVE your organization, talk to an Analytics Consultant today.

Call 1 (888) 252-7866 or contact us below.