Goods quantity prediction method and device
By acquiring and analyzing the sequence types of historical time-series data, employing sliding window tests and significance tests, and combining variable selection networks and transformer structures, a loss function is constructed. This solves the accuracy problems of mean migration and random fluctuations in cargo volume forecasting, achieving more accurate cargo volume forecasting.
Patent Information
- Application Number
- CN202411745887.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-04
AI Technical Summary
Existing technologies struggle to distinguish between mean shift and random fluctuations in cargo volume forecasting, leading to inaccurate predictions. This is especially true in scenarios involving both mean shift and random fluctuations, where existing models struggle to effectively process semantic information and extract deep-level features.
By acquiring historical time-series data and category information for multiple categories, the sequence type at each time point is determined. Sliding window test and significance test are used to sample and train the cargo volume prediction model. The model is then used for prediction with variable selection network and transformer structure, and a loss function based on quantile parameters is constructed.
It improves the accuracy of cargo volume forecasting, enables effective forecasting in scenarios involving mean shift and random fluctuations, balances sample distribution, fully utilizes semantic information, and enhances the model's forecasting accuracy.
Smart Images

Figure CN119557649A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a cargo volume forecasting method and device. Background Art
[0002] In the field of e-commerce logistics, cargo volume forecasting is the basis for subsequent management and decision-making. However, when forecasting cargo volume, it is difficult to distinguish between mean shift and abnormal fluctuation, resulting in inaccurate forecast results.
[0003] In the related technologies, the prediction of mean shift scenarios mainly includes time series models, machine learning models and deep learning models. However, the above models are difficult to effectively process the characteristics of mean shift and random fluctuation samples, and it is difficult to effectively process semantic information, which limits the model's ability to understand complex scenarios and advance deep features. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a cargo volume forecasting method and device, which can effectively forecast cargo volume in scenarios with mean shift and random fluctuations, thereby improving the accuracy of cargo volume forecasting.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for training a cargo volume prediction model is provided, comprising:
[0006] Obtaining historical time series data and category information corresponding to each of a plurality of categories; the historical time series data includes the volume of goods at each of a plurality of time points;
[0007] For each category, determining the occurrence of the sequence type at each time point in the historical time series data corresponding to the category;
[0008] Sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data to obtain batch samples corresponding to the category; each batch sample includes multiple time series samples, and each time series sample includes multiple time points and their corresponding cargo quantities;
[0009] A cargo volume prediction model is trained based on the batch samples and category information corresponding to each category in the multiple categories.
[0010] Optionally, determining the occurrence of a sequence type at each time point in the historical time series data corresponding to the category includes:
[0011] Perform a sliding test on the mean and random fluctuation of the cargo volume in each time period of the historical time series data according to the sliding window parameters to obtain the test result at each time point;
[0012] When the test result indicates that the sequence does not undergo mean shift, the sequence type at the time point is mean shift;
[0013] When the test result indicates that the sequence has undergone mean shift, it is determined whether the cargo volume at the time point meets the preset conditions. If so, the sequence type at the time point is a regular sequence; if not, the type at the time point is a random fluctuation.
[0014] Optionally, before sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data, the method further includes:
[0015] Calculate the similarity results between any two categories based on the historical time series data corresponding to each category;
[0016] The similar results are checked for significance of differences. When the check results indicate significant differences, the cargo volume prediction models corresponding to each category are trained respectively.
[0017] Optionally, sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data to obtain batch samples corresponding to the category includes:
[0018] Calculate the frequency of occurrence of any sequence type in the historical time series data;
[0019] Calculate the sampling frequencies of different sequence types according to a preset rule and the occurrence frequency of any sequence type;
[0020] Determine the weights of time points corresponding to different sequence types according to the sampling frequencies of different sequence types;
[0021] The historical time series data is sampled according to the weights of the time points corresponding to the different sequence types to obtain batch samples corresponding to the categories.
[0022] Optionally, training a cargo volume prediction model according to the batch samples and category information corresponding to each category in the multiple categories includes:
[0023] Extracting category features from the category information, and encoding the category features to obtain an encoding vector;
[0024] Inputting the encoding vector and the cargo volume at each time point in the batch sample and the predicted time point into a variable selection network to obtain a variable selection feature;
[0025] Inputting the variable selection feature and the encoding vector into a transformer structure to obtain the predicted cargo volume at the predicted time point;
[0026] The cargo volume prediction model is obtained by training according to the predicted cargo volume and the actual cargo volume at the predicted time point in combination with the constructed loss function;
[0027] The loss function is constructed based on a quantile parameter, which is calculated based on the number of mean-shifted data points and the number of randomly fluctuated data points.
[0028] Another aspect of an embodiment of the present invention provides a cargo volume prediction method, comprising:
[0029] Obtain historical time series data and target category information corresponding to the target time point in the target category;
[0030] Inputting the historical time series data and target category information into a cargo volume forecasting model to obtain the cargo volume corresponding to the target time point;
[0031] The cargo volume prediction model is obtained by training according to the cargo volume prediction model training method of an embodiment of the present invention.
[0032] In another aspect of the embodiments of the present invention, a training device for a cargo volume prediction model is provided, comprising:
[0033] A first acquisition module acquires historical time series data and category information corresponding to each of a plurality of categories; the historical time series data includes the cargo volume at each of a plurality of time points;
[0034] A determination module, for each category, determines the occurrence of a sequence type at each time point in the historical time series data corresponding to the category;
[0035] A sampling module, sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data, to obtain a batch sample corresponding to the category; each batch sample includes multiple time series samples, and each time series sample includes multiple time points and their corresponding cargo quantities;
[0036] The training module trains a cargo volume prediction model according to the batch samples and category information corresponding to each category in the multiple categories.
[0037] Another aspect of the embodiments of the present invention provides a cargo volume prediction model, including:
[0038] The second acquisition module acquires historical time series data and target category information corresponding to the target time point in the target category;
[0039] A prediction module, inputting the historical time series data and target category information into a cargo volume prediction model corresponding to the target category to obtain the cargo volume corresponding to the target time point;
[0040] The cargo volume prediction model is obtained by training according to the cargo volume prediction model training method of an embodiment of the present invention.
[0041] According to another aspect of an embodiment of the present invention, there is provided an electronic device, including:
[0042] one or more processors;
[0043] a storage device for storing one or more programs,
[0044] When the one or more programs are executed by the one or more processors, the one or more processors implement the cargo volume prediction model training method or cargo volume prediction method provided by the present invention.
[0045] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the training method of the cargo volume prediction model or the cargo volume prediction method provided by the present invention is implemented.
[0046] One embodiment of the above invention has the following advantages or beneficial effects: the training method of the cargo volume prediction model provided by the embodiment of the present invention first obtains the historical time series data and category information corresponding to each category in multiple categories, then determines the occurrence of the sequence type at each time point in the historical time series data corresponding to each list, and then samples the historical time series data according to the occurrence of the sequence type at each time point, and uses the sampled batch samples and category information to train the cargo volume prediction model. The cargo volume prediction model obtained by this method can perform effective cargo volume prediction in scenarios with mean shift and random fluctuations; samples are taken according to the sequence type at each time point in the historical time series data to balance the sample distribution, so that the model pays more attention to key change points during the learning process; and the category information is integrated into the time series prediction, so that the model makes full use of the rich semantic information and improves the prediction accuracy of the model.
[0047] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0049] Figure 1 is a schematic diagram of the main process of a method for training a cargo volume prediction model according to an embodiment of the present invention;
[0050] Figure 2 is a structural schematic diagram of a cargo volume prediction model according to an embodiment of the present invention;
[0051] Figure 3 is a schematic diagram of the main process of a cargo volume prediction method according to an embodiment of the present invention;
[0052] Figure 4is a schematic diagram of main modules of a training device for a cargo volume prediction model according to an embodiment of the present invention;
[0053] Figure 5 is a schematic diagram of main modules of a cargo volume prediction device according to an embodiment of the present invention;
[0054] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0055] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0056] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0057] In the cargo volume forecasting in the logistics field, when the cargo volume on a certain day suddenly increases, the problem that needs to be solved is whether the forecast for subsequent dates should refer to the latest day or the average of the historical cargo volume. The cargo volume of a certain route increases on a certain day and continues to increase, which is called the mean shift state (level_shift); while some are relatively large random fluctuations, which are usually outside the 0.95 quantile of the historical fluctuation distribution, but the cargo volume returns to the normal level the next day. This is called abnormal fluctuation or random fluctuation. When forecasting, the daily sequence of the forecast object is stable, and suddenly the cargo volume increases on a certain day. At this time, it is difficult to accurately distinguish whether the forecast object is mean shift or abnormal fluctuation, resulting in inaccurate forecast results.
[0058] At present, the models used by existing technologies in predicting mean shift scenarios are mainly divided into three categories: time series models, machine learning models, and deep learning models. Time series models include classic trend tests and second-order exponential smoothing. These models can simply learn trend changes and statistical learning in time series to predict future cargo volumes. Machine learning models include xgboost, etc. These models use feature engineering and training models to achieve the judgment and prediction of whether the cargo volume is mean shift. Deep learning models such as RNN, LSTM, and GRU, by constructing neural network structures, further capture long-term dependencies in time series data in addition to short-term dependencies. Existing technologies do not perform well in mean shift scenarios.
[0059] However, time series models tend to rely on recent results for predictions, and lack sufficient attention to long-term patterns in historical data; and because time series models have a simple structure and usually only focus on their own historical data, the number of samples with mean shifts and random fluctuations is relatively small, and it is difficult for time series models to learn effective characteristics and patterns from them. Although machine learning and deep learning methods can perform horizontal comparisons between sequences, they ignore the importance of sample weights when dealing with specific samples such as mean shifts and random fluctuations, resulting in the inability to correctly identify and reflect the importance of these key samples to the prediction results. In addition, the above methods are difficult to effectively process semantic information that contains rich context and implicit semantic associations, which limits the ability of prediction models to understand complex scenarios and extract deep features.
[0060] Based on the above technical problems, an embodiment of the present invention provides a training method for a cargo volume prediction model. The cargo volume prediction model obtained based on the training method can more accurately predict the cargo volume in mean migration and random fluctuation scenarios.
[0061] Figure 1 is a schematic diagram of the main process of a method for training a cargo volume prediction model according to an embodiment of the present invention, such as Figure 1 As shown, the training method comprises the following steps:
[0062] Step S101: Acquire historical time series data and category information corresponding to each of a plurality of categories; the historical time series data includes the quantity of goods at each of a plurality of time points;
[0063] Step S102: for each category, determining the occurrence of the sequence type at each time point in the historical time series data corresponding to the category;
[0064] Step S103: Sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data to obtain batch samples corresponding to the category; each batch sample includes multiple time series samples, and each time series sample includes multiple time points and their corresponding cargo quantities;
[0065] Step S104: training a cargo volume prediction model according to the batch samples and category information corresponding to each category in the multiple categories.
[0066] In an embodiment of the present invention, firstly, multiple categories and historical time series data and category information corresponding to each category are obtained. The multiple categories can be multiple different logistics routes. The historical time series data corresponding to each category can be the cargo volume data at each time point in multiple time points of each logistics route. The multiple time points can be continuous time points. For example, the historical time series data corresponding to each category can be the cargo volume data of each logistics route every day in the past year. The category information of each category can include the site name corresponding to the logistics route, the regional information to which the logistics route belongs, etc.
[0067] In the embodiment of the present invention, after obtaining the cargo volume at each time point corresponding to each category, determining the occurrence of the sequence type at each time point in the historical time series data corresponding to the category includes:
[0068] According to the sliding window parameters, the sliding test of the cargo volume mean and random fluctuation in each time period in the historical time series data is performed to obtain the test results at each time point;
[0069] When the test result indicates that the sequence has not undergone mean shift, the sequence type of the time point is mean shift;
[0070] When the test result indicates that the mean shift of the sequence occurs, determine whether the cargo volume at the time point meets the preset conditions. If so, the sequence type of the time point is a regular sequence; if not, the type of the time point is a random fluctuation.
[0071] In an embodiment of the present invention, for each category, the historical time series data corresponding to the category is identified and labeled, and the occurrence of the sequence type at each time point can be obtained based on the cargo volume at each time point in the historical time series data. The cargo volume at each time point can be used as each data point, that is, the sequence type of each data point is identified, wherein the sequence categories may include mean shift, regular sequence, and random fluctuation.
[0072] Specifically, Chow Test can be used to perform sliding tests on different time periods in historical time series data through the set sliding window parameters. The sliding window parameters can be customized, such as being set to 7 days before and after, that is, performing a sliding test based on the cargo volume 7 days before and after each time point. The null hypothesis is that "the sequence has not undergone mean shift", and the test result for each time point is obtained, that is, the test p-value. When the test p-value rejects the null hypothesis, that is, the test result indicates that mean shift has occurred, the sequence type of the time point is mean shift, for example, the time point or data point can be marked as 1, indicating that mean shift has occurred. If the null hypothesis is not rejected, that is, the test result indicates that the sequence has not undergone mean shift, then determine whether the cargo volume at this time point meets the preset conditions, where the preset conditions can be customized, such as being set to a value that the difference between the cargo volume at this time point and the mean of the previous and next 7 days does not exceed the 0.9 quantile of the historical fluctuation distribution quantile. If so, the sequence type at this time point is a regular sequence, such as marking the time point or data point as 0, representing a regular sequence. Otherwise, the sequence type at this time point is a random fluctuation, such as marking the time point or data point as -1, representing a large random fluctuation.
[0073] In an embodiment of the present invention, after obtaining the occurrence of the sequence type at each time point in the historical time series data of each category, the historical time series data is sampled according to the occurrence of the sequence type at each time point in the historical time series data, so as to obtain a cargo volume prediction model through training based on the sampled batch samples. In order to improve the accuracy of the cargo volume prediction model, it is required to predetermine whether multiple categories are to be trained with the same cargo volume prediction model or to train corresponding cargo volume prediction models for each category, or to group multiple categories and train corresponding cargo volume prediction models using each category in the same group. Therefore, before sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data, it also includes:
[0074] Calculate the similarity results between any two categories based on the historical time series data corresponding to each category;
[0075] A significance check is performed on similar results. If the check results indicate significant differences, the cargo volume prediction model corresponding to each category is trained separately.
[0076] In an embodiment of the present invention, the similarity results between any two categories, i.e., the similarity of the cargo quantity sequences, can be calculated using DTW (Dynamic Time Warping) algorithm based on the cargo quantity at each time point in the historical time series data of each category, and the significance of the difference can be checked. If the difference is significant, a model is created for each category separately, i.e., by analyzing the correlation between the cargo quantities of different categories, the scope of classification modeling can be determined.
[0077] In an embodiment of the present invention, it is also possible to obtain the area corresponding to each category, obtain multiple categories from each area, calculate the similarity of the cargo volume between any two areas based on the historical time series data of the multiple categories in each area, and perform a significance check on the difference. If the difference is significant, a cargo volume prediction model is established for each area.
[0078] In an embodiment of the present invention, historical time series data is sampled according to the occurrence of sequence types at each time point in the historical time series data to obtain batch samples corresponding to the category, including: calculating the occurrence frequency of any sequence type in the historical time series data; calculating the sampling frequencies of different sequence types according to preset rules and the occurrence frequency of any sequence type; determining the weights of time points corresponding to different sequence types according to the sampling frequencies of different sequence types; sampling the historical time series data according to the weights of time points corresponding to different sequence types to obtain batch samples corresponding to the category.
[0079] In an embodiment of the present invention, sampling strategies with different weights can be adopted for samples of different sequence types to achieve sampling inclination towards samples with sequence types of mean migration or random fluctuations, oversampling of sequence types of mean migration and random fluctuations, and undersampling of conventional sequences, i.e., sequence types with overall stable data distribution, so as to improve the prediction accuracy of the cargo volume prediction model.
[0080] Specifically, taking modeling for each category as an example, for each category of historical time series data, first, the frequency of occurrence of any sequence type can be calculated, such as the frequency of occurrence of mean shift. The frequency of occurrence can be the proportion of the number of occurrences to the total data volume. The sampling frequency of each sequence type is calculated according to the frequency of occurrence and preset rules. For example, for the data points of mean shift (level_shift), the sampling frequency is set to 0.5*x+0.17 (close to the threshold of 0.33), the sampling frequency of random fluctuations can be the same as the sampling frequency of mean shift, and the sampling frequency of regular data points is 1-(level_shift sampling frequency + random fluctuation sampling frequency).
[0081] Then, the weight of the time point corresponding to each sequence type is obtained according to the sampling frequency of each sequence type. For example, the sampling frequency of each sequence type can be used as the weight of the time point of the sequence type. Then, the historical time series data is sampled according to the weight of each time point, thereby improving the sampling probability of mean shift and random fluctuation, so that the data points in the obtained batch samples include approximately equal numbers of samples of different sequence types, thereby improving the prediction accuracy of the cargo volume prediction model obtained using the batch samples.
[0082] Each batch sample includes multiple time series samples, and each time series sample includes multiple times and their corresponding cargo volumes. For example, the multiple time series samples may be the cargo volume of each day from the 1st to the 7th day, the cargo volume of each day from the 2nd to the 8th day, and the cargo volume of each day from the 3rd to the 9th day. For example, the cargo volume of the 7th day can be predicted using the cargo volume of the 1st to the 6th day as historical time series data, and the cargo volume of the 7th day is historical real data.
[0083] In an embodiment of the present invention, a cargo volume prediction model is trained based on batch samples and category information corresponding to each category in a plurality of categories, including: extracting category features from the category information, encoding the category features, and obtaining a coding vector; inputting the coding vector and the cargo volume at each time point in the batch samples and the predicted time point into a variable selection network to obtain a variable selection feature; inputting the variable selection feature and the coding vector into a transformer structure to obtain a predicted cargo volume at the predicted time point; training a cargo volume prediction model based on the predicted cargo volume and the actual cargo volume at the predicted time point in combination with a constructed loss function;
[0084] Among them, the loss function is constructed based on the quantile parameter, which is calculated based on the number of mean-shifted data points and the number of randomly fluctuating data points.
[0085] In an embodiment of the present invention, one or more batch samples can be sampled for each category, and then model prediction is performed using the multiple batch samples of multiple categories and the category information of each category to obtain a cargo volume prediction model, which can be a model based on a transform structure.
[0086] like Figure 2 As shown in the figure, static metadata is static information, which can be category information, such as the name of the route from the starting point to the end point and other sequence-related attributes; Past Inputs are batch samples, such as the cargo volume data of each day in the past, and Known Future Inputs can include data such as future months, weeks, dates, etc., and can also include causal relationship data, such as upstream operation data.
[0087] Then, the variable selection network is used to extract the category features from the category information, and the category features are encoded to obtain the encoding vector, that is, the category information is embedded. The variable selection network is used to process the cargo volume at each time point in the batch sample, the predicted time point and the encoding vector to obtain the variable selection feature. Specifically, the variable selection network includes multiple GRN networks. First, the GRN network can be applied separately to each feature for feature extraction, and then the extracted features are connected in series. The GRN network is used again on the series-connected features, and the weights are calculated by softmax. The weighted summation of each feature is obtained according to the weight to obtain the variable selection feature. In order to optimize the calculation speed, the layers with the most intermediate parameters are directly added and processed. Although some information will be lost, it can reduce a lot of calculations compared with the current popular methods. At the same time, the semantic information after embedding is selected and compressed by the variable selection network, which effectively utilizes the semantic information and reduces noise.
[0088] After obtaining the variable selection features, the variable selection features and the encoding vector are input into the transformer structure. First, the variable selection features are input into the GRU, and the GRU is used for decoding and decoding. The long-term and short-term relationships in the time series data are learned through the GRU. In the encoding stage, the variable selection features are input into the GRU encoder and decoder. In the attention stage, the multi-head attention layer is introduced to enable the model to search and identify the similarity between each predicted time point and the mean shift and random fluctuation points in the historical data in a global scope, and the Mask mask is used to ensure that each time dimension can only pay attention to the previous information when calculating the attention to avoid information leakage. In the network, the GLU operation is used extensively on the output of the GRU encoder and decoder to perform further feature selection to remove redundant information; then the Add&Norm operation is performed to improve the training speed and performance of the model; finally, after the GRN layer processing, the encoding vector is further used for guidance to enhance the time characteristics. GRN is used to perform additional nonlinear processing on these outputs, and finally the prediction results of the model are output to obtain the predicted cargo volume at the predicted time point. According to the predicted cargo volume and the actual cargo volume at the predicted time point, combined with the constructed loss function, the cargo volume prediction model is trained.
[0089] The loss function is constructed based on the quantile parameter, which can be calculated using the formula shown in formula (1):
[0090] q = level_shift number / (level_shift number + random fluctuation number), formula (1), the constructed loss function is shown in formula (2),
[0091]
[0092] Where q represents the quantile parameter, Ω is the time series sample set in the batch sample, M is the number of time series samples, W is the model parameter, Q is the quantile set, y is the true value at the predicted time point, and yt is the true value at time point t. is the predicted value at the predicted time point, and τ represents the length of the prediction time window.
[0093] The embodiment of the present invention uses the same training data to train multiple models, and uses the trained models to predict the cargo volume on dates marked as mean migration and random fluctuations in the logistics route, and calculates the prediction accuracy of each model. The models include holt-winter, xgboost, lstm, TFT and cargo volume prediction models.
[0094] Table 1
[0095] Model Prediction accuracy Holt-winter 0.2304 xgboost 0.5417 LSTM 0.5120 TFT 0.6873 Cargo volume forecasting model 0.7473
[0096] It can be seen from Table 1 that the cargo volume prediction model of the embodiment of the present invention can effectively predict the cargo volume in mean shift and random fluctuation scenarios, and has a higher prediction accuracy than other models.
[0097] The training method of the cargo volume prediction model provided by the embodiment of the present invention first obtains the historical time series data and category information corresponding to each category in multiple categories, then determines the occurrence of the sequence type at each time point in the historical time series data corresponding to each list, and then samples the historical time series data according to the occurrence of the sequence type at each time point, and uses the sampled batch samples and category information to train the cargo volume prediction model. The cargo volume prediction model obtained by this method can perform effective cargo volume prediction in the scenario where mean shift and random fluctuation exist; samples are taken according to the sequence type at each time point in the historical time series data to balance the sample distribution so that the model pays more attention to key change points during the learning process; integrates category information into the time series prediction so that the model makes full use of rich semantic information and improves the prediction accuracy of the model; constructs the quantile of the loss function based on mean shift and random fluctuation to achieve more accurate prediction in the mean shift scenario.
[0098] Another aspect of the embodiment of the present invention is as follows Figure 3 As shown, a cargo volume forecasting method is provided, comprising:
[0099] Step S301: Acquire historical time series data and target category information corresponding to a target time point in a target category;
[0100] Step S302: inputting historical time series data and target category information into a cargo volume forecasting model to obtain the cargo volume corresponding to the target time point;
[0101] The cargo volume prediction model is trained according to the cargo volume prediction model training method of the embodiment of the present invention.
[0102] In an embodiment of the present invention, after the cargo volume prediction model is obtained by training according to the training method of the cargo volume prediction model, the cargo volume prediction model can be used to predict the cargo volume at a future time point. First, the historical time series data corresponding to the target time point in the target category is obtained, and the historical time series data includes multiple historical time points and the historical cargo volume at each historical time point. For example, the cargo volume on the 8th day or the cargo volume for each day in the next 7 days can be predicted based on the cargo volume of each day in the past 7 days; then the cargo volume prediction model corresponding to the target category is obtained, and the historical time series data and the category information of the target category are input into the cargo volume prediction model to obtain the cargo volume at the target time point.
[0103] The cargo volume prediction method of the embodiment of the present invention first obtains the historical time series data and target category information corresponding to the target time point in the target category, and then uses the trained cargo volume prediction model to perform prediction based on the historical time series data and the target category information to obtain the cargo volume data at the target time point. The cargo volume prediction method is implemented based on the cargo volume prediction model, and performs effective cargo volume prediction in the presence of mean value Aunt Qin and random fluctuations, which can improve the accuracy of cargo volume prediction.
[0104] In another aspect of the embodiment of the present invention, Figure 4 As shown, a training device 400 for a cargo volume prediction model is provided, comprising:
[0105] The first acquisition module 401 acquires historical time series data and category information corresponding to each of the multiple categories; the historical time series data includes the cargo volume at each of the multiple time points;
[0106] Determination module 402, for each category, determines the occurrence of the sequence type at each time point in the historical time series data corresponding to the category;
[0107] The sampling module 403 samples the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data to obtain batch samples corresponding to the category; each batch sample includes multiple time series samples, and each time series sample includes multiple time points and their corresponding cargo quantities;
[0108] The training module 404 trains a cargo volume prediction model according to the batch samples and category information corresponding to each category in the multiple categories.
[0109] In the embodiment of the present invention, the determination module 402 is further used to: perform a sliding test of the mean value and random fluctuation of the cargo volume in each time period in the historical time series data according to the sliding window parameter, and obtain the test result at each time point;
[0110] When the test result indicates that the sequence has not undergone mean shift, the sequence type of the time point is mean shift;
[0111] When the test result indicates that the mean shift of the sequence occurs, determine whether the cargo volume at the time point meets the preset conditions. If so, the sequence type of the time point is a regular sequence; if not, the type of the time point is a random fluctuation.
[0112] In the embodiment of the present invention, the sampling module 403 is further used to: before sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data,
[0113] Calculate the similarity results between any two categories based on the historical time series data corresponding to each category;
[0114] A significance check is performed on similar results. If the check results indicate significant differences, the cargo volume prediction model corresponding to each category is trained separately.
[0115] In the embodiment of the present invention, the sampling module 403 is further used to: calculate the occurrence frequency of any sequence type in the historical time series data;
[0116] Calculate the sampling frequencies of different sequence types according to preset rules and the occurrence frequency of any sequence type;
[0117] Determine the weights of time points corresponding to different sequence types according to the sampling frequencies of different sequence types;
[0118] The historical time series data is sampled according to the weights of the time points corresponding to different sequence types to obtain batch samples corresponding to the categories.
[0119] In the embodiment of the present invention, the training module 404 is further used to: extract category features from the category information, and encode the category features to obtain a coding vector;
[0120] Input the encoding vector and the cargo volume at each time point in the batch sample and the predicted time point into the variable selection network to obtain the variable selection feature;
[0121] Input the variable selection features and encoding vector into the transformer structure to obtain the predicted cargo volume at the predicted time point;
[0122] Based on the predicted cargo volume and the actual cargo volume at the predicted time point, combined with the constructed loss function, the cargo volume prediction model is trained;
[0123] Among them, the loss function is constructed based on the quantile parameter, which is calculated based on the number of mean-shifted data points and the number of randomly fluctuating data points.
[0124] In another aspect of the embodiment of the present invention, Figure 5 As shown, a cargo volume prediction model 500 is provided, including:
[0125] The second acquisition module 501 acquires historical time series data and target category information corresponding to the target time point in the target category;
[0126] The prediction module 502 inputs the historical time series data and the target category information into the cargo volume prediction model corresponding to the target category to obtain the cargo volume corresponding to the target time point;
[0127] The cargo volume prediction model is trained according to the cargo volume prediction model training method of the embodiment of the present invention.
[0128] According to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the training method of the cargo volume prediction model or the cargo volume prediction method provided by the present invention.
[0129] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the training method of the cargo volume prediction model or the cargo volume prediction method provided by the present invention is implemented.
[0130] Figure 6 A training method for a cargo volume prediction model or a training device for a cargo volume prediction model according to an embodiment of the present invention, as well as an exemplary system architecture 600 of the cargo volume prediction method or the cargo volume prediction model are shown.
[0131] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, 603, network 604 and server 605. Network 604 is used to provide a medium for communication links between terminal devices 601, 602, 603 and server 605. Network 604 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0132] Users can use terminal devices 601, 602, and 603 to interact with server 605 through network 604 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 601, 602, and 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0133] The terminal devices 601 , 602 , and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.
[0134] The server 605 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
[0135] It should be noted that the cargo volume prediction model training method or cargo volume prediction method provided in the embodiments of the present invention is generally executed by the server 605 , and accordingly, the cargo volume prediction model training device or cargo volume prediction device is generally arranged in the server 605 .
[0136] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0137] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0138] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0139] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0140] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0141] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0142] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0143] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be provided in a processor, for example, may be described as: a processor including a first acquisition module, a determination module, a sampling module, and a training module. The names of these modules do not, in some cases, constitute limitations on the modules themselves, for example, the first acquisition module may also be described as a "module for acquiring historical time series data and category information for each of a plurality of categories".
[0144] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining historical time series data and category information corresponding to each category in multiple categories; the historical time series data includes the cargo volume at each time point in multiple time points; for each category, determining the occurrence of the sequence type at each time point in the historical time series data corresponding to the category; sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data to obtain batch samples corresponding to the category; each batch sample includes multiple time series samples, and each time series sample includes multiple time points and their corresponding cargo volumes; according to the batch samples and category information corresponding to each category in the multiple categories, training a cargo volume prediction model.
[0145] According to the technical solution of the embodiment of the present invention, the training method of the cargo volume prediction model provided by the embodiment of the present invention first obtains the historical time series data and category information corresponding to each category in multiple categories, then determines the occurrence of the sequence type at each time point in the historical time series data corresponding to each list, and then samples the historical time series data according to the occurrence of the sequence type at each time point, and uses the sampled batch samples and category information to train to obtain the cargo volume prediction model. The cargo volume prediction model obtained by this method can perform effective cargo volume prediction in scenarios with mean shift and random fluctuations; samples are taken according to the sequence type at each time point in the historical time series data to balance the sample distribution so that the model pays more attention to key change points during the learning process; the category information is integrated into the time series prediction so that the model makes full use of the rich semantic information and improves the prediction accuracy of the model; the quantile of the loss function is constructed based on mean shift and random fluctuations to achieve more accurate predictions in mean shift scenarios.
[0146] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for training a cargo volume prediction model, characterized in that: include: Obtaining historical time series data and category information corresponding to each of a plurality of categories; the historical time series data includes the volume of goods at each of a plurality of time points; For each category, determining the occurrence of the sequence type at each time point in the historical time series data corresponding to the category; Sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data to obtain batch samples corresponding to the category; each batch sample includes multiple time series samples, and each time series sample includes multiple time points and their corresponding cargo quantities; A cargo volume prediction model is trained based on the batch samples and category information corresponding to each category in the multiple categories.
2. The method according to claim 1, characterized in that: Determine the occurrence of the sequence type at each time point in the historical time series data corresponding to the category, including: Perform a sliding test on the mean and random fluctuation of the cargo volume in each time period of the historical time series data according to the sliding window parameters to obtain the test result at each time point; When the test result indicates that the sequence has a mean shift, the sequence type at the time point is a mean shift; When the test result indicates that the sequence has not undergone mean shift, it is determined whether the cargo volume at the time point meets the preset conditions. If so, the sequence type at the time point is a regular sequence; if not, the type at the time point is a random fluctuation.
3. The method according to claim 1, characterized in that Before sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data, the method further includes: Calculate the similarity results between any two categories based on the historical time series data corresponding to each category; The similar results are checked for significance of differences. When the check results indicate significant differences, the cargo volume prediction models corresponding to each category are trained respectively.
4. The method according to claim 1, characterized in that Sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data to obtain batch samples corresponding to the category includes: Calculate the frequency of occurrence of any sequence type in the historical time series data; Calculate the sampling frequencies of different sequence types according to a preset rule and the occurrence frequency of any sequence type; Determine the weights of time points corresponding to different sequence types according to the sampling frequencies of different sequence types; The historical time series data is sampled according to the weights of the time points corresponding to the different sequence types to obtain batch samples corresponding to the categories.
5. The method according to claim 1, characterized in that: According to the batch samples and category information corresponding to each category in the multiple categories, a cargo volume prediction model is trained, including: Extracting category features from the category information, and encoding the category features to obtain an encoding vector; Inputting the encoding vector and the cargo volume at each time point in the batch sample and the predicted time point into a variable selection network to obtain a variable selection feature; Inputting the variable selection feature and the encoding vector into a transformer structure to obtain the predicted cargo volume at the predicted time point; The cargo volume prediction model is obtained by training according to the predicted cargo volume and the actual cargo volume at the predicted time point in combination with the constructed loss function; The loss function is constructed based on a quantile parameter, which is calculated based on the number of mean-shifted data points and the number of randomly fluctuated data points.
6. A cargo volume forecasting method, characterized in that: include: Obtain historical time series data and target category information corresponding to the target time point in the target category; Inputting the historical time series data and the target category information into a cargo volume prediction model to obtain the cargo volume corresponding to the target time point; Wherein, the cargo volume prediction model is trained according to any one of the methods described in claims 1-5.
7. A training device for a cargo volume prediction model, characterized in that: include: A first acquisition module acquires historical time series data and category information corresponding to each of a plurality of categories; the historical time series data includes the cargo volume at each of a plurality of time points; A determination module, for each category, determines the occurrence of a sequence type at each time point in the historical time series data corresponding to the category; A sampling module, sampling the historical time series data according to the occurrence of the sequence type at each time point in the historical time series data, to obtain a batch sample corresponding to the category; each batch sample includes multiple time series samples, and each time series sample includes multiple time points and their corresponding cargo quantities; The training module trains a cargo volume prediction model according to the batch samples and category information corresponding to each category in the multiple categories.
8. A cargo volume forecasting model, characterized in that: include: The second acquisition module acquires historical time series data and target category information corresponding to the target time point in the target category; A prediction module, inputting the historical time series data and target category information into a cargo volume prediction model corresponding to the target category to obtain the cargo volume corresponding to the target time point; Wherein, the cargo volume prediction model is trained according to any one of the methods described in claims 1-5.
9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.