
Back
June 21, 2024
ML Infra, Classifiers & RL
Demand Forecasting
Pfactorial
Share

Introduction
In the dynamic world of retail, the ability to predict the future is often the key to success. Imagine a retail world where store shelves are always stocked with the right products, seasonal surges are seamlessly anticipated, and customer’s needs are met almost before they realize them. Today's customers are a diverse and dynamic group, with preferences and expectations that have become increasingly complex. That makes it increasingly harder for retailers to make better and more reliable forecasts to get the right inventory to the right location. Here in this blog we are going to discuss Demand forecasting and its importance.

What is demand forecasting
Demand forecasting is the systematic process of evaluating future demand for a specific product. It allows you to predict the sales scientifically for upcoming weeks, months and years. Thus you know exactly how much stock to order. We can define Demand Forecasting as the method of using historical sales data to evaluate future customer demand.
Generating an accurate forecast can be relatively straightforward when operating under stable conditions. However, in the retail industry, we are all too aware that stability is a rare occurrence. Retail is inherently dynamic, and it faces a constant influx of numerous factors that continually influence demand. It includes Seasonality of product sales, competition, type of goods, geography and economy.
Here we are going to discuss the application of machine learning in forecasting sales.
Why machine learning for Demand forecasting
Machine learning has emerged as a powerful tool for demand forecasting in the retail industry due to its ability to address the inherent complexity and ever-changing nature of consumer behavior. Machine learning algorithms can adapt to fluctuations in demand patterns by processing and learning from large volumes of historical data. They excel in handling variables that influence consumer choices, from seasonal trends and promotions to market dynamics and external events. Additionally Machine learning algorithms can capture Recurring demand patterns, internal business decisions, and also hidden unknown patterns. Integrating machine learning into the retail demand planning process can elevate forecasting accuracy, streamline inventory management, and enhance the overall efficiency of the supply chain.
Steps in demand forecasting
We are going to Discuss the main steps in demand forecasting using an example data set
Collecting data :
Collecting data is often the initial and most challenging step in demand forecasting, as machine learning algorithms require a substantial amount of historical data to effectively learn and make accurate predictions.
We'll be working with a dataset sourced from Kaggle. You can access the dataset by following this link Store Item Demand Forecasting Challenge | Kaggle. The goal here is to forecast sales for the upcoming three months.
Let's discuss about the data :

This is a sample of the training dataset, which includes sales data with date information. The "store" column represents the store ID, the "item" column corresponds to the item ID, and the "sales" column indicates the quantity of items sold at a specific store on a given date. We need to predict the sales using test data.
Data understanding and preprocessing :
Data preprocessing includes handling null values, data type changing and other inconsistencies in data. Inconsistent data can create confusion and hinder the forecasting process. Preprocessing helps to standardise data formats and units, making it easier to work with and interpret.
To gain a better grasp of the data, we can utilise data visualisation. This process aids in selecting the appropriate forecasting model and identifying recurring patterns within the dataset, and other valuable insights.

The figure above illustrates the relationship between the date and sales through a plot. From this we can clearly reveal the non-stationary nature of the data and highlight the presence of noticeable seasonality.

This visualisation showcases data decomposition, isolating trends and seasonal or other noises within the input data. From this it is clear that there is an upward trend and seasonality.
Model development :
The selection of machine learning models is dependent upon various factors, including business objectives, data characteristics, data volume and data quality. There is no common algorithm for all situations. As we said before, data understanding and objectives help us to choose the model. Commonly employed demand forecasting methodologies are
- Time series forecasting (ARIMA/SARIMA)
- Gradient Boosting
- Long Short-Term Memory (LSTM)
- Regression models
- Ensemble Models
As an illustration, in our specific case, we will be applying the SARIMA (Seasonal Autoregressive Integrated Moving Average) model.
Preprocessing steps for SARIMA model :
Before building SARIMA models we need to check stationarity and Stationarize Time series. It means that the data should have constant mean and standard over different time periods. Here we are going to use 2 methods to check stationarity: Rolling Mean and ACDF (Augmented Dicky- Fuller) Test .
This is how our data look like . you can see that mean and variance is not constant

In the case of stationary data, the trend graph should exhibit a flat or horizontal pattern.

Next we need to find optimal parameters for the model. ACF/PACF graphs will help us to find the optimal parameters order and seasonal order.

Now we can build the model.

Forecast using model :
Now our SARIMA model is ready. We can Predict using the model.


Use Cases
- Retail Inventory Management : One of the most common applications of demand forecasting in the retail sector is inventory management. Retailers, such as fashion stores, use historical sales data and market trends to predict the demand for clothing items. Let's consider a fashion retailer as an example . Imagine a clothing store that specializes in seasonal fashion, offering a wide range of clothing, from summer dresses to winter coats. By analyzing historical sales data, they can forecast the demand for various items well in advance.
- Supply Chain Management: Demand forecasting is critical in supply chain management to ensure the timely availability of raw materials and components. Manufacturers can use it to optimise production schedules and reduce lead times. For example, an automotive manufacturer may forecast the demand for different car models to align production and component orders accordingly.
- Healthcare and Pharmaceuticals: Hospitals and pharmaceutical companies employ demand forecasting for medical supplies and drug inventory management. It ensures the availability of critical supplies, such as personal protective equipment (PPE) and medications, when needed.
The applications of demand forecasting extend far and wide, touching virtually every industry. It optimizes resources, reduces costs, and enhances decision-making processes.
Demand forecasting is a vital component of effective business planning and resource allocation. It empowers organisations to anticipate future sales trends, optimise inventory management. Accurate demand forecasting is a game-changer in retail, providing a lot of benefits. empowers retailers to make data-driven inventory choices, resulting in better stock turnover by minimising shortages and surplus items. This, in turn, reduces expenses related to risk and clearance sales while elevating the shopping experience for customers. Precise forecasting also streamlines logistics, enhances productivity, curbs waste, and fine-tunes inventory management. As technology continues to advance and more data becomes available, the field of demand forecasting stands on the path of development, presenting new insights and opportunities for businesses.
BLOGS
You might also like...

Power biData VisualizationEnterprise Ops Platforms+3
Jun 20, 20245 min readRead

Machine LearningData ScienceFinance & Payments+4
Lending with Confidence: Credit Scoring Models for Institutions
Jun 25, 20246 min readRead

PuLPData ScienceEnterprise Ops Platforms+3
Supply Chain Optimization
Jun 21, 20248 min readRead