# Augmented Data and XGBoost Improvement for Sales Forecasting in the Large-Scale Retail Sector
## 2 Methodology: Platform Design and Implementation and AD Approach  
### Platform Design and Implementation  
Figure 1 illustrates the unified Modeling Language (UML) functional scheme of the implemented system applied for an industry working in the large-scale retail sector. The  
main objective of the present research work was the implementation of an innovative BI platform. In detail, Figure 1 shows the Use Case Diagram (UCD) of the project. This diagram outlines the main functionalities that the intelligent platform is equipped with. Here, we focus on the functionality outlined in red, which is the prediction of sales through XGBoost algorithms. Figure 2 shows the UCD of the intelligent platform. The operator carries out the data entry. Then, the data is deposited in a data warehouse (DW) that allows for depositing the data coming from multiple sources and at the same time simplifies the data processing. A web app allows the customer to receive some personalized purchase information made possible by the customer profiling carried out by K-means algorithms. The various branches of the store send data in real time to a central database (DB). This is a Structured Query Language (SQL) DB which is not suitable for archiving historical data. Therefore, the massive data are sent on the Vertica DB. The resulting DW architecture is shown in Figure 3.  
Figure 1: UML UCD of the implemented system. The paper discusses the implementation and results of the XGBoost algorithms used for sales prediction. We used the XGBoost algorithm in order to predict the future purchases of customers who have made a number of purchases equal to at least 30% of the number of days corresponding to the training period. On the basis of these predictions and the analysis of the association rules of the products purchased by the total customers of the supermarket, it is possible to formulate personalized offers for each customer. Customers were grouped into clusters, calculated on the basis of recency (distance from the last entry into the supermarket) and frequency (frequency of entry in the last 90 days). The prediction algorithm calculates the product that will be purchased by a customer who belongs to a cluster or to the entire clientele. Figure 4 shows the flow chart of the implemented XGBoost algorithm. The algorithm takes as input the cluster on which to make the forecast, the training period, the number of days for which it carries out the prediction, and the code of the product in question. Finally, a check box permits one to select which of the following parameters must be used  
Figure 3: Data Warehouse Architecture. Figure 2: UML UCD of the implemented prototype platform with focus on data processing. by the algorithm to make the prediction. The multiple parameters used for the prediction estimation were the following:  
* day of purchase of the product;
* week number;
* promotion status;
* weather conditions;
* perceived temperature;
* ratio between the number of receipts containing the specific product code and the number of receipts sold in total during the day;
* ratio between the number of customer receipts with the cluster identified and the total number of receipts for the day;
* ratio between the total receipts issued by the department of the specific product code and the number of total receipts issued during the day;
* unit price;
* total number of customers of the day;
* product in promotion at the competitor;
* week before a holiday week;
* day after a holiday;
* pre-holiday;
* closing day of the financial year. After building the dataset, a data pre-processing activity was carried out in order to apply Xgboost. Specifically, the techniques used were the following:  
* one hot encoding, which is a mechanism that consists of transforming the input data into binary code;  
Figure 4: Flow chart of XGBoost algorithm for cluster sales forecasting. clustering, in order to obtain a relevant statistic, the clientele was divided into groups of customers with similar habits.