Abstract
Stock management is very important for the companies to supply necessary demand for the products they sell, to pricing the products and to the aspect of storage cost. In stock management, the products to be sold to the customer are procured by ordering from the vendors. The orders given to the vendors are determined by estimating the sales quantities of the products. When estimating sales, if we order in large quantities, the storage and expiration dates of the products may exceed, or if we order less than demand, the customer cannot find the product in the store. With the Covid-19 pandemic entering our lives, there have been some changes in our habits. One of these changes is the change in shopping habits of people due to the isolation period. By managing this change in terms of stock management on the store side, it ensures that people can reach the products they demand in these difficult times and that companies do not create extra costs by making more stock than necessary. We made a sales forecast on 5-lt sunflower oil which is a basic food product using the data of a grocery chain with machine learning methods and developed models to use these forecasts in stock management. Our data is multivariate and contains both quantitative and qualitative features. In our study, we used the supervised learning method and the XGBoost, LGBMRegressor and Ridge models used in many machine learning projects. As a result of our studies, an improvement of approximately 25% has emerged with the features we added specifically for the pandemic.
You have full access to this open access chapter, Download conference paper PDF
Keywords
1 Introduction
Markets are workplaces where customers can meet their needs. It is essential that the market supplies the needs of the customers, namely the demand. If the market does not present the customer’s needs to the customer, this may lead to customer dissatisfaction and loss of customers for the market [1]. The reputation of the stores in the eyes of the customers is also important, their customers want to buy the product they want at an affordable price. Inventory management plays an important role in customers’ access to products and in affordable prices compared to other competing markets [2]. Effective stock management benefits the market and the customer [3].
Inventory management is to ensure that the products offered by the markets to their customers are supplied from the suppliers and that the customers can reach them on the shelves of the market at more affordable prices than the competitors of the market. There are two criteria here; It should be ensured that the customer has continuous and affordable access to the product [4]. When the criteria are met, customer satisfaction will increase the profitability rate in the market.
In order to be able to manage the stock, it is necessary to predict how much of each product will be sold [5]. If the sale of the product is underestimated and the customer cannot reach the product, it will cause loss of customer and reputation in terms of the market. If we overestimate the sales of the product, we have to store the product, which increases our warehouse cost and therefore the cost of the product. It makes it difficult to offer affordable products to our customers. In another case, when we have excess demanded product and the expiry date of the product has passed, we can no longer sell the products and the cost of the product increases [6]. However, it causes additional costs because the products in the warehouse or on the shelf have to be removed for the market.
In extraordinary times such as stock management pandemics, it becomes even more important that the demand, which consists of the needs of the people, can be supplied by the market [7]. This situation, which is out of normal, causes abnormality in sales. Especially during the pandemic period, together with the problems experienced in logistics, stock management and thus sales forecasting are of vital importance in presenting the required products to customers [8].
Sales forecasting provides continuation of sales before stocks run out and provides real-time forecasts suitable for all situations [9]. Statistics, mathematical models, machine learning and deep learning etc. on stock management. Many techniques are used [10]. Instead of a rule-based model [8], we decided to examine this issue using a machine learning technique that could extract the change in sales from the data. First of all, we made general analyzes on our data and tried to understand our data. In the light of the analyzes we made, we tried to find features that would positively affect the result while predicting sales by performing feature engineering on our data. We developed a model using our data and newly discovered features and the XGBoost machine learning model [11], which is frequently used in making predictions. In our study, with the development of the pandemic feature, an improvement of approximately 25% has emerged in sales forecasts.
2 Dataset
Our data set includes sales records of 5-lt sunflower oil product in all branches between 01-05-2019 and 01-05-2021 of a chain market consisting of 10 branches located in various parts of Turkey. Data set contains 1613 daily records. The selected time period also includes the COVID-19 pandemic period so that the pandemic effect can be examined. With the COVID-19 pandemic, there have been unusual curfews and serious difficulties related to logistics [12]. Limits have been imposed on the working hours of the markets and the number of customers inside. At the same time, restrictions were introduced for a certain segment of people to go out to the street, depending on their age. Such restrictions on both markets and customers have led to significant changes in sales [13]. The features included in our data are given in Table 1.
Using the date information here, the period without a pandemic before March 2020, when the pandemic effect was seen, and the period after it were described as the pandemic period.
3 Methodology
3.1 Problem Identification
Figure 1 shows our methodology. The methods that are actively used to forecast the sales of the product in non-pandemic times have changed due to changes and limitations in shopping habits during the pandemic. When we use the machine learning algorithm, which is trained with normal data, under pandemic conditions, it makes bad predictions compared to the previous period estimates due to the change in the data. Due to this change, the previous forecasting model will have a high margin of error during the pandemic period. In this study, it is aimed to prevent this.
3.2 Data Preparation
After our data was obtained from the database. It was pre-processed as follows in order to eliminate the errors and deficiencies found in our data. Some of these errors are Identifying the missing areas in our data and removing them from our data will prevent our model from making mistakes and making biased learning during the training. Features in the dataset are typecasted in order to extract additional features. For example: date columns transformed string to datetime type.
3.3 Exploratory Data Analysis
In this study, only human exposure estimation was made without distinguishing activity. Exploratory data analysis provides the opportunity to summarize our data, discover the features of our data, understand the relationship between features, and detect abnormal data by analyzing our data with statistical methods and data visualization methods. These analyzes can also be used during feature extraction processes.
General information can be obtained by examining our data statistically first. When we examine Table 2, where the data are analyzed statistically, we can see that the sales figures of the pandemic period have decreased in general. We analyzed the sales data of our product statistically: the number of records, average sales, standard deviation, minimum value, maximum value and data distribution of 25%, 50%, 75%. We obtained these values in Table 2 using the print(df.describe()) function of the pandas library. As can be seen in the table, there has been a decrease of approximately 30% in the average of sales. Changes in other areas are also at this level, and sales have generally decreased as expected during the pandemic period (Fig. 2).
In order to see the changes in our sales data with and without pandemics on the basis of days of the week, we obtained Figs. 3, 4 and 5 using the seaborn library and column (bar plot) and line (line plot) graphics. Percentage changes are expressed in the bar chart.
In the graphs in Fig. 4, a column chart of the sales in the pandemic period (shown in red) and in the non-pandemic period (shown in green) is shown by weekdays. In this chart, the change in sales is observed due to the expected weekend closure. Percentage changes are given on the column. When we interpret the graph, we can see that the sales in the normal period are high on the weekend. In the pandemic period, we can see that sales are less due to the weekend closure.
In order to understand the changes in sales on weekdays and weekends, we showed our data in the form of time with and without pandemics, as in Fig. 3, with a column chart as the average sales on weekdays and weekends. When we examine these graphics, we need to update our model that we use in normal times, because the sales character has changed during the pandemic period. In order to predict sales during the pandemic period, a model suitable for the development of our model should be put forward by adding new features.
As seen in the line graph in Fig. 5, sales follow a decreasing trend on weekends.
3.4 Feature Extraction
In the light of the graphics in the analysis section, the pattern and characteristics of our data have changed due to the change in sales habits during the pandemic period. Because of this change, when our machine learning models are trained with the data before the pandemic, the consistency in the predictions is lost because the pandemic data is different. For this, we can add new features, taking into account the information in the analysis section, so that our model can better learn the changing data and non-pandemic data. In this way, we can better predict the sales during the pandemic period and make better stock management by placing the orders accordingly. We use pandas library’s ready-made functions on time data types while extracting properties.
These features were extracted from the time feature of our data in order to be able to deal with the year, month, week of the year, which day of the year, which day of the week, and when and in which situation the sale was made. Thanks to these features, we expect our model to establish a connection between sales data and time and to better learn the sales values made at the same time. We evaluate these temporal features categorically, and we want our model to evaluate it that way. Since there will be a connection between time-based sales, records with the same time feature will have similar values and this approach will enable our model to learn better.
We extract a true-false property from our time feature, whether it is weekdays or weekends. Weekday and weekend sales are different in the retail industry. It is said by retail experts that people shop more during the holidays. In order to express this situation in our data, we add this feature to our data.
The character of the sales during the pandemic period, which we observe in the graphics, is changing. We add a categorical feature to our data that takes values as pandemic and non-pandemic when it is in the pandemic period.
3.5 Dataset Separation
We divide our data into two as data to be used in training the models and then as data to be used in testing in order to measure the predicted performance of the trained model. When dividing the data, considering that our data is a time series, we determine the training and test parts by shifting. In order to see the change over time in the time series data, the part immediately after the data taken for training is taken for testing. Figure 5 illustrates this approach. Each shift is evaluated as a step, and the model is trained with the training data at each step, and evaluation metrics are obtained with the test data. Then the average of the scores obtained in all steps is taken.
Time series cross validation method is used before a certain time for training and after for testing, so we can objectively train time series data and measure the performance of our model. We did it using the time series cv algorithm of the sklearn library.
tscv = TimeSeriesSplit(n_splits = 3, test_size = 2).
Example: Size of data set = 1613.
-
1.
Fold = 1
-
a.
Train size = 1607
-
b.
Test size = 2
-
a.
-
2.
Fold = 2
-
a.
Train size = 1609
-
b.
Test size = 2
-
a.
-
3.
Fold = 3
-
a.
Train size = 1611
-
b.
Test size = 2
-
a.
3.6 Regression and Machine Learning Model
Regression is a statistical measurement that tries to determine the strength of the relationship between a dependent variable and other independent variables, and makes predictions according to this power. It is used as a predictive modeling method in machine learning where an algorithm is used to predict the dependent variable.
Solving regression problems is one of the most common applications for machine learning models, especially in supervised machine learning. Algorithms are trained to understand the relationship between independent variables and an outcome or dependent variable. The model can then be used to predict the outcome of new and invisible input data or to fill a gap in the missing data.
Machine learning is a sub-branch of artificial intelligence algorithms. It has a structure that can learn on data, and allows us to make predictions after this learning. This model takes an input and an output data as training data. The algorithm establishes a function by learning between the input data and the output data and learns the statistical pattern in our data. Estimates are made with the learned model.
Here, we decided to use the XGBoost and LGBMRegressor model with the tree-based gradient boosting [14] feature, which is the most popular of the machine learning algorithms, and the linear-based Ridge model. This choice was made taking into account both the overall success of the models in machine learning and the number of records of our data. Due to the scarcity of data we have, deep learning methods were not preferred.
XGBoost and LGBMRegressor algorithms are decision trees-based machine learning algorithms that use gradient boosting. XGBoost has brought some improvements over plain GBM, such as the use of regularization, pruning, and parallelization to prevent over-learning. It works faster than other algorithms with its parallel operation. It is used in many projects and competitions. Since the XGBoost library is an open source project, it is developed and supported by many users.
XGBoost, short for Extreme Gradient Boosting, is a scalable distributed gradient assisted decision tree (GBDT) machine learning library. It provides parallel tree reinforcement and is the leading machine learning library for regression, classification and sorting problems. XGBoost, a supervised machine learning method, uses algorithms to train a model to find patterns in a dataset containing tags and features, and then uses the trained model to predict tags in a new dataset’s features.
LGBMRegressor has the following differences from XGBoost. Instead, it grows trees in the form of leaves. He chooses the leaf he believes will provide the greatest reduction in loss. Also, LightGBM does not use the commonly used rank-based decision tree learning algorithm, which looks for the best split point in the sorted feature values, as XGBoost or other applications do. Instead, LightGBM implements a highly optimized histogram-based decision tree learning algorithm, which provides huge advantages in both efficiency and memory consumption. The LightGBM algorithm uses two new techniques called Gradient-Based Unilateral Sampling (GOSS) and Special Feature Packing (EFB), which allow the algorithm to run faster while providing a high level of accuracy.
Ridge regression is a method of estimating the coefficients of multiple regression models in scenarios where the independent variables are highly correlated. It has been used in many fields, including econometrics, chemistry, and engineering.
3.7 Performance Evaluation
The metrics allow us to evaluate our model’s predictive performance after training. It allows us to measure how successful a model trained with training data is on the test data, or how wrong predictions it makes. We will use the MAPE [15] and RMSE [16] metrics to measure our model. These metrics are frequently used in regression tasks.
The problem we are trying to solve is a regression problem. Among the most preferred metrics in regression problems are MAPE and RMSE. The reason why we use two different metrics at the same time here is to be able to look at our mistakes from two different angles and to be more objective.
MAPE; Average absolute percent error (MAPE), also known as mean absolute percent deviation (MAPD), is a measure of the error in estimation of a forecasting method in statistics. The MAPE scale is set out in Eq. 1.
Here, At, Tt, and n represent the actual value, the predicted value, and the number of cases tested in the total data set, respectively. The MAPE metric is our error expressed as a percentage. Calculation of the error as a percentage will reflect the error more objectively, if the magnitude of the values change as a scalar, since this is calculated as a percentage to the error.
RMSE; The mean square deviation (RMSD) or mean square error (RMSE) is a commonly used measure of the difference between values predicted by a model or estimator (sample or population values) and observed values. The RMSE scale is shown in Eq. 2.
The abbreviations used in the RMSE metric are also used in the same sense as MAPE. The performance of the extracted feature and the operated model with these two performance scales are given in Table 3 and Fig. 6.
4 Findings and Interpretation
By training our data in a comparative way, we will make evaluations by observing the effect of the features we add on the result. Two datasets were created, the first contains features related to the pandemic and the other does not. We trained these datasets with XGBRegressor, LGBMRegressor and Ridge machine learning models, and evaluated our models with the performance metrics that occurred in the estimation they made on the test data.
The results we obtained with the test data after the training are given in Table 3 and Fig. 6. Considering these results, our model makes 25% improvement in the one step ahead sales prediction (Table 4).
Figure 7 in below shows the estimation of our model on the test data graphically. As seen in this way, our model generally catches the sales trend, but makes an one step ahead prediction that sometimes less or more sales prediction will be made in sales (Fig. 8).
5 Conclusion
If the market chains cannot manage the stock well, they may face the risk of loss of reputation in the public, storage due to excess stock, or deterioration of the product due to insufficient supply to the incoming demand. Any market chain sells around 10000 products and the stock management of this large-volume product portfolio requires serious resources. Here, XGBoost, LGBMRegressor and Ridge machine learning models were preferred as a method where we can efficiently manage stocks through algorithms created with today’s developing techniques and data obtained, update our data despite changing conditions, and provide rapid training because there are so many product types.
As a result of our work, we have developed a new feature that can be used for the pandemic period, and by adding this feature to other already existing features, we have improved the consistency of our predictions.
In the future, when feature extraction studies on our data reach the desired point and the number of data increases, we are considering using deep learning methods, feature extraction and models. The amount of data is of great importance for deep learning methods.
With this developed model, the sales forecast of the products in the portfolio of a market can be made and an adequate stock management can be realized in this way. In this way, the stock management of the entire market will be fully automated with the recommended machine learning model.
Production and consumption, which is the basis of the economy, is directly related to stock management. This study will be an example to the literature for information and guidance for each company working on stock management.
References
Erceg, Ž, et al.: A new model for stock management in order to rationalize costs: ABC-FUCOM-interval rough CoCoSo model. Symmetry 11(12), 1527 (2019)
Li, R., Chiu, A., Seva, R.: A process-based dead stock management framework for retail chain store systems. In: RSF Conference Series: Business, Management and Social Sciences, vol. 2, no. 1 (2022)
van Ryzin, G., Mahajan, S.: On the relationship between inventory costs and variety benefits in retail assortments. Manag. Sci. 45(11), 1496–1509 (1999)
Chase Jr., C.W.: What you need to know when building a sales forecasting system. J. Bus. Forecast. 15(3), 2 (1996)
McCarthy, T.M., et al.: The evolution of sales forecasting management: a 20-year longitudinal study of forecasting practices. J. Forecast. 25(5), 303–324 (2006)
Chen, C.-Y., et al.: The study of a forecasting sales model for fresh food. Expert Syst. Appl. 37(12), 7696–7702 (2010)
Gupta, C., Poddar, S., Ghosh, A.: The consumer demand recovery beyond the pandemic. Int. J. Manag. Hum. Sci. (IJMHS) 5(3), 60–68 (2021)
PriyaDarshani, M., Sinha, M.P., Sinha, K.: A study on evolutionary technique to predict the sales during COVID-19. In: Handbook of Research on Library Response to the COVID-19 Pandemic, pp. 376–402. IGI Global (2021)
Kiracı, M.: Stok yönetimi ve karlılık ilişkisinin finansal oranlar aracılığıyla incelenmesi: İMKB imalat sektöründe bir araştırma (2009)
Cadavid, J.P.U., Lamouri, S., Grabot, B.: Trends in machine learning applied to demand & sales forecasting: a review. In: International Conference on Information Systems, Logistics and Supply Chain (2018)
Chen, T., et al.: XGBoost: extreme gradient boosting. R package version 0.4-2 1.4 1-4 (2015)
Açıkgöz, Ö., Günay, A.: The early impact of the Covid-19 pandemic on the global and Turkish economy. Turk. J. Med. Sci. 50(9), 520–526 (2020)
Priya, S.S., Cuce, E., Sudhakar, K.: A perspective of COVID 19 impact on global economy, energy and environment. Int. J. Sustain. Eng. 14(6), 1290–1305 (2021)
Ke, G., et al.: LightGBM: a highly efficient gradient boosting decision tree. In: Advances in Neural Information Processing Systems, vol. 30 (2017)
De Myttenaere, A., et al.: Mean absolute percentage error for regression models. Neurocomputing 192, 38–48 (2016)
Botchkarev, A.: Performance metrics (error measures) in machine learning regression, forecasting and prognostics: properties and typology. arXiv preprint arXiv:1809.03006 (2018)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
Copyright information
© 2023 The Author(s)
About this paper
Cite this paper
Yildirim, E., Cam, V., Balki, F., Sarp, S. (2023). Sales Forecasting During the COVID-19 Pandemic for Stock Management. In: Biele, C., Kacprzyk, J., Kopeć, W., Owsiński, J.W., Romanowski, A., Sikorski, M. (eds) Digital Interaction and Machine Intelligence. MIDI 2022. Lecture Notes in Networks and Systems, vol 710. Springer, Cham. https://doi.org/10.1007/978-3-031-37649-8_12
Download citation
DOI: https://doi.org/10.1007/978-3-031-37649-8_12
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-031-37648-1
Online ISBN: 978-3-031-37649-8
eBook Packages: Intelligent Technologies and RoboticsIntelligent Technologies and Robotics (R0)