Sales prediction method and terminal based on second-order cross multiple linear regression
By adopting a sales forecasting method based on second-order cross-multivariate linear regression in the cross-border e-commerce field, the problems of low accuracy and time-consuming sales forecasting in the prior art are solved, and the effect of improving the accuracy of the sales forecasting model is achieved.
Patent Information
- Application Number
- CN202510088741.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-21
- Publication Date
- 2025-02-25
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the sales forecast of the cross-border e-commerce field, the accuracy rate is low and takes a long time. Especially when the enterprise scale is large and the product range is wide, manual prediction cannot consider too many influencing factors, resulting in the further away from the current date, the lower the accuracy of the forecast sales.
The sales volume prediction method based on second-order cross-multivariate linear regression is adopted. By obtaining historical sales data, it is divided into training sets and test sets, the target tensor corresponding to the test set is calculated and the mask is generated. The data that ignores the mask position when calculating the loss function, thereby reducing the quality requirements for the original training data and improving the prediction accuracy of the model.
During the model iteration process, the high error part in the original training data is automatically ignored, which reduces the impact of the low-quality part in the original training data on model training and improves the accuracy of the sales prediction model.
Smart Images

Figure CN119515455A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a field, and in particular to a sales forecasting method and terminal based on second-order cross multiple linear regression. Background Art
[0002] Sales forecasting is important in e-commerce business because the results of sales forecasting are directly related to supply chain management and operational decisions. Sales forecasting can help companies understand future sales demand, formulate reasonable procurement and supply plans, optimize logistics and inventory management, and reduce logistics and inventory costs; it can also help companies formulate marketing strategies and promotional activities, optimize product portfolios, develop new products, and improve their market competitiveness.
[0003] In the field of cross-border e-commerce, traditional sales forecasting methods are based on financial data and historical sales data, using statistical analysis methods, such as regression analysis methods such as moving average method, exponential smoothing method, or time series analysis method, combined with expert judgment method and market analysis method for forecasting. Due to the long time of cross-border transportation, each forecast needs to forecast sales for at least the next six months. If the company is large and the business covers a wide range of products, this forecasting method will inevitably consume a lot of time and manpower, and manual forecasting cannot take into account too many influencing factors, which leads to the fact that the farther away from the current date, the lower the accuracy of the predicted sales.
[0004] There are also a small number of companies that use machine learning regression models for forecasting, but this method is not widely used in the field of cross-border e-commerce. Even if it is used, the forecast accuracy is often not high. This is because when using machine learning methods to forecast sales, data quality often has a great impact on the forecast effect of the model. Summary of the invention
[0005] The technical problem to be solved by the present invention is to provide a sales forecasting method and terminal based on second-order cross multiple linear regression, so as to improve the accuracy of the sales forecasting model.
[0006] In order to solve the above technical problems, a technical solution adopted by the present invention is: A sales forecasting method based on second-order cross-multivariate linear regression includes the following steps: Acquire historical sales data, and divide the historical sales data into a training set and a test set; Obtaining the values to be adjusted in the training set and the default values corresponding to the values to be adjusted; Calculate the target tensor corresponding to the test set, and generate a mask at the position of the default value that is not equal to the target tensor; An initial second-order cross-multivariate linear regression model is trained according to the training set to obtain a target second-order cross-multivariate linear regression model, and the mask is ignored when calculating the loss function.
[0007] In order to solve the above technical problems, another technical solution adopted by the present invention is: A sales forecasting terminal based on second-order cross multiple linear regression includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented: Acquire historical sales data, and divide the historical sales data into a training set and a test set; Obtaining the values to be adjusted in the training set and the default values corresponding to the values to be adjusted; Calculate the target tensor corresponding to the test set, and generate a mask at the position of the default value that is not equal to the target tensor; An initial second-order cross-multivariate linear regression model is trained according to the training set to obtain a target second-order cross-multivariate linear regression model, and the mask is ignored when calculating the loss function.
[0008] The beneficial effects of the present invention are as follows: historical sales data are divided into a training set and a test set for model training, before training, the values to be adjusted in the training set are obtained and adjusted to the default values, and the target tensor corresponding to the calculated test set is obtained, and for the default values that are not equal to the target tensor, a mask is generated to indicate that the default value may have a large error, and then when calculating the loss function in the iterative process of the model, the masked data is ignored, thereby reducing the quality requirements for the original training data, and automatically ignoring the high-error parts in the original training data during the model iteration process, thereby reducing the impact of the low-quality parts in the original training data on the model training, and improving the prediction accuracy of the model when the quality of the original training data cannot be further improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 A flow chart of the steps of a sales forecasting method based on second-order cross multiple linear regression according to an embodiment of the present invention; Figure 2 A schematic diagram of data flow of a sales forecasting method based on second-order cross multiple linear regression according to an embodiment of the present invention; Figure 3 This is another step flow chart of a sales forecasting method based on second-order cross multiple linear regression according to an embodiment of the present invention; Figure 4 A schematic diagram of a model structure of a sales forecasting method based on second-order cross multiple linear regression according to an embodiment of the present invention; Figure 5It is a structural schematic diagram of a sales forecasting terminal based on second-order cross multiple linear regression according to an embodiment of the present invention; Description of labels: 1. A sales forecasting terminal based on second-order cross-multivariate linear regression; 2. Processor; 3. Memory. DETAILED DESCRIPTION
[0010] In order to explain the technical content, achieved objectives and effects of the present invention in detail, the following is an explanation in combination with the implementation modes and the accompanying drawings.
[0011] Please refer to Figure 1 , a sales forecasting method based on second-order cross-multivariate linear regression, comprising the steps of: Acquire historical sales data, and divide the historical sales data into a training set and a test set; Obtaining the values to be adjusted in the training set and the default values corresponding to the values to be adjusted; Calculate the target tensor corresponding to the test set, and generate a mask at the position of the default value that is not equal to the target tensor; An initial second-order cross-multivariate linear regression model is trained according to the training set to obtain a target second-order cross-multivariate linear regression model, and the mask is ignored when calculating the loss function.
[0012] From the above description, it can be seen that the beneficial effects of the present invention are: dividing historical sales data into a training set and a test set for model training, obtaining the values to be adjusted in the training set before training and adjusting them to the default values, and obtaining the target tensor corresponding to the calculated test set, and for the default values that are not equal to the target tensor, generating a mask to indicate that the default value may have a large error, then ignoring the masked data when calculating the loss function in the iterative process of the model, thereby reducing the quality requirements for the original training data, and automatically ignoring the high-error parts in the original training data during the model iteration process, thereby reducing the impact of the low-quality parts in the original training data on the model training, and improving the prediction accuracy of the model when the quality of the original training data cannot be further improved.
[0013] Furthermore, the obtaining of historical sales data includes: If the historical sales data is discrete data, the historical sales data is mapped into a continuous vector by using an Embedding method; If the historical sales data is continuous data, discretization, nonlinear change or normalization is performed on the historical sales data; If the historical sales data is text data, a pre-trained natural language processing model is used to obtain text features.
[0014] From the above description, it can be seen that historical sales data includes not only sales data, but also records of various factors that affect sales. Therefore, historical sales data will include a variety of different data types. Therefore, different initialization methods are used for different data types. Data features can be extracted according to the characteristics of different data types, thereby improving the calculation accuracy of subsequent models.
[0015] Further, the training of the initial second-order cross-multivariate linear regression model according to the training set to obtain the target second-order cross-multivariate linear regression model, and ignoring the mask when calculating the loss function, includes: Inputting the training data in the training set into the initial second-order cross-multivariate linear regression model to obtain predicted sales; Calculating a value of a loss function according to the predicted sales volume and the target sales volume corresponding to the training data, and ignoring the masked training data in the training set; Adjusting the parameters of the initial second-order cross-multivariate linear regression model according to the value of the loss function to obtain an updated initial second-order cross-multivariate linear regression model; Determine whether the iteration stop condition is met. If so, use the current initial second-order cross-multivariate linear regression model as the target second-order cross-multivariate linear regression model; otherwise, return to execute the step of inputting the training data in the training set into the initial second-order cross-multivariate linear regression model.
[0016] From the above description, it can be seen that the training data is input into the initial second-order cross-multivariate linear regression model to obtain the predicted sales volume, and the value of the loss function can be calculated with the target sales volume corresponding to the training data in the training set, that is, the true value, and in the process of calculating the loss function, the masked values are ignored and not included in the calculation of the loss function, because the masked values are values that are filled with default values and still deviate from the test set, that is, the complete data. In the training process of the model, the optimization of the model parameters depends on the calculation of the loss function. The loss function quantifies the error between the predicted value and the true value obtained by the model, thereby guiding the adjustment of the model parameters to reduce the error. Therefore, in the calculation process of the loss function, the influence of poor quality data is discarded, and only the data in the training set with better quality is considered, thereby achieving the improvement of the quality of the loss function without relying on the quality of the original data.
[0017] Furthermore, the step of inputting the training data in the training set into the initial second-order cross-multivariate linear regression model to obtain the predicted sales volume includes: Inputting the training data in the training set into the linear layer of the initial second-order cross-multivariate linear regression model for linear transformation to obtain a linear part; Input the training data into the cross layer of the initial second-order cross multiple linear regression model to calculate the cross part; The predicted sales volume is obtained according to the linear part and the cross part.
[0018] From the above description, we can see that in the model, which is divided into linear layers and cross layers, the input training data is not only individually feature extracted, but also extracted after being associated with each other, so as to fully explore the influence of different factors in the training data on the prediction results and improve the accuracy of the final prediction results.
[0019] Furthermore, the step of inputting the training data in the training set into the forward propagation function of the initial second-order cross-multivariate linear regression model to perform linear transformation to obtain the linear part includes: ; Where i represents the feature, x i represents the i-th feature of the training data, w i represents the weight of feature i in the linear layer, N represents the total number of features in the training data, and lr_part represents the linear part.
[0020] From the above description, it can be seen that in the process of calculating the linear part, the training data is sent to the linear layer, and the weight of the linear layer is taken into account to comprehensively obtain the predicted linear part, thereby improving the accuracy of subsequent prediction results.
[0021] Furthermore, the step of inputting the training data into the cross layer of the initial second-order cross multivariate linear regression model to obtain the cross part comprises: ; In the formula, v i v j represents the weight of the intersection of feature i and feature j at the intersection layer; x i x j represents a cross term, and cross_part represents the cross part.
[0022] From the above description, it can be seen that in the process of calculating the cross part, different weights are also set for the corresponding cross layers, so as to be closer to the actual factors and improve the accuracy of the final prediction value.
[0023] Further, obtaining the predicted sales volume according to the linear part and the cross part includes: Z = lr_part + cross_part + b; In the formula, lr_part represents the linear part, cross_part represents the cross part, and b represents the bias term.
[0024] From the above description, it can be seen that after obtaining the prediction of the linear part and the prediction of the cross part, the bias term is set with reference to the pure linear prediction method, and the bias term provides further space for adjusting the error, thereby improving the accuracy of the final prediction value.
[0025] Furthermore, the calculation loss function includes: Computes the weighted sequential mean squared error and the aggregate mean squared absolute error.
[0026] From the above description, it can be seen that the loss function composed of the two error types is enriched, which can enrich the types of errors used in the parameter optimization process and cover a wider range of possible causes of errors, thereby improving the effect of parameter optimization in the model.
[0027] Further, the calculation of the weighted sequence mean square error weight_mse includes: ; ; ; ; ; In the formula, no_mask represents the total number of mask mask_symbols with a value of 0; mask_symbol represents a mask; loss_t2 represents a loss tensor with a weight; loss_t1 represents a loss tensor; weight represents a preset weight tensor, which is a pre-set value; dim=-1 represents the last dimension of the tensor; unsqueeze represents inserting a new dimension at the position of the last dimension of the weight tensor; input represents the training tensor corresponding to the data in the training set; target represents the target tensor; not_equal represents obtaining unequal positions; mask_value represents the default value.
[0028] From the above description, it can be seen that by setting the mask, the target tensor corresponding to the test set is used as a comparison reference. If the default value and the target tensor do not match, a mask is added, and when calculating the loss tensor, the corresponding value is directly ignored according to the mask, thereby reducing the impact of low-quality data in the original training data on the loss value calculation, ensuring that the loss value can represent the prediction error of the model to the greatest extent, thereby ensuring the effect of parameter tuning in the model, and in the process of calculating the tensor, first set the weight for the position in the tensor sequence, that is, the more important the data at a certain position in the sequence, the higher the weight of that position. In actual applications, the weight settings are different for different scenarios. In this way, the weights can be adjusted according to the different importance of each dimension in the actual data.
[0029] Please refer to Figure 4 A sales forecasting terminal based on second-order cross-multivariate linear regression includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, each step of the above-mentioned sales forecasting method based on second-order cross-multivariate linear regression is implemented.
[0030] Among the relevant sales prediction technologies, the traditional machine learning regression model has high requirements for input data. On the one hand, feature engineering directly affects the model performance. The traditional regression model is sensitive to outliers. If the features suitable for the model are not selected, extracted and designed, or the feature dimension is too high, it is easy to increase the computational complexity or overfitting. On the other hand, the traditional regression model does not support feature crossover. If the model needs to extract the combination information of features, the features can only be reasonably combined manually based on business knowledge. However, in the field of cross-border e-commerce, the factors affecting sales are highly complex. Some common factors include: (1) seasonal factors, such as holidays and platform promotions; (2) promotional activities, including spontaneous promotional activities of merchants, such as limited-time discounts and coupons; (3) competitors, mainly changes in the promotion methods of competitors; (4) logistics impact, including warehouse inventory, replenishment logistics timeliness, etc.; (5) external events, such as market trends, weather temperature effects, policy adjustments, etc. These factors often interact with each other and will have long-term or short-term impacts on sales, resulting in fluctuations in sales data. In addition, during the data collection process, data loss, data errors or duplicate records may occur, which will increase the number of outliers and missing values in the data set. All of the above factors may lead to high noise in cross-border e-commerce datasets. In addition, traditional machine learning regression models have the defect of being difficult to capture nonlinear relationships.
[0031] It can be seen that, first, the traditional machine learning regression model has strict requirements on the training data set. The training data set needs to have a large enough amount of data and enough variable information, and the noise of the data set cannot be too large. Otherwise, the reliability and predictive ability of the model will decrease. When there is a significant imbalance in the number of samples of different categories in the sample, the prediction accuracy of the model will also be greatly reduced for the category with a small sample size.
[0032] Second, the regression model of traditional machine learning cannot directly perform feature crossover and can only manually create new crossover features through feature engineering. Therefore, the regression model of traditional machine learning cannot directly use the combined information between features to improve prediction accuracy, and there is a situation of incomplete information extraction.
[0033] Third, the regression model of traditional machine learning is a general model that cannot meet all scenarios. However, the cross-border e-commerce field often encounters sales forecasting tasks in some personalized scenarios, such as the platform's promotional shopping season, the cold start period of new products, or products with special peak and off-peak seasons. The prediction accuracy of the general model in specific scenarios will decrease.
[0034] Fourth, when making predictions, it is necessary to provide model-dependent features to generate prediction results, and refer to the lack of feature cross-training in the model training process mentioned above. Therefore, missing features or providing incorrect features may lead to errors in the prediction results.
[0035] Fifth, the model prediction results are not completely reliable. There are generally two situations in which the model prediction is inaccurate. One is that special events occur in the actual business, such as problems with the sales platform, emergencies, such as problems with logistics and supply production leading to tight inventory, or the sudden emergence of new market hotspots leading to changes in marketing plans, etc., which affect future sales; the other is due to the limitations of the model itself, resulting in abnormal prediction data, and the solution in this invention is to reduce the limitations of the model itself.
[0036] The above-mentioned sales forecasting method and terminal based on second-order cross-multivariate linear regression of the present invention can be applied to sales forecasting of various commodities, especially scenarios such as cross-border e-commerce where the time period required for forecasting is long and the quality of original data is uncertain, and the specific implementation method is used to illustrate it below.
[0037] Please refer to Figure 1-4 , Embodiment 1 of the present invention is: A sales forecasting method based on second-order cross-multivariate linear regression includes the following steps: S1. Obtain historical sales data, and divide the historical sales data into a training set and a test set.
[0038] Among them, historical sales data includes advertising data sets, logistics data sets, sales data, user behavior data sets, user comment data sets, etc., which are generally sorted data obtained from third-party platforms; for example, store data exported from e-commerce platforms.
[0039] Please refer to Figure 2 , because the historical sales data obtained cannot be used directly for model training, feature engineering is also required. For different types of historical sales data, different feature extraction methods need to be matched to fully mine the features and obtain the most appropriate feature identification. Therefore, the following steps S11-S13 are also required in S1.
[0040] S11. If the historical sales data is discrete data, the historical sales data is mapped into a continuous vector by using an Embedding method.
[0041] Discrete data includes category data and time data. Category data includes product categories, sales regions, user tags, user behaviors, etc. Time data is time dimension data such as year, month, day, and week extracted from specific dates. Since there are many feature categories in the e-commerce field, the embedding method is usually used to map discrete data from low-dimensional data into high-dimensional dense vectors, so that the model can better capture the similarities and differences between features.
[0042] S12. If the historical sales data is continuous data, the historical sales data is discretized, nonlinearly changed or normalized. The specific processing method needs to be determined according to the data performance. For example, during training, different data processing methods can be tried to compare the final training results of the model, or the corresponding data processing method can be selected based on the processing methods of other publicly available model training data.
[0043] Continuous data is numerical, including sales volume, inventory, etc. There are generally three types of processing methods: discretization, nonlinear change, and normalization.
[0044] Discretization is a binning process based on the data distribution of continuous features, such as equal-frequency binning, equal-width binning, and cluster binning. By discretizing continuous data, the complexity of the model can be simplified, and the sensitivity of the model to outliers can be reduced. At the same time, part of the data information can be retained, making the model easier to understand and explain.
[0045] Nonlinear change methods include logarithmic transformation, square root transformation, etc. By performing appropriate nonlinear transformations on continuous data, the distribution characteristics of the data can be improved to make it more consistent with the model assumptions and improve the performance and robustness of the model. Other general continuous features are normalized to unify the value ranges of different features to avoid the model being affected by the value range of the features.
[0046] S13. If the historical sales data is text data, a pre-trained natural language processing model is used to obtain text features.
[0047] Text data contains features such as product reviews. Due to the large scale of text data in the e-commerce field, the BERT method (a natural language processing model) is usually used to process text data. First, the text data is preprocessed, such as word segmentation and context tagging, and then the pre-trained BERT model is used to encode the text data to obtain text features.
[0048] The historical sales data processed by S11-S13 is divided into samples for model training. Each sample includes training data and the target sales volume corresponding to the training data. The training data is the feature data related to the target sales volume, which affects the final target sales volume. During the model training process, the predicted sales volume is obtained based on the sample training data, and the predicted sales volume is compared with the target sales volume. The model parameters are optimized based on the difference in comparison (loss function).
[0049] S2. Obtain the value to be adjusted in the training set and the default value corresponding to the value to be adjusted; S3. Calculate the target tensor corresponding to the test set, and generate a mask at a position of a default value that is not equal to the target tensor; S4. Training an initial second-order cross-multivariate linear regression model according to the training set to obtain a target second-order cross-multivariate linear regression model, and ignoring the mask when calculating the loss function; including steps S41-S44.
[0050] S41, input the training data in the training set into the initial second-order cross-multivariate linear regression model to obtain the predicted sales volume, please refer to Figure 4 The second-order cross-multivariate linear regression model includes a cross layer, a linear layer +, and a trigger activation, including steps S411-S413.
[0051] S411, inputting the training data in the training set into the linear layer of the initial second-order cross-multivariate linear regression model to perform linear transformation to obtain a linear part, including: ; In the formula, i represents the feature, x i represents the i-th feature of the training data, w i represents the weight of feature i in the linear layer, N represents the total number of features in the training data, and lr_part represents the linear part. The sample is passed to the forward propagation function, and each feature in a single sample is linearly transformed according to the input data to obtain the linear part.
[0052] S412, inputting the training data into the cross layer of the initial second-order cross multiple linear regression model to calculate the cross part, including: ; In the formula, v i v j represents the weight of the intersection of feature i and feature j at the intersection layer; x i x j It represents the cross term, which means the intersection of the i-th feature and the j-th feature of the training data; cross_part represents the cross part.
[0053] S413, obtaining predicted sales volume Z=lr_part+cross_part+b according to the linear part and the cross part; In the formula, b represents the bias term.
[0054] In an optional implementation, after the linear part and the cross part are added, operations such as logarithmic transformation and dimension adjustment can be performed to further provide an adjustable part to improve the accuracy of the model, so as to achieve a balance between the complexity of the model and the accuracy of the model, and avoid the model being too complex to affect the efficiency of training.
[0055] S42. Calculate the value of the loss function according to the predicted sales volume and the target sales volume corresponding to the training data, and ignore the masked training data in the training set. The loss function is an evaluation index for the model, which is used to measure the performance of the model on the training data. The loss function is made smaller through iteration, thereby improving the accuracy of the model prediction.
[0056] The loss function calculated in S42 includes: Calculates weighted sequence mean square error and aggregate mean square absolute error, including: S421, calculating the weighted sequence mean square error weight_mse, including: ; ; ; ; ; In the formula, no_mask indicates the number of mask_symbols that are 0 in a single sample; mask_symbol indicates a mask; loss_t2 indicates a loss tensor with weights; loss_t1 indicates a loss tensor, mask_symbol is composed of 0 and 1, the mask corresponding to the missing value in the data is 0, and multiplying by the mask means ignoring the missing value in the data; dim=-1 indicates the last dimension of the tensor; the weight here is pre-set, that is, the more important the data at a certain position in the sequence is, the higher the weight of that position is. In actual application scenarios, different weight settings are required; unsqueeze indicates inserting a new dimension at the position of the last dimension of the weight tensor; input indicates the training tensor corresponding to the data in the training set; target indicates the target tensor, mask_value is the default value, and is used to identify missing values. If a missing value appears in a certain position of the tensor, mask_value will be used to fill it; not_equal indicates obtaining the position in the target tensor where the value is not equal to the default value mask_value. If they are not equal, it means that a missing value appears, and mask_symbol is marked as 0, otherwise it is marked as 1; Specifically, the construction process of the above formula includes: (1) Divide the historical sales data into a training set and a test set according to the set ratio. Convert the data in the training set into the training tensor input and the data in the test set into the target tensor target. Before training, first set a default value mask_value for the missing values or outliers (i.e., the values to be adjusted) in the training data. The terminal generates a mask mask_symbol with a value of 0 based on the positions where mask_value and the target tensor target are not equal.
[0057] (2) weight_mse will ignore the positions where the target value is equal to the mask symbol and weight the loss value according to the weight. Then calculate the loss tensor loss_t1.
[0058] (3) Multiply the loss tensor loss_t1 by weight and broadcast it over the last dimension.
[0059] (4) Calculate the number of masks no_mask that are 0.
[0060] (5) Finally, the weighted mean square error weight_mse is calculated. The denominator means that the larger value of the mask no_mask of 0 and 1.0 is selected as the denominator. The denominator is set in this way to avoid division by zero errors. Even if there is a zero value in no_mask, it will be replaced by 1.0 to ensure that the denominator will not be zero. The meaning of this denominator is that the more masks there are, the lower their weight. The role of the mask is to ignore the loss at the missing value, that is, only the loss at the non-zero mask position is considered during calculation, so a non-zero mask is selected; in the mask, if the number of 0s is more, it means that there are more positions to be ignored, so the larger the denominator, the lower the weight.
[0061] S422, calculating the aggregate mean square absolute error agg_mae, including: (1) The weight of the missing value part is not considered during aggregation, and the final loss value is the mean of the absolute errors between the aggregated input and the target.
[0062] ; ; Among them, agg_input is the input data ignoring the missing values of tensor input, and agg_target is the target data of tensor target ignoring the corresponding positions of missing values. Through such aggregation operations, the data can be converted into a more concise form for subsequent calculation of absolute error or other evaluation indicators.
[0063] (2) Calculate the aggregate mean square absolute error agg_mae = mean(|agg_input - agg_target|). mean() is used to calculate the average value, that is, to calculate the absolute value of the difference after calculating the tensor for each sample and calculate the average value.
[0064] It can be seen that by combining the above two loss functions and filling the positions of missing values and outliers with default values, the model can better focus on data points containing real information. The weight_mse loss function focuses on the mean square error of a single time step and allows the loss to be weighted by the weight parameter, while the agg_mae loss function aggregates the information of the entire sequence and calculates the loss by averaging the absolute errors of the entire sequence. Combining these two loss functions can comprehensively consider the characteristics of a single time step in the sequence and the overall sequence, helping the model to focus on errors at different levels at the same time, thereby more comprehensively evaluating the performance of the model.
[0065] S43. Adjust the parameters of the initial second-order cross-multivariate linear regression model according to the value of the loss function to obtain an updated initial second-order cross-multivariate linear regression model.
[0066] S44, judging whether the iteration stop condition is satisfied, if so, taking the current initial second-order cross-multivariate linear regression model as the target second-order cross-multivariate linear regression model; otherwise, returning to execute S41.
[0067] In an optional implementation, if the iteration stop condition is met, the current initial second-order cross-multivariate linear regression model is tested according to the test set to determine whether the value of the loss function during the test is less than a preset value, and if so, the current initial second-order cross-multivariate linear regression model is used as the target second-order cross-multivariate linear regression model, otherwise, return to execute S41. In this way, after the model is trained through the training set, the training result of the model is tested according to the test set.
[0068] In an optional embodiment, the conditions for stopping the iteration include reaching the maximum number of iterations or the loss function convergence, that is, the calculated value of the loss function is less than a preset value; thereby confirming that the accuracy of the model meets the requirements.
[0069] In an optional implementation manner, S4 includes: S5. Obtain personalized scenarios, and perform model transfer learning on the target second-order cross-multivariate linear regression model for the personalized scenarios. Personalized scenarios include: (1) Product cold start period, when the model performance may not be strong due to less training data. (2) Sales platform promotion period, when sales trends are different from daily sales and there will be large fluctuations, such as logistics problems. (3) Some products whose sales change patterns are different from other products.
[0070] Transfer learning includes: S51. Perform personalized data extraction based on known personalized scenarios, that is, extract a portion of data related to the personalized scenarios from the original data set to perform model transfer learning. This portion of data is hereinafter referred to as target domain data.
[0071] S52. Select a general model that has been trained on the source domain data for transfer learning, that is, for different personalized scenarios, use the corresponding target domain data to fine-tune some model parameters to generate an independent model for the personalized scenario to adapt to the characteristics and labels of the target task.
[0072] S6. Receive a prediction request, where the prediction request includes prediction data; input the prediction data into a target second-order cross-multivariate linear regression model to obtain a sales forecast value.
[0073] S7. Verify the sales forecast value according to preset verification conditions, and output the sales forecast value if it meets the preset verification conditions.
[0074] In order to avoid inaccurate predictions caused by the limitations of the model itself, or special events that occur in actual business, the output of the model usually needs to be post-processed.
[0075] First, check the abnormal results predicted by the algorithm. The abnormality detection process is as follows: The current forecast period is called the current period (the first preset time period after the current time, usually six months). For example, here we predict that June to November 2024 is the current period; May to October 2024 is the previous period; June to November 2023 is the same period last year as the current period. Commonly used abnormality detection indicators are:
[0076] The specific calculation of the formula mentioned in the above table is as follows: 1. Weighted average of actual sales in the past 4 weeks: (1) Set the number of periods n involved in weighted averaging; (2) Let this period be the mth period, and the number of this period is , then the number of the first n periods of this period is recorded as ; (3) Calculate weight ; (4) Calculate the weighted average ; 2. Perform an exponential smoothing forecast on the actual sales volume in the past four weeks. The formula for an exponential smoothing forecast is: ; In the formula, is the exponential smoothing value of the t+1 period, is the actual value of period t, is the exponential smoothing value of the tth period, is the smoothing coefficient 3. Sales volume of the same period last year * the same period last year: the formula of the same period last year is the year-on-year growth rate = (this period number - the same period last year number) / the same period last year number; 4. Sales volume of the previous period * year-on-year comparison: The formula for year-on-year comparison is month-on-month growth rate = (this period number - previous period number) / previous period number.
[0077] Please refer to Figure 2 , Embodiment 2 of the present invention is: A sales forecasting terminal 1 based on second-order cross-multivariate linear regression includes a processor 2, a memory 3, and a computer program stored in the memory 3 and executable on the processor 2. When the processor 2 executes the computer program, each step in the first embodiment is implemented.
[0078] In summary, the present invention provides a sales forecasting method and terminal based on second-order cross multiple linear regression. After obtaining historical sales data, it is divided into a training set and a test set, the tensor of the test set is calculated, and the default value is supplemented for the abnormal value or missing value in the training set; and a mask is added to the different positions of the default value and the tensor, and the mask is read in the process of optimizing the model to calculate the loss function, and the weight of the mask position in the loss function calculation process is reduced, thereby increasing the proportion of the real value in the loss function calculation process, and reducing the impact of the supplemented default value on the optimization of model parameters. Combined with field experience, the feature engineering method is comprehensively utilized to perform a combination transformation that conforms to business logic on the original variable information, reduce data set noise, and enhance the data volume and stability of the data set. At the same time, model transfer learning is performed for classifications with small data volumes or classifications with small variable information, and the model parameters are initialized using the experience learned on the original training set, thereby reducing the requirements for data volume or variable information and improving model performance. Based on business rules and professional knowledge, the output of the model is post-processed. First, statistical knowledge is used to design filtering indicators to check abnormal data in the algorithm prediction results. At the same time, business rules are designed for common business abnormal scenarios; finally, the final version of the prediction is output through manual adjustment or business rule processing. To a certain extent, the limitations of the regression model itself are overcome, and the natural advantages of the deep learning algorithm model are utilized to more efficiently provide enterprises with more accurate sales forecasting suggestions. First, business experience is combined with feature engineering methods to provide a high-quality training data set for the model. In view of the defects of the regression model itself, the nonlinear modeling ability of deep learning and the automatic learning characteristics of neural networks are used to combine with the linear regression model for prediction, which can better capture the nonlinearity and interaction between features, thereby improving the performance and prediction accuracy of the model. After training a general model, model transfer learning can also be performed for scenarios with less data volume, less variable information or other personalized scenarios to obtain targeted models. Then, through strict planning management, more accurate future features are provided to further improve the model prediction ability. Finally, the rule screening and processing algorithm is used to predict abnormal values. The above invention reduces the manual business volume and improves the limitation that manual prediction cannot consider too many influencing factors.
[0079] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A sales forecasting method based on second-order cross-multivariate linear regression, characterized in that: Includes steps: Acquire historical sales data, and divide the historical sales data into a training set and a test set; Obtaining the values to be adjusted in the training set and the default values corresponding to the values to be adjusted; Calculate the target tensor corresponding to the test set, and generate a mask at the position of the default value that is not equal to the target tensor; An initial second-order cross-multivariate linear regression model is trained according to the training set to obtain a target second-order cross-multivariate linear regression model, and the mask is ignored when calculating the loss function.
2. The sales volume forecasting method based on second-order cross multiple linear regression according to claim 1 is characterized in that: The acquisition of historical sales data includes: If the historical sales data is discrete data, the historical sales data is mapped into a continuous vector by using an Embedding method; If the historical sales data is continuous data, discretization, nonlinear change or normalization is performed on the historical sales data; If the historical sales data is text data, a pre-trained natural language processing model is used to obtain text features.
3. The sales volume forecasting method based on second-order cross multiple linear regression according to claim 1 is characterized in that: The step of training the initial second-order cross-multivariate linear regression model according to the training set to obtain the target second-order cross-multivariate linear regression model, and ignoring the mask when calculating the loss function, includes: Inputting the training data in the training set into the initial second-order cross-multivariate linear regression model to obtain predicted sales; Calculating a value of a loss function according to the predicted sales volume and the target sales volume corresponding to the training data, and ignoring the masked training data in the training set; Adjusting the parameters of the initial second-order cross-multivariate linear regression model according to the value of the loss function to obtain an updated initial second-order cross-multivariate linear regression model; Determine whether the iteration stop condition is met. If so, use the current initial second-order cross-multivariate linear regression model as the target second-order cross-multivariate linear regression model; otherwise, return to execute the step of inputting the training data in the training set into the initial second-order cross-multivariate linear regression model.
4. The sales volume forecasting method based on second-order cross multiple linear regression according to claim 3 is characterized in that: Inputting the training data in the training set into the initial second-order cross-multivariate linear regression model to obtain the predicted sales volume includes: Inputting the training data in the training set into the linear layer of the initial second-order cross-multivariate linear regression model for linear transformation to obtain a linear part; Input the training data into the cross layer of the initial second-order cross multiple linear regression model to calculate the cross part; The predicted sales volume is obtained according to the linear part and the cross part.
5. The sales volume forecasting method based on second-order cross multiple linear regression according to claim 4 is characterized in that: The step of inputting the training data in the training set into the forward propagation function of the initial second-order cross-multivariate linear regression model to perform linear transformation to obtain the linear part comprises: ; In the formula, i represents the feature, x i represents the i-th feature of the training data, w i represents the weight of feature i in the linear layer, N represents the total number of features in the training data, and lr_part represents the linear part.
6. The sales volume forecasting method based on second-order cross multiple linear regression according to claim 4 is characterized in that: The cross-layer calculation of inputting the training data into the initial second-order cross-multivariate linear regression model to obtain the cross-part includes: ; In the formula, v i v j represents the weight of the intersection of feature i and feature j at the intersection layer; x i x j represents a cross term, and cross_part represents the cross part.
7. The sales volume forecasting method based on second-order cross multiple linear regression according to claim 4 is characterized in that: The predicted sales volume obtained according to the linear part and the cross part includes: Z = lr_part + cross_part + b; In the formula, lr_part represents the linear part, cross_part represents the cross part, and b represents the bias term.
8. A sales forecasting method based on second-order cross-multivariate linear regression according to any one of claims 1 to 7, characterized in that: The calculation loss function includes: Computes the weighted sequential mean squared error and the aggregate mean squared absolute error.
9. The sales volume forecasting method based on second-order cross multiple linear regression according to claim 8, characterized in that: The calculation of the weighted sequence mean square error weight_mse includes: ; ; ; ; ; In the formula, no_mask represents the total number of mask mask_symbols with a value of 0; mask_symbol represents a mask; loss_t2 represents a loss tensor with a weight; loss_t1 represents a loss tensor, weight represents a preset weight tensor; dim=-1 represents the last dimension of the tensor; unsqueeze represents inserting a new dimension at the position of the last dimension of the weight tensor; input represents the training tensor corresponding to the data in the training set; target represents the target tensor; not_equal represents obtaining unequal positions; and mask_value represents the default value.
10. A sales forecasting terminal based on second-order cross-multivariate linear regression, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the sales forecasting method based on second-order cross multivariate linear regression described in any one of claims 1-9 is implemented.
Citation Information
Patent Citations
Link quality prediction method combining Bi-LSTM and time pattern attention
CN115297496A
Optimal matching method for power operators under asymmetric relationship
CN115375071A
Sales prediction method, system and device, and storage medium
CN116681463A
Promotion effects determination at an aggregate level
US20180365714A1
Cited By
Commodity sales volume prediction method and system
CN122529802A
A commodity sales forecasting method and system
CN122529802B