Tobacco sales prediction method and device based on intelligent logistics
By adopting a prediction method based on smart logistics in the tobacco industry, combining ARIMA and LSTM modules for prediction, and using combined module weighted combinations, the problem of difficulty in accurately predicting tobacco sales in the prior art is solved, and higher prediction accuracy and digital operation level are achieved.
Patent Information
- Application Number
- CN202411883326.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-19
- Publication Date
- 2025-04-15
AI Technical Summary
It is difficult to accurately predict tobacco sales in the tobacco industry in the prior art, especially when faced with a variety of cigarette product rules and complex industry rules.
A tobacco sales forecasting method based on smart logistics is adopted, combining artificial intelligence algorithms and marketing sorting data, and predicting through trained ARIMA modules and LSTM modules, and weighting and combining the prediction results with combined modules to improve the accuracy of prediction.
It significantly improves the accuracy of tobacco sales forecasts, reduces the impact of diverse cigarette product specifications and complex environmental factors on the forecast, enhances the application capabilities of data analysis, realizes the interconnection and integration of data flows and business flows, and improves the digital operation level of commercial tobacco.
Smart Images

Figure CN119831635A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of tobacco sales forecasting, and in particular relates to a tobacco sales forecasting method and device based on smart logistics. Background Art
[0002] Inventory management is an indispensable key link in the smart logistics system, especially in the tobacco industry, where its importance is particularly prominent. Through accurate predictions of tobacco sales, companies can gain insight into future market demand trends. This capability not only provides valuable decision-making support for companies, but also helps them achieve scientific planning of production and inventory. Specifically, accurate predictions can help companies effectively avoid the problems of capital occupation and resource waste caused by excess inventory, while also preventing sales losses and decreased customer satisfaction caused by out-of-stock situations. Therefore, strengthening the ability to predict tobacco sales is not only the key to improving logistics efficiency and response speed, but also lays a solid and solid foundation for the comprehensive construction of smart logistics.
[0003] At present, the marketing and placement decision-making process in the tobacco logistics industry mainly relies on manual work. Through manual analysis of sales targets, combined with historical experience data and placement experience, placement strategies of different dimensions are formulated and order structures are determined. Due to the lack of data-based automated analysis tools and decision-making methods, the formulation of placement strategies is a process of repeated adjustments, which is not only time-consuming and labor-intensive, but also relies on manual experience, which is not conducive to the effective transfer of industry knowledge.
[0004] Patent CN118313869A proposes a commodity sales prediction method and prediction model based on a fully connected neural network, and constructs a training data set based on the historical sales data of the commodity. The data set is input into a multi-scale feature extraction module to obtain sequences of different scales, and predictions are made through sequence data of different scales, and prediction results are output. The prediction results of different scales are merged to obtain the final prediction results. Patent CN117474588A proposes a cigarette sales prediction method, device, computer equipment and storage medium. According to the location information of retailers and the tobacco sales data and non-tobacco sales data corresponding to each retailer, a preset machine learning algorithm is used to train the cigarette sales prediction model to obtain a trained cigarette sales prediction model, and the trained cigarette sales prediction model is used to predict cigarette sales.
[0005] The above method constructs and predicts data through traditional time series models or simple neural networks, which is effective for simple sales forecasts. However, it is unable to make accurate forecasts in the face of the diverse cigarette specifications and complex industry rules in the tobacco industry. Summary of the invention
[0006] In order to solve the above problems, the present invention proposes a tobacco sales forecasting method and device based on smart logistics, which combines artificial intelligence algorithms with marketing sorting data, and uses the prediction output of the model as a decision-making aid for marketing business work, thereby assisting marketing personnel to quickly formulate cigarette delivery strategies and optimize cigarette delivery structures; greatly enhance the data analysis and application capabilities, realize the interconnection and integration of data flows and business flows, and improve the digital operation level of commercial tobacco; at the same time, it can improve the accuracy of prediction results and reduce the impact of diverse cigarette specifications and complex environmental factors on tobacco cigarette forecasts.
[0007] In a first aspect, the present invention provides a tobacco sales forecasting method based on smart logistics, comprising:
[0008] Acquire tobacco sales data to be tested; wherein the data to be tested is multi-source data;
[0009] The test data is input into a tobacco sales prediction model to perform tobacco sales prediction and obtain a tobacco sales prediction result; wherein the tobacco sales prediction model includes a trained ARIMA module, a trained LSTM module and a combination module; the ARIMA module and the LSTM module are respectively connected to the combination module; the trained ARIMA module is used to determine the first prediction data of tobacco sales, the trained LSTM module is used to determine the second prediction data of tobacco sales, and the combination module is used to determine the final prediction data of tobacco sales based on the first prediction data and the second prediction data.
[0010] In a possible implementation manner, the data to be tested includes tobacco inventory data, historical sales data, quarterly sales data, holiday data, and policy impact data, wherein the historical sales data includes tobacco sales data for the same month in the past year.
[0011] In a possible implementation manner, the first prediction data and the second prediction data determine final prediction data of tobacco sales, including:
[0012] Determine residual data based on the first forecast data and the historical sales data of tobacco in the same month of the past year in the historical sales data;
[0013] Modeling the residual data using an LSTM algorithm to determine residual prediction data;
[0014] Adjusting the first prediction data according to the residual prediction data to obtain adjusted first prediction data;
[0015] The adjusted first prediction data and the second prediction data are weightedly combined to obtain the final prediction data.
[0016] In a possible implementation, the ARIMA module is trained by the following method:
[0017] Obtaining a first training sample set; wherein the first training sample set includes historical sales data for the past year;
[0018] Performing a stationarity test on the first training sample set, and processing the first training sample set according to the stationarity test result to obtain a first training sample set after stationarity test;
[0019] Construct the ARIMA initial module based on the ARIMA algorithm;
[0020] Using the first training sample set to train the ARIMA initial module to obtain first training result data; and determining initial values of hyperparameters of the ARIMA initial module; wherein the hyperparameters include the number of autoregressive terms, the number of differences, and the number of moving average terms;
[0021] The hyperparameters are updated to obtain a trained ARIMA module.
[0022] In a possible implementation manner, performing a stationarity test on the first training sample set, and processing the first training sample set according to a stationarity test result to obtain a first training sample set after stationarity test, includes:
[0023] The first training sample set is tested for stationarity using an image analysis method, and whether the first training sample set is a stationary sequence is determined using a changing trend of a time series graph; if it is not a stationary sequence, the first training sample set is stabilized using a differential operation to obtain a first training sample set after the stationary processing; if it is a stationary sequence, the first training sample set is not processed.
[0024] In a possible implementation manner, updating the hyperparameters includes:
[0025] The number of differences is updated according to the order of the difference operation. When the stationarity detection result is a stationary sequence, the number of differences is a preset number value; and the number of autoregressive terms and the number of moving average terms are updated using the Bayesian criterion.
[0026] In a possible implementation, the LSTM module is trained by the following method:
[0027] Constructing an LSTM initial module based on the LSTM algorithm, wherein the LSTM initial module includes an input layer, a hidden layer, and an output layer;
[0028] Acquire a second training sample set, wherein the second training sample set includes inventory data of the past year, historical sales data of the past year, quarterly sales data of the past year, and holiday data of the past year;
[0029] The LSTM initial module is trained using the second training sample set to obtain a trained LSTM module and second training result data.
[0030] In a possible implementation, the method further includes:
[0031] Combining the first training result data with the first real sales data corresponding to the first training sample set, using the error variance weighted average method to determine the first error data; combining the second training result data with the second real sales data corresponding to the second training sample set, using the error variance weighted average method to determine the second error data;
[0032] The weight for weighted combination is determined according to the first error data and the second error data.
[0033] In a possible implementation, the method further includes:
[0034] Get a test sample set;
[0035] Using the test sample set to test the tobacco sales prediction model, and obtaining the test results corresponding to the test sample set;
[0036] In combination with the actual results and test results corresponding to the test sample set, the output results of the test sample set are evaluated using a root mean square error algorithm and a mean absolute percentage error algorithm to verify the performance of the tobacco sales prediction model.
[0037] In a second aspect, the present invention provides a tobacco sales forecasting device based on smart logistics, comprising:
[0038] A data acquisition module is used to acquire tobacco sales data to be tested; wherein the data to be tested is multi-source data;
[0039] A sales forecasting module is used to input the test data into a tobacco sales forecasting model to perform tobacco sales forecasting and obtain tobacco sales forecasting results; wherein the tobacco sales forecasting model includes a trained ARIMA module, a trained LSTM module and a combination module; the ARIMA module and the LSTM module are respectively connected to the combination module; the trained ARIMA module is used to determine the first forecast data of tobacco sales, the trained LSTM module is used to determine the second forecast data of tobacco sales, and the combination module is used to determine the final forecast data of tobacco sales based on the first forecast data and the second forecast data.
[0040] The beneficial effects of the technical solution provided by the embodiment of the present invention are as follows: a tobacco sales prediction method and device based on smart logistics of the present invention, since its tobacco sales prediction model includes a trained ARIMA module, a trained LSTM module and a combination module, wherein the tobacco sales data to be tested are respectively input into the trained ARIMA module and the trained LSTM module to obtain the first prediction data and the second prediction data respectively, and the combination module performs weighted combination of the first prediction data and the second prediction data to obtain the final prediction data; therefore, the present invention adopts two algorithms to predict tobacco sales, and compared with the method based on a single model, the accuracy of the tobacco sales prediction result is improved by combining the model; at the same time, since the ARIMA module has a statistical advantage and the LSTM module has an advantage of deep learning, the present invention combines the respective advantages of the ARIMA module and the LSTM module to reduce the impact of various tobacco specifications and complex environmental factors on tobacco sales prediction, improve the stability of the prediction, and further improve the accuracy of the prediction. The present invention combines artificial intelligence algorithms with marketing sorting data to establish a marketing sorting digital model, and uses the model's predictive output as a decision-making aid for marketing operations, assisting marketing personnel in quickly formulating cigarette delivery strategies and optimizing cigarette delivery structures; greatly enhancing data analysis and application capabilities, achieving the interconnection and integration of data flows and business flows, and improving the digital operation level of commercial tobacco. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A schematic diagram of a flow chart of a tobacco sales forecasting method based on smart logistics provided in an embodiment of the present invention;
[0042] Figure 2 Another flowchart of a tobacco sales forecasting method based on smart logistics provided by an embodiment of the present invention;
[0043] Figure 3 A schematic diagram of a training method for an ARIMA module according to an embodiment of the present invention;
[0044] Figure 4 A schematic diagram of the structural principle of the LSTM module provided in an embodiment of the present invention;
[0045] Figure 5 A schematic diagram of the system principle of a tobacco sales forecasting device based on smart logistics provided in an embodiment of the present invention.
[0046] In the figure: 10-data acquisition module; 20-sales forecast module. DETAILED DESCRIPTION
[0047] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0048] See also Figure 1 The present embodiment provides a tobacco sales forecasting method based on smart logistics, including the following steps S100 to S200.
[0049] Step S100, obtaining tobacco sales data to be tested; wherein the data to be tested is multi-source data.
[0050] Specifically, the data to be tested include inventory data of the previous week, historical sales data of the previous week, quarterly sales data of the previous quarter, holiday data of the previous week, and policy impact data of the previous week; in addition, tobacco sales data of the same month last year are also included for use in the subsequent determination of residual data. For example, to predict tobacco sales in the first week of January 2024, the data to be tested include: inventory data, historical sales data, and holiday data of the last week of December 2023, quarterly sales data from October 2023 to December 2023 (the last quarter of 2023), and tobacco sales data of the first week of January 2023.
[0051] The data to be tested in this embodiment is multi-source data, because this embodiment takes into account the influence of multiple factors, such as the historical sales volume of cigarettes of various specifications (sales volume in the same month of previous years), inventory, sales volume of each quarter, and special circumstances of holidays (such as the Spring Festival guarantee during the New Year's Day will adopt special order placement rules). Special circumstances of holidays are due to the fact that in reality, the cigarette logistics distribution center has a fixed production cycle and vacation every month, and cigarettes will be placed every working day. If there is a vacation, cigarettes will not be placed; therefore, the number of vacation days will also have an impact on the monthly sales volume, and the order placement rules will change according to different months and statutory holidays. In addition, this embodiment will also consider policies and other force majeure factors, such as changes in superior policies or factors of cigarette manufacturers that cause a certain type of cigarette to stop being placed or change the number of cigarettes placed. Specifically in each module, the input of the ARIMA module is historical sales data, and the input of the LSTM module is multivariate data including historical sales data, that is, the quarterly sales data, holiday data and policy impact data mentioned above, so the LSTM module is also called a multivariate LSTM module.
[0052] Step S200, input the test data into the tobacco sales prediction model to perform tobacco sales prediction, and obtain the tobacco sales prediction result; wherein, the tobacco sales prediction model includes a trained ARIMA module, a trained LSTM module and a combination module; the ARIMA module and the LSTM module are respectively connected to the combination module; the trained ARIMA module is used to determine the first prediction data of tobacco sales, the trained LSTM module is used to determine the second prediction data of tobacco sales, and the combination module is used to determine the final prediction data of tobacco sales based on the first prediction data and the second prediction data.
[0053] Specifically, the prediction result is the tobacco sales volume in the next week. The prediction process of the tobacco sales volume prediction model is as follows: Figure 2 As shown, the test data are respectively input into the trained ARIMA module and LSTM module to obtain the first prediction data and the second prediction data, respectively, and the first prediction data and the second prediction data are respectively input into the combination module to obtain the tobacco sales forecast result. Usually, before inputting the prediction model, the test data needs to be preprocessed, including outlier processing, standardization and normalization, etc. For the specific processing principle, please refer to the data preprocessing method below.
[0054] Among them, the ARIMA module is built based on the ARIMA algorithm model (Auto-Regressive Integrated Moving Average), and the LSTM module is built based on the LSTM algorithm model (Long Short-Term Memory). The ARIMA algorithm model is a statistical method for time series analysis and prediction. It combines autoregression (AR), difference (I) and moving average (MA) to capture the dynamic characteristics of time series data. The ARIMA algorithm is suitable for time series data that is stable or stable after difference, and has good short-term prediction effect. The LSTM algorithm model is a variant of the recurrent neural network (RNN). The LSTM algorithm includes an input gate, a forget gate and an output gate. The input gate is used to control how much new information is stored in the cell state, the forget gate is used to control how much information is retained in the current cell state, and the output gate is used to determine how much information is output from the cell state. These gates allow LSTM to maintain and update memory over a longer time range by controlling the flow of information. The LSTM algorithm can capture long-term dependencies in time series data and performs well for complex and nonlinear time series data. In addition, LSTM has relatively low requirements for the stationarity of data and can handle non-stationary sequences.
[0055] The combination module is used to determine the final prediction data of tobacco sales based on the first prediction data and the second prediction data. The specific method includes the following steps (11) to (14).
[0056] Step (11) determines residual data based on the first prediction data and the historical sales data of tobacco in the same month of the past year in the historical sales data, as shown in the following formula (1).
[0057]
[0058] In formula (1), Represents the first prediction data, y t Represents the historical sales data of tobacco in the same month of the past year, e tRepresents residual data.
[0059] Step (12) uses the LSTM algorithm to model the residual data to determine the residual prediction data, as shown in the following formula (2).
[0060] N t =f(e t-1 ,…e t-n e), (2);
[0061] In formula (2), f represents the nonlinear function determined by the neural network based on the LSTM algorithm, N t Represents the residual prediction data.
[0062] It should be noted that in this step, the LSTM algorithm is used to model the residual data, that is, the LSTM algorithm principle is used for modeling, rather than the aforementioned LSTM module.
[0063] Step (13), adjusting the first prediction data according to the residual prediction data to obtain the adjusted first prediction data. With N t The ARIMA forecast data after improving the forecast accuracy is obtained, as shown in the following formula (3).
[0064]
[0065] In formula (3), y represents the adjusted first prediction data.
[0066] Step (14), performing weighted combination on the adjusted first prediction data and the second prediction data to obtain final prediction data.
[0067] In this step, the prediction value with improved accuracy is weightedly combined with the second prediction data to obtain the final prediction data. Weighted combination is different from summation. Summation refers to adding a set of values one by one to obtain a sum. Weighted combination is to multiply a set of values by a weight (or coefficient) and then add these weighted values. The introduction of weights allows us to give higher importance or preference to certain values. The weighted combination principle of this embodiment is shown in formula (4).
[0068] f t =λ1x 1t +λ2x 2t (t=1,2…N), Formula (4);
[0069] In formula (4), λ1 represents the weight of the ARIMA module after improving the accuracy, x 1t The forecast data of the ARIMA module in week t after improving the accuracy, that is, the adjusted first forecast data; λ2 represents the weight of the LSTM module with multiple variables, x2t It represents the forecast data of the LSTM module with multiple variables in week t, that is, the second forecast data. In addition, the final forecast data is output in the form of orders for one week.
[0070] The tobacco sales prediction model of this embodiment includes a trained ARIMA module, a trained LSTM module and a combination module, which can extract data information from multiple aspects, thereby combining the respective advantages of the ARIMA module and the LSTM module to achieve the purpose of improving the model prediction accuracy.
[0071] The following is a detailed introduction to the construction and training process of the tobacco sales prediction module. When building the model, data preprocessing is required. The original data used comes from the order table of the marketing department database of a tobacco logistics center. The original data is stored in the order table in the form of each order. Each order records the order number, customer number, order payment method, order delivery method, order creation time, order status and order delivery address. The marketing data from January 1, 2023 to December 31, 2023 are selected to build and test the model. In time series prediction problems, abnormal data will affect the final prediction accuracy. Therefore, in order to improve the prediction accuracy of the prediction model, data preprocessing becomes a necessary step to improve the prediction accuracy. The steps of data preprocessing include the following steps (1)-step (3).
[0072] Step (1) reduces some missing values, duplicate values, invalid values and other abnormal data in the original data. Remove attribute data in the sample data that is irrelevant to business needs and unhelpful in observing the characteristics and development laws of the sample itself, and perform outlier processing to delete sample points whose values in the sample are significantly deviated from the rest.
[0073] Step (2) is to divide the data set. The original data is divided into a training sample set and a test sample set. The training sample set is used to train the model and fit the parameters, while the test sample set is used to test the prediction effect of the actual model in a new data set, thereby verifying the effectiveness of the model. In this embodiment, the data is arranged in chronological order, so the holdout method is used to divide the data according to the actual order.
[0074] Step (3) standardizes and normalizes the data. Standardization refers to converting the data to the same order of magnitude before processing; the original data is subjected to data standardization before comprehensive analysis. The role of normalization is to compress the pre-processed data within a certain range (such as [0, 1]), so that these effects can be eliminated, thereby reducing the prediction error. The normalization formula is shown in the following formula (5).
[0075]
[0076] In formula (5), x' is the normalized data, x is the original data, min(x) and max(x) are the minimum and maximum values of the original data, respectively.
[0077] After data preprocessing, ARIMA and LSTM models are constructed respectively, and the error between the predicted value and the true value of each single model is calculated and sorted by the error variance weighted average method. The weight of the single model is inversely proportional to the error. The larger the error variance, the smaller the weight value. And the weights of the single models are assigned one by one according to the weight values according to the relative error inverse method. In a possible embodiment, the ARIMA module is trained through the following steps (21)-step (25). The specific steps can be divided into: time series stationarity detection, non-stationary series processing, model identification and model verification.
[0078] Step (21), obtaining a first training sample set; wherein the first training sample set includes historical sales data of the past year. This embodiment uses the historical sales data of each cigarette brand in the past year to train and test the ARIMA module.
[0079] Step (22), performing a stationarity test on the first training sample set, and processing the first training sample set according to the stationarity test result to obtain the first training sample set after stationarity test.
[0080] Specifically, the historical sales data is a time series, and this embodiment uses image analysis to perform a stationary test on the first training sample set. Since a stationary time series does not have an obvious trend change in its time series diagram and its range of change is limited, this embodiment uses the change trend of the time series diagram to determine whether the first training sample set is a stationary sequence. If it is not a stationary sequence, the first training sample set is stabilized using a differential operation to obtain a first training sample set after the stationary operation; if it is a stationary sequence, the first training sample set is not processed. Among them, when the differential operation is used for stationary processing, the calculation is completed by subtracting the data separated by k orders in the sequence, and the calculation formula is as shown in the following formula (6).
[0081]
[0082] In formula (6), Z is the time series, t is the number of terms in the series, and k is the order of difference.
[0083] The difference method can convert non-stationary data into stationary data by performing first-order or higher-order differences on the data. The first-order difference is the difference between two adjacent data points, and the higher-order difference is to differentiate the difference result again. This embodiment can convert a non-stationary time series into a stationary time series through a difference operation, thereby simplifying the subsequent analysis and modeling process. A stationary time series is more in line with the assumptions of the model, allowing the model to better capture the laws and trends in the data, thereby improving the accuracy of the prediction.
[0084] Step (23), construct an ARIMA initial module based on the ARIMA algorithm.
[0085] Step (24), using the first training sample set to train the ARIMA initial module to obtain first training result data; and determining the initial values of the hyperparameters of the ARIMA initial module; wherein the hyperparameters include the number of autoregressive (AR) terms, the number of difference (I) times, and the number of moving average (MA) terms.
[0086] Step (25), update the hyperparameters to obtain the trained ARIMA module.
[0087] Specifically, the number of differences is updated according to the order k of the difference operation in step (22). When the stability test result is a stable sequence, the number of differences is a preset number of times 0; the number of autoregressive items and the number of moving average items are updated using the Bayesian Information Criterion (BIC). Among them, autoregression (AR) is used to use past values to predict future values, difference (I) is used to eliminate the trend in the time series and make it stable, and moving average (MA) is used to use the linear combination of past prediction errors to predict future values.
[0088] In some possible embodiments, the residuals of the trained ARIMA module are checked, that is, there is no correlation between the residuals and they follow a normal distribution to verify whether they are white noise. Methods such as the Ljung-Box test, QQ graph, residual autocorrelation function, and residual partial autocorrelation function can be used. If the residuals are not white noise, this means that the model does not fully capture certain patterns in the data or there are problems of overfitting / underfitting. It is necessary to reselect or adjust the model hyperparameters, and sometimes it may be necessary to consider adding other variables or changing the structure of the model. In addition, it is necessary to determine whether the fit is good. If the residuals are not considered white noise, refitting is required. In other possible embodiments, the root mean square error (RMSE) and mean absolute percentage error (MAPE) are used as two prediction evaluation indicators to evaluate the cigarette sales forecast results (such as the first training result data) to test the performance of the trained ARIMA module.
[0089] In a possible embodiment, the LSTM module is trained through the following steps (31) to (33).
[0090] Step (31), constructing an LSTM initial module based on the LSTM algorithm, the LSTM initial module includes an input layer, a hidden layer and an output layer.
[0091] Here, when constructing the LSTM initial module, in addition to taking the historical sales data of different brands of cigarettes as input, it is also necessary to add inventory data, quarterly sales data, holiday data, and policy impact data. The input data structure is shown in the following equations (7) and (8).
[0092] F n =(i1,i2,i3…,i n ), formula (7);
[0093] i t ={s t ,w t ,h t …}, formula (8);
[0094] In formula (7) and formula (8), i t represents the sales data of the tth week, s t Represents inventory data, w t Indicates the number of vacation days per month, h t It indicates the number of cigarettes released that is modified due to policy factors. It should be noted that the data structure in the test data is the same as the data structure in the second training sample set.
[0095] In a possible embodiment, the structure of the LSTM module is as follows: Figure 4 As shown in the figure, it includes input layer, hidden layer and output layer. The input dimension of the input layer is set to 28 (4×7) columns as the feature input of the past week, the time step is 1, the output dimension of the output layer is set to 1, and the activation function is set to Adam for model training. Among them, the dimension is 4×7, which means that 4 weeks are used as the standard input per month, and the remaining days are calculated together with the starting day of the next month.
[0096] The input layer obtains the original data set, where the original data set is pre-stored in the order table in the form of each order. Each order records the order number, customer number, order payment method, order delivery method, order creation time, order status, order delivery address and other information. The input layer obtains the original data (historical sales data, inventory data, quarterly sales data, holiday data) from these data information. After that, the input layer performs data preprocessing and training set division. Data preprocessing includes one or more of missing value processing, duplicate value processing, invalid value processing, outlier processing, standardization and normalization; and divides the preprocessed original data into training sample sets and test sample sets. Finally, the input layer converts the input training sample set or test sample set into supervised learning, and the input layer finally outputs the data set S1.
[0097] Dataset S1 is input to the hidden layer, which includes multiple LSTM units (i.e., multiple LSTM1 units), each of which can capture long-term dependencies in time series data. LSTM units control the flow of information through forget gates, input gates, and output gates, thereby achieving effective modeling of time series data; the hidden layer outputs dataset S1.
[0098] Dataset S1 is output to the output layer. Since the original data input to the input layer has been preprocessed by standardization, the output layer needs to convert the prediction results into the same scale as the original data, that is, de-standardize the data set S1. The output layer finally obtains the sales prediction results.
[0099] Step (32), obtaining a second training sample set, wherein the second training sample set includes inventory data of the past year, historical sales data of the past year, quarterly sales data of the past year, and holiday data of the past year.
[0100] Step (33), using the second training sample set to train the LSTM initial module to obtain a trained LSTM module and second training result data.
[0101] Finally, two model prediction evaluation indicators, root mean square error (RMSE) and mean absolute percentage error (MAPE), were used to evaluate the cigarette prediction result data (such as the second training result data) to test the performance of the trained LSTM module.
[0102] After the ARIMA module obtains the first training result data through the first training sample set, and the LSTM module obtains the second training result data through the second training sample set, it also includes a step of determining the weights in the combination module, such as the following steps (41) to (42).
[0103] Step (41), combining the first training result data and the first real sales data corresponding to the first training sample set, and using the error variance weighted average method to determine the first error data; combining the second training result data and the second real sales data corresponding to the second training sample set, and using the error variance weighted average method to determine the second error data.
[0104] Step (42), determining the weights for weighted combination in the aforementioned step (14) based on the first error data and the second error data, that is, determining λ1 and λ2 in equation (4) based on the first error data and the second error data.
[0105] Specifically, the error variance weighted average method calculates the error between the predicted value and the true value of each single model and sorts them. The weight of the single model is inversely proportional to the error. The larger the error variance, the smaller the weight value. The weights of the single models are assigned one by one according to the error variance. λ1 is the reciprocal of the first error data, and λ2 is the reciprocal of the second error data.
[0106] It should also be noted that before step (41) to step (42), in the step of determining the first training result data, it is also necessary to use formula (1) to formula (3) and use the residual data and the LSTM algorithm principle to adjust the first training result data to obtain the adjusted first training result data, that is, the first training result data in step (41) refers to the adjusted first training result data. Then, the adjusted first training result data is used to perform weighted combination through steps (41) to (42). Among them, in formula (1) Represents the first training result data, y t Represents the true value of the first training sample.
[0107] After determining the weights in the combination module, the method also includes a step of using a test sample set to test the tobacco sales prediction model, such as the following steps (51) to (53).
[0108] Step (51), obtain a test sample set.
[0109] Step (52), using the test sample set to test the tobacco sales prediction model, and obtaining the test results corresponding to the test sample set.
[0110] Step (53), combining the actual results and test results corresponding to the test sample set, using the root mean square error algorithm and the mean absolute percentage error algorithm to evaluate the output results of the test sample set to verify the performance of the tobacco sales prediction model.
[0111] In another possible embodiment, see Figure 3 , the ARIMA module is trained and tested through the following steps 61 to 68.
[0112] Step 61: Obtain a first training sample set.
[0113] Step 62, stationarity test: Perform a stationarity test on the first training sample set. If the test passes, go to step 64, otherwise continue to execute step 63.
[0114] Step 63: differential operation. Perform differential operation and adjust the samples in the first training sample set, and then go to step 61 and execute again.
[0115] Step 64, randomness test: Perform a randomness test on the first training sample set. If the test passes, go to step (69). If the test fails, continue to step 65.
[0116] Specifically, randomness detection is used to check time series to determine whether there is correlation between series. Whether the historical value of the time series has an impact on the future value. If it has no impact on the future development trend, it means that the time series is a pure random sequence and is noise data, which needs to be excluded (generally, tobacco data does not contain white noise data).
[0117] Step 65: module training: Input the first training sample set into the ARIMA initial module for training to obtain first training result data.
[0118] Step 66, module optimization: Optimize the ARIMA initial module to obtain a trained ARIMA module.
[0119] Step 67, module test: Use the first test sample set to perform module test on the trained ARIMA module. If the test passes, proceed to the next step 68. If the test fails, return to step 65.
[0120] Step 68: Sales volume forecasting: The data to be tested is input into the trained ARIMA module for sales volume forecasting to obtain the first forecast result data.
[0121] Step 69, end. If the randomness test fails, the process also ends.
[0122] This embodiment proposes a tobacco sales forecasting method based on smart logistics, including the following contents (1)-(3).
[0123] (1) Data preprocessing: Clean, normalize, and convert multi-dimensional data such as historical sales, inventory data, seasonal factors, and holiday factors to provide a high-quality data source for subsequent model training and model prediction.
[0124] (2) Model training: First, build the ARIMA module, fit the model by determining the good hyperparameters, check the residual to verify whether it is white noise, and judge whether the fit is good. If the residual is not white noise, refitting is required. Secondly, use the deep learning framework to build the LSTM module and train it to obtain a trained LSTM module.
[0125] (3) Model prediction: Finally, the two models are connected in parallel, and the results are input into the combination module for weighted combination. For example, in some embodiments, the prediction is first performed through the ARIMA module, and then the residual data is calculated, and the residual prediction data is determined by the neural network based on the LSTM algorithm. Then, the prediction result of the ARIMA module is adjusted using the residual prediction data to obtain the first prediction data with improved accuracy. Finally, the second prediction data obtained by the LSTM model containing various multivariables is weightedly combined to obtain the final prediction data of tobacco sales.
[0126] This embodiment aims to improve the accuracy and adaptability of tobacco sales forecasting and help the tobacco industry grasp sales trends more accurately in a changing market environment. Existing tobacco sales forecasting methods usually adopt a single model, which can only play its superiority in specific scenarios, and only one model cannot make more comprehensive use of the information in the data. This embodiment combines the idea of combining models and the advantages of ARIMA algorithm and LSTM algorithm to reduce the impact of various cigarette specifications and complex environmental factors on tobacco cigarette forecasting. This is because compared with the traditional sales forecasting method, this embodiment combines the models in parallel, where the ARIMA module is responsible for processing linear components and periodic fluctuations, while the LSTM module can cope with complex nonlinear patterns and long-term dependencies. Through the parallel structure, these features can be processed simultaneously, thereby improving the overall robustness and avoiding the weaknesses of a single model. At the same time, in the processing of data, since ARIMA is suitable for processing linear data with regularity, the structure of its data source is usually relatively simple, and the LSTM module makes up for this defect well. The LSTM module can process multi-source heterogeneous data, such as historical sales data, inventory information, policy changes, etc., has a strong feature extraction capability, and can simultaneously integrate information from multiple data sources. The parallel connection of models also provides more contextual information for the ARIMA module, improving the model's adaptability and generalization capabilities to diverse data, thereby optimizing the overall prediction effect. The parallel model structure also has flexible model tuning and scalability. Since the ARIMA module and LSTM module are independently trained models, their parameter adjustment and optimization can be performed independently, which makes the model tuning more flexible and efficient. In addition, other prediction models can be introduced for parallel processing according to actual conditions to further improve the prediction accuracy and adaptability.
[0127] See also Figure 5, a tobacco sales prediction device based on smart logistics provided in this embodiment includes a data acquisition module 10 and a sales prediction module 20. The data acquisition module 10 is used to obtain the tobacco sales data to be tested; wherein the data to be tested is multi-source data. The sales prediction module 20 is used to input the data to be tested into the tobacco sales prediction model to perform tobacco sales prediction and obtain tobacco sales prediction results; wherein the tobacco sales prediction model includes a trained ARIMA module, a trained LSTM module and a combination module; the ARIMA module and the LSTM module are respectively connected to the combination module; the trained ARIMA module is used to determine the first prediction data of tobacco sales, the trained LSTM module is used to determine the second prediction data of tobacco sales, and the combination module is used to determine the final prediction data of tobacco sales based on the first prediction data and the second prediction data.
[0128] In an optional embodiment, the data to be tested includes tobacco inventory data, historical sales data, quarterly sales data and holiday data, wherein the historical sales data includes tobacco sales data of the same month in the past year.
[0129] In an optional embodiment, the combination module specifically includes: a residual data module, a residual prediction module, an adjustment module and a weighted combination module. The residual data module is used to determine the residual data based on the first prediction data and the historical sales data of tobacco in the same month of the past year in the historical sales data. The residual module is used to model the residual data using the LSTM algorithm to determine the residual prediction data. The adjustment module is used to adjust the first prediction data according to the residual prediction data to obtain the adjusted first prediction data. The weighted combination module is used to perform a weighted combination of the adjusted first prediction data and the second prediction data to obtain the final prediction data.
[0130] In an optional embodiment, the ARIMA module in the sales forecasting module 20 includes: a first acquisition module, a stationarity detection module, a first construction module, a first training module and an update module. The first acquisition module is used to acquire a first training sample set; wherein the first training sample set includes historical sales data for the past year. The stationarity detection module is used to perform a stationarity detection on the first training sample set, and process the first training sample set according to the stationarity detection result to obtain the first training sample set after stationarization detection. The first construction module is used to construct an ARIMA initial module based on the ARIMA algorithm. The first training module is used to train the ARIMA initial module using the first training sample set to obtain the first training result data; and determine the initial values of the hyperparameters of the ARIMA initial module; wherein the hyperparameters include the number of autoregressive terms, the number of differences and the number of moving average terms. The first update module is used to update the hyperparameters to obtain a trained ARIMA module.
[0131] In an optional embodiment, the stationarity detection module is specifically used to: perform stationarity detection on the first training sample set using an image analysis method, and determine whether the first training sample set is a stationary sequence using the changing trend of the time series diagram; if it is not a stationary sequence, perform stationarity processing on the first training sample set using a differential operation to obtain the first training sample set after stationarity processing; if it is a stationary sequence, do not process the first training sample set.
[0132] In an optional embodiment, the update module is specifically used to: update the number of differences according to the order of the difference operation, when the stationarity test result is a stationary sequence, the number of differences is a preset number value; and, use the Bayesian criterion to update the number of autoregressive terms and the number of moving average terms.
[0133] In an optional embodiment, the LSTM module in the sales forecasting module 20 includes a second construction module, a second acquisition module and a second training module. The second construction module is used to construct an LSTM initial module based on the LSTM algorithm, and the LSTM initial module includes an input layer, a hidden layer and an output layer. The second acquisition module is used to obtain a second training sample set, wherein the second training sample set includes inventory data for the past year, historical sales data for the past year, quarterly sales data for the past year, and holiday data for the past year. The second training module is used to train the LSTM initial module using the second training sample set to obtain a trained LSTM module and second training result data.
[0134] In an optional embodiment, in the sales forecasting module 20, after the LSTM module and the ARIMA module, an error confirmation module and a weight confirmation module are also included (i.e., the LSTM module and the ARIMA module are respectively connected to the error confirmation module, and the error confirmation module is connected to the weight confirmation module). The error confirmation module is used to determine the first error data by using the error variance weighted average method in combination with the first training result data and the first real sales data corresponding to the first training sample set; and to determine the second error data by using the error variance weighted average method in combination with the second training result data and the second real sales data corresponding to the second training sample set. The weight confirmation module is used to determine the weight of the weighted combination in the step of weighted combination of the adjusted first prediction data and the second prediction data to obtain the final prediction data according to the first error data and the second error data.
[0135] In an optional embodiment, the weight confirmation module is connected to a test sample set module, and the test sample set module includes a third acquisition module, a test module, and an evaluation module. The third acquisition module is used to acquire the test sample set. The test module is used to test the tobacco sales prediction model using the test sample set to obtain the test results corresponding to the test sample set. The evaluation module is used to combine the actual results and test results corresponding to the test sample set, and use the root mean square error algorithm and the mean absolute percentage error algorithm to evaluate the output results of the test sample set to verify the performance of the tobacco sales prediction model.
[0136] The device of this embodiment realizes tobacco sales forecast by combining ARIMA module and LSTM module in parallel, wherein the module can be applied to a variety of time series, including trend, seasonal and non-stationary data, through the efficient time series modeling capability of ARIMA module; through the powerful feature extraction capability and nonlinear fitting advantage of LSTM module, multi-source heterogeneous data (including historical sales data, current inventory, holidays, policy impact, etc.) are effectively integrated to accurately predict future tobacco sales. As a classic statistical model, ARIMA module performs well in capturing linear trends and seasonality. LSTM module is based on deep learning theory and can handle complex nonlinear relationships and long-term dependencies. Compared with the traditional single prediction model, the parallel combination of the two modules in this embodiment has a stronger generalization ability, can better capture the complex patterns in the data, give full play to their respective advantages, improve the accuracy and stability of the prediction, and can also obtain better performance on new data.
[0137] The device provided in the embodiment of the present application is adopted. Since the device adopts the same inventive concept as the above-mentioned method provided in the embodiment of the present application, on the premise that the method can solve the technical problem, the device can also solve the technical problem, which will not be repeated here.
[0138] It is known from common technical knowledge that the present invention can be implemented by other embodiments that do not deviate from its spirit or essential features. Therefore, the above disclosed embodiments are only illustrative in all respects and are not exclusive. All changes within the scope of the present invention or within the scope equivalent to the present invention are included in the present invention.
Claims
1. A tobacco sales forecasting method based on smart logistics, characterized in that: include: Acquire tobacco sales data to be tested; wherein the data to be tested is multi-source data; The test data is input into a tobacco sales prediction model to perform tobacco sales prediction and obtain a tobacco sales prediction result; wherein the tobacco sales prediction model includes a trained ARIMA module, a trained LSTM module and a combination module; the ARIMA module and the LSTM module are respectively connected to the combination module; the trained ARIMA module is used to determine the first prediction data of tobacco sales, the trained LSTM module is used to determine the second prediction data of tobacco sales, and the combination module is used to determine the final prediction data of tobacco sales based on the first prediction data and the second prediction data.
2. The tobacco sales forecasting method based on intelligent logistics according to claim 1 is characterized in that: The data to be tested includes tobacco inventory data, historical sales data, quarterly sales data, holiday data and policy impact data, wherein the historical sales data includes tobacco sales data of the same month in the past year.
3. The tobacco sales forecasting method based on intelligent logistics according to claim 2 is characterized in that: The first prediction data and the second prediction data determine the final prediction data of tobacco sales, including: Determine residual data based on the first forecast data and the historical sales data of tobacco in the same month of the past year in the historical sales data; Modeling the residual data using an LSTM algorithm to determine residual prediction data; Adjusting the first prediction data according to the residual prediction data to obtain adjusted first prediction data; The adjusted first prediction data and the second prediction data are weightedly combined to obtain the final prediction data.
4. The tobacco sales forecasting method based on intelligent logistics according to claim 3 is characterized in that: The ARIMA module is trained as follows: Obtaining a first training sample set; wherein the first training sample set includes historical sales data for the past year; Performing a stationarity test on the first training sample set, and processing the first training sample set according to the stationarity test result to obtain a first training sample set after stationarity test; Construct the ARIMA initial module based on the ARIMA algorithm; Using the first training sample set to train the ARIMA initial module to obtain first training result data; and determining initial values of hyperparameters of the ARIMA initial module; wherein the hyperparameters include the number of autoregressive terms, the number of differences, and the number of moving average terms; The hyperparameters are updated to obtain a trained ARIMA module.
5. The tobacco sales forecasting method based on intelligent logistics according to claim 4 is characterized in that: The step of performing a stationarity test on the first training sample set and processing the first training sample set according to a stationarity test result to obtain a first training sample set after stationarity test includes: The first training sample set is tested for stationarity using an image analysis method, and whether the first training sample set is a stationary sequence is determined using a changing trend of a time series graph; if it is not a stationary sequence, the first training sample set is stabilized using a differential operation to obtain a first training sample set after the stationary processing; if it is a stationary sequence, the first training sample set is not processed.
6. The tobacco sales forecasting method based on intelligent logistics according to claim 5 is characterized in that: The updating of the hyperparameters comprises: The number of differences is updated according to the order of the difference operation. When the stationarity detection result is a stationary sequence, the number of differences is a preset number value; and the number of autoregressive terms and the number of moving average terms are updated using the Bayesian criterion.
7. The tobacco sales forecasting method based on intelligent logistics according to claim 4 is characterized in that: The LSTM module is trained as follows: Constructing an LSTM initial module based on the LSTM algorithm, wherein the LSTM initial module includes an input layer, a hidden layer, and an output layer; Acquire a second training sample set, wherein the second training sample set includes inventory data of the past year, historical sales data of the past year, quarterly sales data of the past year, and holiday data of the past year; The LSTM initial module is trained using the second training sample set to obtain a trained LSTM module and second training result data.
8. The tobacco sales forecasting method based on intelligent logistics according to claim 7 is characterized in that: The method further comprises: Combining the first training result data with the first real sales data corresponding to the first training sample set, using the error variance weighted average method to determine the first error data; combining the second training result data with the second real sales data corresponding to the second training sample set, using the error variance weighted average method to determine the second error data; The weight for weighted combination is determined according to the first error data and the second error data.
9. The tobacco sales forecasting method based on intelligent logistics according to claim 1 is characterized in that: The method further comprises: Get a test sample set; Using the test sample set to test the tobacco sales prediction model, and obtaining the test results corresponding to the test sample set; In combination with the actual results and test results corresponding to the test sample set, the output results of the test sample set are evaluated using a root mean square error algorithm and a mean absolute percentage error algorithm to verify the performance of the tobacco sales prediction model.
10. A tobacco sales forecasting device based on smart logistics, characterized in that: include: A data acquisition module is used to acquire tobacco sales data to be tested; wherein the data to be tested is multi-source data; A sales forecasting module is used to input the test data into a tobacco sales forecasting model to perform tobacco sales forecasting and obtain a tobacco sales forecasting result; wherein the tobacco sales forecasting model includes a trained ARIMA module, a trained LSTM module and a combination module; the ARIMA module and the LSTM module are respectively connected to the combination module; the trained ARIMA module is used to determine the first forecast data of tobacco sales, the trained LSTM module is used to determine the second forecast data of tobacco sales, and the combination module is used to determine the final forecast data of tobacco sales based on the first forecast data and the second forecast data.
Citation Information
Patent Citations
Cigarette sales prediction method and device, computer equipment and storage medium
CN117474588A
Cited By
Tobacco intelligent identification and sales prediction management system based on improved YOLOv5 and LSTM
CN121147956A