July 20, 2020

Using Machine Learning to predict sales and anticipate demand

Eliott Kalfon
Eliott Kalfon Data Scientist

Business challenge:

Data Science
Machine Learning
Sales Forecasting
Sales Performance

How many staff should be hired? How much stock should be ordered? How much revenue can be expected in August? All these questions show how central sales forecasting is to business planning.

Without proper sales forecasting, many business decisions are based on unreliable estimates or instinct – which leads to many inefficiencies and missed opportunities. 

In this context, rigorous sales forecasting has great potential to generate value. This blog post will describe how to leverage Machine Learning to accurately predict sales and plan accordingly

Instead of applying assumptions and a complex set of rules in an unwieldy Excel workbook, Machine Learning models learn patterns from the data to generate predictions. This way, if the underlying trends change, the model can be retrained, and learn these changes. Also, statistical learning algorithm can discover patterns missed by business analysts. 

Using Machine Learning instead of an Excel model makes the forecasting process much more traceable. The prediction algorithm can be run on a cloud Machine Learning environment or a Virtual Machine and write predictions directly to a database. These predictions could then be distributed to business users through interactive dashboards. This way, there is a single source of truth for the entire company. A centrally run and managed algorithm is more secure, more adaptable and more efficient. 

What is sales forecasting? 

A sales forecast is an estimation of future sales. This estimation can be based on past values, economic indicators, seasonality, weather forecasts…

There are two main types of sales forecasting: 

  1. 1. Rule-based forecasting: In rule-based forecasting, predictions are generated using a set of manually developed rules and assumptions based on past data and known trends. As an example, if business analysts notice that sales have been consistently growing by 5% each year, they could apply the following forecasting rule: 

Sales Tomorrow = Sales Last Year * 1.05 

This is a simplifying example, rule-based forecasting could quickly become very complex, opaque and hard to audit. Also, if the growth rate suddenly jumps from 5% to 15%, using this type of rules could lead to misleading estimates and missed business opportunities. 

2. Machine Learning forecasting: Machine learning algorithms would learn the rules that would have to be manually designed in rule-based forecasting. This is done through a process called supervised learning. Supervised learning is the task of learning the relationship between outputs (sales) and inputs (past sales, economic indicator, holiday calendar etc.) Machine Learning algorithms find these relationships by minimising prediction error – i.e. finding the relationships and parameters that maximise prediction accuracy.  

How to use Machine Learning to predict sales? 

In the world of Machine Learning, sales forecasting is a time-series regression problem. A regression is any task concerned with the estimation of a continuous quantity (i.e. sales). Time-series regressions are a particular case of regression, with an additional time dimension. 

There are two main types of time series regressions models: 

1. Auto-regressive models: These models predict future sales solely based on past sales values. These models include ARIMA, SARIMAX, and Exponential Smoothing. They generate predictions by finding trends and seasonality patterns. 

2. Multivariate models: Multivariate models are based on a variety of inputs, including past sales, holiday calendars, or even economic indicators. These models include Linear Regressions, Neural Networks, Decision Tree-based methods and Support Vector Machines. 

The choice of model ultimately depends on the business problem at hand, data availability and a rigorous model testing process. 

Case Study: Parkdean Resorts

Parkdean Resorts, the largest Holiday Park Operator in the UK, contacted TrueCue to develop a model generating hourly food and beverage sales forecasts in more than 180 venues. In the hospitality industry, overstaffing can be a substantial cost driver and understaffing can significantly impact customer satisfaction. A reliable hourly forecast could therefore help fight these issues. 

A rule-based forecasting model for 180 very different venues, at an hourly grain, would never have been manageable. Also, sales data changes every day, a rule-based model designed in 2018 might not hold in 2019. 

To answer this problem, our team developed a multivariate prediction model leveraging decision tree-based methods (XGBoost). This model was trained on recent sales data, learning seasonality patterns and relationships of sales with bookings, holidays and other exogenous variables.  

The algorithm was run on a Virtual Machine, reading from and writing to a SQL database. The forecasts were then shared with venue managers using interactive Power BI dashboards to inform their planning decisions.  

Read the full case study

What are the advantages of cloud-based forecasting and reporting? 

Moving away from local Excel-based forecast to a cloud-based solution has several key advantages: 

1. Single source of truth: the prediction algorithm is run centrally and written to database. This way, there is a single, reliable forecast for the entire business. 

2. Auditable and secure process: Any failure or error is much easier to spot and correct in a centrally managed solution. Within a cloud-based architecture, role-based access control (RBAC) security can be applied. This way, business users will only have access to the resources they are entitled to interact with (i.e. model development, cloud-environment administration, prediction visualisations). 

3.Unified and interactive reporting: Using automated reporting tools such as Power BI and Tableau opens a new world of possibilities. Using these platforms, predictions can be distributed to business users in automatically refreshed dashboards. These reports can include both high level indicators and detailed breakdowns to best inform day-to-day business decisions. 

What are the prerequisites for Machine Learning sales forecasting? 

Just like humans, Machine Learning algorithms learn from past sales data. Consequently, the main prerequisite to develop ML models is the availability of training data. This data can be drawn from sales systems, company databases, local archive files and external sources. 

Efficient and scalable forecasting models require a database or data warehouse

The TrueCue Platform allows businesses to build and maintain a data warehouse hosted on Azure without a single line of code, using a drag and drop interface. Thanks to this automated approach to data engineering, data warehouses can be built in under a few months, at low cost, quickly generating business value. 

The TrueCue Platform can be linked seamlessly to the Azure suite, including Azure Machine Learning services, Azure’s cloud ML offering. 

Wrapping Up 

The possibilities of Machine Learning-powered sales forecasting are endless. More and more companies are now realising the benefits of moving away from Excel rule-based forecasting to unified predictive analytics. 

To leverage the technical advance of ML and AI to inform business planning speak to one of the team! Get in touch

Business challenge:

Data Science
Machine Learning
Sales Forecasting
Sales Performance
Eliott Kalfon
Written by Eliott Kalfon Data Scientist

Eliott's life changed when he discovered that machines could learn. From this day onwards, he has been applying his background in Economics and Maths to solve tough business problems and understand the world through data. He is proficient in Python, SQL, Power BI, Tableau and Alteryx, with a passion for discovering new technologies. In his free time, he enjoys playing the guitar, swimming, chess, and night walks.

Case Study: Fighting COVID-19 with Data

Learn about how we’re helping the largest Sustainability and Transformation Partnership in the NHS, to use data analytics to improve their response to COVID-19 and save lives.

Download Case Study