Traffic prediction method and device, electronic equipment and storage medium
The data completion module and the prediction module are jointly trained through the joint training loss function of the prediction completion model, which solves the problems of immediacy and low accuracy of traffic prediction in data-missing scenarios, realizes the end-to-end prediction process, and improves the accuracy of the prediction results.
Patent Information
- Application Number
- CN202210723890.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-23
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2042-06-23
AI Technical Summary
Existing traffic prediction methods have poor immediacy and low prediction accuracy in data-missing scenarios. The reason is that data completion and prediction tasks fail to interact effectively, resulting in error accumulation.
A prediction completion model is adopted to jointly train the data completion module and the prediction module through a joint training loss function to realize an end-to-end prediction process. Sample data, sample missing data and sample missing position matrix are used for pre-training to enhance the capability of the data completion module and improve the prediction accuracy through information interaction.
It improves the immediacy and accuracy of traffic prediction in data-missing scenarios, realizes information interaction between the data completion module and the prediction module, reduces error accumulation, and improves the accuracy of prediction results.
Smart Images

Figure CN115238963B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular to a traffic prediction method and device, electronic equipment and storage medium. BACKGROUND
[0002] With the development of big data and artificial intelligence technology, the increasingly accumulated traffic big data and various excellent deep learning algorithms provide a realistic basis for relieving traffic congestion and improving traffic pollution. However, in real traffic scenarios, due to the difficulty in maintaining physical detection equipment, and the influence of possible accidental factors (such as data loss, errors, etc.) in the data transmission and storage process, the obtained traffic data is often of poor data quality, or there are different proportions of data missing.
[0003] Although the existing method can achieve good prediction performance in the data missing scenario, it still has the following shortcomings:
[0004] First, the existing method regards data completion as an independent task, and the traffic prediction in the data missing scenario is divided into two stages of data completion and prediction, which is poor in timeliness.
[0005] Second, there is no effective interaction between the data completion and prediction tasks, which will cause the error of data completion to further accumulate in the prediction task, and negatively affect the prediction accuracy. SUMMARY
[0006] The present application provides a traffic prediction method, device, electronic equipment and storage medium to solve the defects of poor timeliness and low prediction accuracy of traffic prediction in the traffic data missing scenario in the prior art.
[0007] The present application provides a traffic prediction method, comprising:
[0008] determining historical traffic data and a missing position matrix of the historical traffic data;
[0009] inputting the historical traffic data and the missing position matrix into a prediction completion model to obtain a prediction result output by the prediction completion model;
[0010] The prediction completion model is obtained by training the initial model based on the weight parameters of the data completion module in the initial model, using sample data, sample missing data, sample data expected values and sample missing position matrices. The weight parameters of the data completion module in the initial model are pre-trained based on the sample data, the sample missing data and the sample missing position matrix.
[0011] According to the traffic prediction method provided by the present application, the training step of the prediction completion model comprises:
[0012] determine the initial model; the initial model comprises a data completion module and a prediction module;
[0013] pre-train the data completion module based on the sample data, the sample missing data, the sample data expected value and the sample missing position matrix, to obtain a weight parameter of the data completion module;
[0014] jointly train the data completion module and the prediction module based on the weight parameter, the sample data, the sample missing data, the sample data expected value and the sample missing position matrix, to obtain the prediction completion model.
[0015] According to the traffic prediction method provided by the application, the joint training of the data completion module and the prediction module comprises:
[0016] jointly train the data completion module and the prediction module based on a joint training loss function; the joint training function is constructed based on the difference between the sample data expected value and the initial prediction result of the sample data output by the prediction module, and the difference between the sample missing data and the completion data of the sample data output by the data completion module.
[0017] According to the traffic prediction method provided by the application, the initial prediction result acquisition step comprises:
[0018] determine sample reconstruction data based on the sample data and the completion data of the sample data;
[0019] determine sample reconstruction data corresponding to each time granularity based on the sample reconstruction data and each time granularity;
[0020] determine sample fusion features based on the sample reconstruction data corresponding to each time granularity;
[0021] determine the initial prediction result based on the sample fusion features.
[0022] According to the traffic prediction method provided by the application, the determination of sample fusion features based on the sample reconstruction data corresponding to each time granularity comprises:
[0023] extract space-time features from the sample reconstruction data corresponding to each time granularity to obtain sample space-time features corresponding to each time granularity;
[0024] determine sample space-time fusion features based on the sample space-time features corresponding to each time granularity and adaptive weights;
[0025] The sample fusion feature is determined based on the sample spatiotemporal fusion feature and the external factor feature; the external factor feature includes a weather factor feature and / or a time period factor feature.
[0026] According to a traffic prediction method provided by the present invention, the data completion module is pre-trained based on the sample data, the sample missing data, the sample data expected value, and the sample missing position matrix to obtain the weight parameters of the data completion module, including:
[0027] Determining the sample data, the sample missing data, and the sample missing position matrix;
[0028] Extracting spatiotemporal features from the sample data, and completing the sample data based on the obtained spatiotemporal features corresponding to the sample data to obtain completed data corresponding to the sample data;
[0029] Based on the completion data corresponding to the sample data, the sample missing data and the sample missing position matrix, the completion module loss is determined, and based on the completion module loss, the parameters of the data completion module are iteratively updated to obtain the weight parameters of the data completion module.
[0030] According to a traffic prediction method provided by the present invention, the steps of determining the sample data, the sample missing data and the sample missing position matrix are as follows:
[0031] Determine the original traffic data;
[0032] Randomly deleting a preset proportion of traffic data from the original traffic data to obtain sample data corresponding to the preset proportion and sample missing data corresponding to the preset proportion;
[0033] Determine a sample missing position matrix corresponding to each preset proportion based on the spatiotemporal position of the original traffic data and the spatiotemporal position of the sample missing data corresponding to each preset proportion in the original traffic data;
[0034] The sample data, the sample missing data and the sample missing position matrix are determined based on the sample data corresponding to each preset proportion quantity, the sample missing data corresponding to each preset proportion quantity and the sample missing position matrix corresponding to each preset proportion quantity.
[0035] The present invention also provides a traffic prediction device, comprising:
[0036] a determination module, configured to determine historical traffic data and a missing location matrix of the historical traffic data;
[0037] a prediction module configured to input the historical traffic data and the missing position matrix into a prediction completion model to obtain a prediction result output by the prediction completion model;
[0038] The prediction completion model is obtained by training an initial model based on weight parameters of a data completion module in the initial model, sample data, sample missing data, sample data expected values, and a sample missing position matrix; and the weight parameters of the data completion module in the initial model are obtained by pre-training based on the sample data, the sample missing data, and the sample missing position matrix.
[0039] The application further provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the traffic prediction method according to any one of the above when executing the program.
[0040] The application further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and the computer program is executable on a processor to implement the traffic prediction method according to any one of the above.
[0041] The application further provides a computer program product including a computer program, and the computer program is executable on a processor to implement the traffic prediction method according to any one of the above.
[0042] The traffic prediction method, device, electronic device, and storage medium provided by the application implement an end-to-end prediction process of the prediction completion model by using a prediction completion model trained based on a data completion model to predict according to historical traffic data and obtain a prediction result, update parameters of an initial model of the prediction completion network model according to an initial prediction result output in the process of training the prediction completion model, realize information interaction between a prediction module and a data completion module in the prediction completion model, and complete end-to-end prediction, thereby improving instantaneity and improving the accuracy of the prediction result. BRIEF DESCRIPTION OF DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the present application or the prior art, the following will briefly introduce the drawings needed in the embodiments or prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.
[0044] Figure 1 is a flowchart of the traffic prediction method provided by the application;
[0045] Figure 2 is one of the flowcharts of the prediction completion model training method provided by the application;
[0046] Figure 3 is a flowchart of an initial prediction result acquisition method provided by the present application;
[0047] Figure 4 is a flowchart of a sample fusion feature acquisition method provided by the present application;
[0048] Figure 5 is a network structure diagram of a space-time feature extraction network provided by the present application;
[0049] Figure 6 is a flowchart of a prediction completion model training method provided by the present application 2;
[0050] Figure 7 is a network structure diagram of a prediction completion model provided by the present application;
[0051] Figure 8 is a structural diagram of a traffic prediction device provided by the present application;
[0052] Figure 9 is a structural diagram of an electronic device provided by the present application. DETAILED DESCRIPTION
[0053] In order to make the objectives, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are some embodiments of the present application, but not all embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0054] At present, existing data completion is mainly through classical data interpolation methods such as historical average and linear regression, or through traditional machine learning methods such as Markov Chain Monte Carlo (MCMC) and data completion methods based on deep learning. Although the existing methods can achieve good prediction performance in the data missing scene, since data completion is an independent task independent of prediction, the immediacy is poor, and since there is no interaction between data completion and prediction, the error of data completion will accumulate in prediction, thereby affecting the prediction accuracy.
[0055] Therefore, how to improve the immediacy and prediction accuracy of traffic data prediction in the data missing scene is a technical problem to be solved by those skilled in the art.
[0056] In view of the above technical problems, the embodiments of the present application provide a traffic prediction method. Figure 1FIG. 1 is a flow chart of the traffic prediction method provided by the present invention. Figure 1 As shown, the method includes:
[0057] Step 110, determining historical traffic data and a missing location matrix of the historical traffic data;
[0058] It should be noted that historical traffic data is a sequence of traffic data in a region within a time period. The traffic data may be data such as traffic flow, speed or demand. The region may be a street or multiple streets, or the city may be divided into multiple regions based on longitude and latitude. The embodiment of the present invention does not impose any restrictions on this.
[0059] In addition, historical traffic data can be complete traffic data for a time period in a region, or traffic data containing missing data for a time period in a region. This is not limited in the present embodiment. Complete traffic data means that the traffic data at each time step from the start time to the end time of the time period is not missing, where the time step represents the time interval. For example, if the time step is 1 second, then one minute of complete traffic data includes 60 data items, that is, one data item for each second. The missing position matrix of historical traffic data is constructed based on the number of complete traffic data items, and missing mark values are used to record missing data in the historical traffic data. For example, if the time step is 1 second, a missing position matrix of one minute of historical traffic data is constructed, which can be a 60x1 matrix. If the traffic data at the 15th second in the historical traffic data is missing, then the 15th index bit in the matrix is marked as 0, and the remaining bits in the matrix are marked as 1. This is not limited in the present embodiment.
[0060] Step 120: inputting the historical traffic data and the missing location matrix into the prediction and completion model to obtain a prediction result output by the prediction and completion model;
[0061] The prediction completion model is obtained by training the initial model based on the weight parameters of the data completion module in the initial model using sample data, sample missing data, sample data expected value and sample missing position matrix; the weight parameters of the data completion module in the initial model are obtained by pre-training based on sample data, sample missing data and sample missing position matrix.
[0062] The prediction process of the current traffic prediction model in the missing data scenario is mostly to first complete the missing data by a data completion model alone to obtain the completed traffic data, and then the prediction model predicts the prediction result according to the completed traffic data. The prediction process is not an end-to-end process, and the information interaction between the data completion module and the prediction module cannot be realized. Therefore, the prediction completion model needs to have the ability of information interaction between the data completion module and the prediction module to realize the end-to-end prediction process, so as to improve the instantaneity of prediction and alleviate the further accumulation of errors of the data completion result in the prediction module, thereby improving the accuracy of the prediction result. Therefore, in the embodiment of the present application, the data completion module is used to provide the data completion ability for the prediction completion model, and the joint training mechanism is designed to realize the information interaction between the data completion module and the prediction module, and the end-to-end prediction process of the prediction completion model is realized.
[0063] Specifically, the data completion module in the initial model is pre-trained according to the sample data, the sample missing data and the sample missing position matrix to obtain the weight parameters of the data completion module, so that the initial model itself has the data completion ability. On this basis, the parameters of the initial model can be iteratively updated according to the sample data, the sample missing data, the sample data expected value and the sample missing position matrix. At the same time, the parameters of the data completion module in the initial model are also updated in the process of iterative updating, so that the data completion module in the initial model is affected by the initial prediction result output by the prediction module, so that the prediction completion model has the data completion ability and the information interaction ability between the data completion module and the prediction module in the prediction completion model.
[0064] The prediction completion model obtained in this way has the end-to-end prediction process and the information interaction ability between the data completion module and the prediction module in the prediction completion model, so that the historical traffic data can be directly input into the prediction model to obtain the accurate and reliable prediction result output by the prediction model.
[0065] It should be noted that the sample data can be incomplete traffic data with different missing proportions in a region in a time period, and the sample labeled data is the missing traffic data of the sample data. The missing proportion represents the proportion of the number of missing traffic data to the complete traffic data. For example, the complete traffic data of one minute with a time step of 1 second has a missing rate of 10%, and 6 data are randomly missing in the sample data determined by the missing rate. The present application does not limit this. In addition, the sample data expected value refers to the traffic data value of the same time period in the future in the region, such as the flow value or speed value, and the present application does not limit this.
[0066] The traffic prediction method provided by the embodiment of the application trains a prediction completion model based on the weight parameters of the data completion module obtained through pre-training, predicts historical traffic data, obtains a prediction result, and updates the parameters of the initial model of the prediction completion network model according to the initial prediction result output in the training process of the prediction completion model, realizes information interaction between the prediction module and the data completion module in the prediction model, and completes end-to-end prediction, thereby improving the accuracy of the prediction result while improving the instantaneity.
[0067] Based on the above embodiment, Figure 2 is one of the flowcharts of the prediction completion model training method provided by the application. As shown in Figure 2 , the training step of the prediction model in step 120 includes:
[0068] Step 210, determining an initial model; the initial model includes a data completion module and a prediction module;
[0069] Step 220, pre-training the data completion module based on sample data, sample missing data, sample data expected value and sample missing position matrix, to obtain the weight parameters of the data completion module;
[0070] Step 230, jointly training the data completion module and the prediction module based on the weight parameters, the sample data, the sample missing data, the sample data expected value and the sample missing position matrix, to obtain a prediction completion model.
[0071] In order to enable the prediction completion model to have the data completion ability and the prediction result ability of the prediction completion model in the missing data scenario, the data completion module and the prediction module are applied to construct an initial model, and the weight parameters of the data completion module are obtained through pre-training of the data completion module.
[0072] Compared with the initial model before pre-training of the data completion module, the initial model after pre-training of the data completion module already has a certain data completion ability.
[0073] Then the weight parameters, the sample data, the sample missing data, the sample data expected value and the sample missing position matrix are applied to jointly train the data completion module and the prediction module in the initial model, to obtain a prediction completion model, that is, the parameters of the data completion module and the prediction module in the initial model are iteratively updated according to the initial prediction result output by the initial model, to obtain the prediction completion model. Here, the parameters of the data completion module will also be updated with the initial prediction result, so that the data completion module and the prediction module in the prediction completion model form the ability of information interaction.
[0074] The traffic prediction method provided by the embodiment of the application trains the data completion module and the prediction module jointly after the weight parameters of the data completion module in the initial model obtained through pre-training, so that the prediction completion model obtained through training has the data completion capability and the prediction capability, and has the information interaction capability between the data completion module and the prediction module, thereby reducing the error accumulation during training, and further improving the accuracy of the prediction result of the prediction completion model.
[0075] Based on the above embodiment, the joint training of the data completion module and the prediction module in step 220 comprises:
[0076] Based on the joint training loss function, the data completion module and the prediction module in the initial model are jointly trained; the joint training function is constructed based on the difference between the initial prediction result of the sample data output by the prediction module in the initial model and the expected value of the sample data, and the difference between the missing data of the sample and the completion data of the sample data output by the data completion module in the initial model.
[0077] Considering that information interaction needs to be formed between the data completion module and the prediction module in the prediction completion model, and considering that the gradient between the data completion module and the prediction module in the initial model is interrupted, the gradient of the data completion module cannot be transmitted to the prediction module, therefore, the data completion module and the prediction module in the initial model are jointly trained by the embodiment of the application with the minimum joint training loss as the target.
[0078] Specifically, the joint training loss function is determined based on the loss function of the data completion module and the loss function of the prediction module in the initial model, for example, it can be the weighted sum of the two, or it can be in the form of nonlinear combination, and the embodiment of the application does not limit this.
[0079] The loss function of the data completion module in the initial model is constructed with the minimum difference between the completion data of the sample data and the missing data of the sample as the target. Further, the loss of the data completion module in the initial model can be calculated by the following formula:
[0080]
[0081] In the formula, x is the missing data of the sample and is the completion data of the sample data, m is the sample missing position matrix, only the data of the position of the missing identifier in the sample missing position matrix is retained to participate in the calculation when calculating the error of data completion, and β is a hyperparameter.
[0082] The loss function of the prediction module in the initial model is constructed with the minimum difference between the initial prediction result and the expected value of the sample data as the target.
[0083] Further, the loss of the prediction module in the initial model can be calculated by the following formula:
[0084]
[0085] wherein y is the expected value of the sample data, and is the initial prediction result, and β is a hyperparameter.
[0086] Further, the joint loss can be calculated by the following formula:
[0087]
[0088] wherein are the loss values of the data completion and the prediction result respectively, λ∈[0.0,1.0] is an adjustment factor for adjusting the maximum proportion of the data completion module loss in the joint loss function, and γ is a scaling factor for adjusting the initial proportion of the data completion module loss in the joint loss function.
[0089] Based on the above embodiments, Figure 3 is a flowchart of the initial prediction result acquisition method provided by the application. As Figure 3 shown, the initial prediction result acquisition step includes:
[0090] Step 310, determining sample reconstruction data based on the sample data and the completed data of the sample data;
[0091] Specifically, according to the spatiotemporal position of the missing data in the sample data, the completed data of the sample data is inserted into the corresponding spatiotemporal position of the missing data to obtain the sample reconstruction data.
[0092] It should be noted that since the sample data comes from a complete traffic data sequence arranged in time order collected in a time step in a time period in a region, the spatiotemporal position represents the position of the traffic data in the traffic data sequence, for example, if the time step is 1 second and the time period is 1 minute, there are 60 traffic data arranged in time order in the complete traffic data sequence, and the traffic data at the spatiotemporal position 15 represents the traffic data at the index 14 in the traffic data sequence, and the index number of the sequence starts from 0.
[0093] Step 320, determining sample reconstruction data corresponding to each time granularity based on the sample reconstruction data and each time granularity;
[0094] Step 330, determining sample fusion features based on the sample reconstruction data corresponding to each time granularity;
[0095] Step 340, determining the initial prediction result based on the sample fusion features.
[0096] It is considered that if the sampling time can be changed from short to long, the prediction completion model can learn various time trend characteristics at different time scales, thereby improving the accuracy of the prediction result of the prediction completion model.
[0097] Specifically, the sample reconstruction data is reconstructed at each time granularity to obtain sample reconstruction data corresponding to each time granularity, and spatio-temporal feature extraction is performed on the sample reconstruction data corresponding to each time granularity, and the spatio-temporal features corresponding to the sample reconstruction data corresponding to each time granularity are fused to obtain sample fusion features, and finally, prediction is performed according to the sample fusion features to obtain an initial prediction result.
[0098] It should be noted that each of the time granularities is different, and the time granularities cover time intervals from small to large, for example, time granularities of minutes, hours, and days, which are not limited by the embodiments of the present application. The sample reconstruction data can be reconstructed at each time granularity, which can be represented by aggregating sample data within adjacent time granularities, for example, if the time granularity is 1 hour, the sample data within the next two hours of the time point of the current sample data is combined into the sample reconstruction data corresponding to the current sample data.
[0099] In addition, the spatio-temporal features corresponding to the sample reconstruction data corresponding to each time granularity can be weighted based on a preset weight, and can also be weighted based on an adaptive weight, wherein the weight value of the adaptive weight can be adjusted according to the loss obtained by the fusion loss function, and the embodiments of the present application are not limited thereto.
[0100] Based on the above embodiments, Figure 4 is a flowchart of the sample fusion feature acquisition method provided by the present application. As shown in Figure 4 step 330 includes:
[0101] Step 331, spatio-temporal feature extraction is performed on the sample reconstruction data corresponding to each time granularity to obtain sample spatio-temporal features corresponding to each time granularity;
[0102] Step 332, based on the sample spatio-temporal features corresponding to each time granularity and the adaptive weight, sample spatio-temporal fusion features are determined;
[0103] Step 333, based on the sample spatio-temporal fusion features and external factor features, sample fusion features are determined; the external factor features include weather factor features and / or time period factor features.
[0104] Taking into account that adaptive weights can allow the prediction module in the initial model to be adaptively adjusted according to the loss calculated by the fusion loss function, that is, the weight ratio can be adjusted by data-driven, so that the trained prediction completion model can know which time granularity corresponds to the spatiotemporal features that are more likely to affect the prediction results, thereby improving the accuracy of the prediction results.
[0105] At the same time, considering that traffic data may be affected by some external factors, for example, rainy days are more congested than sunny days, or the morning and evening rush hours are more congested, etc., the embodiment of the present invention further integrates the external factor characteristics and the sample spatiotemporal characteristics, which can further improve the accuracy of the prediction results.
[0106] Specifically, spatiotemporal features are first extracted from the sample reconstruction features corresponding to each time granularity to obtain the sample spatiotemporal features corresponding to each time granularity. The sample spatiotemporal features corresponding to each time granularity are then weighted and fused using adaptive weights to obtain sample spatiotemporal fusion features. Finally, the sample spatiotemporal fusion features are further fused with external factor features to obtain sample fusion features. External factors include weather factors and / or time period factors, which can include morning and evening rush hour periods, holiday periods, etc. External factors can also include temperature factors and wind speed factors, etc., which are not limited in the present embodiment.
[0107] It should be noted that the spatiotemporal feature extraction of the sample reconstruction features corresponding to each time granularity is performed separately according to the spatiotemporal feature extraction network corresponding to each time granularity in the prediction module, and the parameters of the spatiotemporal feature extraction network corresponding to each time granularity in the prediction module will be iteratively updated according to the loss value calculated by the fusion loss function.
[0108] Furthermore, the time granularity includes: sub-granularity, hourly granularity and daily granularity. Based on the spatiotemporal feature extraction network of the granularity in the prediction module, the spatiotemporal feature extraction is performed on the sample reconstruction data corresponding to the granularity to obtain the sample spatiotemporal feature corresponding to the granularity. Based on the spatiotemporal feature extraction network of the time granularity in the prediction module, the spatiotemporal feature extraction is performed on the sample reconstruction data corresponding to the time granularity to obtain the sample spatiotemporal feature corresponding to the time granularity Based on the spatiotemporal feature extraction network of the day granularity in the prediction module, the spatiotemporal feature extraction is performed on the sample reconstruction data corresponding to the day granularity to obtain the sample spatiotemporal feature corresponding to the day granularity. based on and as well as The adaptive weight W m 、 The adaptive weight W h and The adaptive weight W d, and the sample spatio-temporal fusion feature is obtained by fusing the formula The specific formula is as follows:
[0109]
[0110] In the formula, represents Hadamard product, W m , W h and W d Adaptively adjust in a data-driven manner.
[0111] Further, Figure 5 is the network structure diagram of the spatio-temporal feature extraction network provided by the application. As shown in Figure 5 , first, according to the spatio-temporal information in the sample data, the residual method is used to extract features from the sample data, then the extracted features are adjusted in feature dimension, and finally the adjusted features are input into the dilated causal convolution to obtain the sample spatio-temporal features corresponding to the output sample data. In the figure, BN is labeled, Conv2d, Conv2d_1 and Conv2d_2 are two-dimensional convolution layers, ReLu is an activation function, and ResBlock 1……L is a residual module unit.
[0112] The traffic prediction method provided by the embodiment of the application reconstructs the sample reconstructed data through multiple time granularities, so that the prediction completion model can learn the spatio-temporal features of multiple trends, and the external factor features are fused with the sample spatio-temporal fusion features of each time granularity, so that the prediction completion model can learn the influence of external factors on the prediction result, and the accuracy of the prediction result output by the prediction completion model is further improved.
[0113] Based on the above embodiment, step 220 includes:
[0114] Step 410, determining sample data, sample missing data and sample missing position matrix;
[0115] It should be noted that the sample data can be represented as sample traffic data under different data missing ratios, the sample missing data and the missing sample traffic data in the corresponding sample data, and the sample missing position matrix can be used to mark the spatio-temporal position corresponding to the missing sample traffic data of the corresponding sample data, wherein the sample missing data can be used as the label of the corresponding sample data for final loss calculation.
[0116] Step 420, spatio-temporal feature extraction is performed on the sample data, and based on the obtained sample spatio-temporal features corresponding to the sample data, the sample data is completed to obtain the completion data corresponding to the sample data;
[0117] At step 430, based on the completion data corresponding to the sample data, the sample missing data and the sample missing position matrix, the completion module loss is determined, based on the completion module loss, the parameters of the data completion module are iteratively updated to obtain the weight parameters of the data completion module.
[0118] Specifically, the sample data is subjected to spatio-temporal feature extraction to obtain sample spatio-temporal features corresponding to the sample data, and the sample spatio-temporal features corresponding to the sample data are obtained by a convolution layer with an activation layer to obtain an initial completion result. The completion network loss function is used to calculate the completion module loss based on the initial completion result, the sample missing data and the sample missing position matrix, and the parameters of the data completion module are iteratively updated through the completion module loss until the training is completed, and the weight parameters of the data completion module are obtained. Further, the completion network loss function is:
[0119]
[0120] In the formula, x is the sample missing data and is the completion data of the sample data, m is the sample missing position matrix, only the data of the position with the missing identifier in the sample missing position matrix is retained for calculation when calculating the error of data completion, and β is a hyperparameter.
[0121] Based on the above embodiment, the sample data, sample labeled data and missing position matrix determination steps are as follows:
[0122] At step 510, the original traffic data is determined.
[0123] It should be noted that the original traffic data can be represented as a complete traffic data sequence sorted by time in a region within a time period. Among them, the traffic data in the traffic data sequence is data subjected to standardization preprocessing. Further, the standardization preprocessing is processed based on the following formula:
[0124]
[0125] In the formula, x' is the traffic data before standardization, x max , x min are the maximum value and minimum value of the corresponding traffic data in the traffic data sequence respectively, x' is the traffic data after standardization, and based on the missing position encoding matrix M, the positions with data missing in x' are filled with -1.
[0126] At step 520, a predetermined proportion of traffic data is randomly deleted from the original traffic data to obtain sample data corresponding to each predetermined proportion and sample missing data corresponding to each predetermined proportion.
[0127] In step 530, based on the spatio-temporal positions of the original traffic data and the spatio-temporal positions of the sample missing data corresponding to each preset proportion in the original traffic data, a sample missing position matrix corresponding to each preset proportion is determined.
[0128] In step 540, based on the sample data corresponding to each preset proportion, the sample missing data corresponding to each preset proportion, and the sample missing position matrix corresponding to each preset proportion, the sample data, the sample missing data, and the sample missing position matrix are determined.
[0129] Specifically, according to each preset proportion, the traffic data corresponding to the preset proportion is randomly deleted from the original traffic data. At this time, the deleted traffic data from the original traffic data is the sample missing data corresponding to the preset proportion, and the traffic data not deleted from the original traffic data is the sample data corresponding to the preset proportion. Then, according to the spatio-temporal positions of the original traffic data and the spatio-temporal positions of the sample missing data corresponding to each preset proportion in the original traffic data, a sample missing position matrix corresponding to each preset proportion is determined. Finally, according to the sample data corresponding to each preset proportion, the sample missing data corresponding to each preset proportion, and the sample missing position matrix corresponding to each preset proportion, the sample data, the sample missing data, and the sample missing position matrix used for data completion model training and prediction completion model training are determined.
[0130] It should be noted that, according to the spatio-temporal positions of the original traffic data and the spatio-temporal positions of the sample missing data corresponding to each preset proportion in the original traffic data, the sample missing position matrix corresponding to each preset proportion can be determined. Specifically, based on the spatio-temporal positions of the original traffic data, an initial missing position matrix is determined. Based on the spatio-temporal positions of the sample missing data corresponding to each preset proportion in the original traffic data, the index positions corresponding to the initial missing position matrix are marked as missing, to obtain a sample missing position matrix corresponding to each preset proportion. Further, each element in the initial missing position matrix is 1, and the element of the index position corresponding to the missing data in the sample missing position matrix is marked as 0.
[0131] Further, the traffic data is randomly deleted in the original traffic data with different preset proportions of 10%, 20%, 30%, 40%, and 50%, to obtain sample data and sample missing data corresponding to different preset proportions of 10%, 20%, 30%, 40%, and 50%.
[0132] Figure 6 FIG. 2 is a flowchart of a prediction completion model training method provided by the present application. Figure 7 FIG. 3 is a network structure diagram of a prediction completion model provided by the present application. As shown in FIG. 3, the training method comprises the following steps. Figure 6 and Figure 7 The training method comprises the following steps.
[0133] Step 610, according to the original collected traffic data, the original traffic data is aggregated in time sequence and standardized.
[0134] Step 620, the original traffic data is constructed with missing data, specifically:
[0135] Randomly delete 10%, 20%, 30%, 40%, and 50% different preset proportion of data in the original traffic data to obtain sample data and sample missing data corresponding to 10%, 20%, 30%, 40%, and 50% different preset proportion, and construct the corresponding sample missing position matrix through the sample data and sample missing data corresponding to 10%, 20%, 30%, 40%, and 50% different preset proportion.
[0136] Step 630, according to the sample data, sample missing data and sample missing position matrix corresponding to 10%, 20%, 30%, 40%, and 50% different preset proportion, the data completion model is pre-trained, and the model parameters of the trained data completion model, i.e. the weight parameter W pre and the bias parameter b pre , are transplanted into the data completion module of the initial model.
[0137] Step 640, reconstruct the sample data and the completed data of the sample data output by the data completion module of the initial model to obtain sample reconstruction data, and the specific reconstruction formula is:
[0138] X * =X·M+X im ·M re
[0139] In the formula, X and X im respectively represent the original data with missing data and the completed data, M is the sample missing position matrix, which is a 0-1 binary adjacency matrix, M re is the corresponding inverse code matrix, and X * is the reconstruction result of the completed data.
[0140] Step 650, apply the multi-trend of granularity, time granularity and day granularity to reconstruct the result obtained by reconstruction to obtain sample reconstruction data corresponding to each time granularity;
[0141] Step 660, apply the corresponding space-time feature extraction network in the prediction module in the initial model to each time granularity corresponding sample reconstruction data respectively to obtain sample space-time features corresponding to each time granularity. Among them, the sample space-time features corresponding to the granularity The spatio-temporal feature extraction network based on the time granularity in the prediction module extracts the spatio-temporal features of the sample data corresponding to the time granularity, to obtain the sample spatio-temporal features corresponding to the time granularity
[0142] Step 670, the sample spatio-temporals corresponding to each time granularity are adaptively weighted and fused to obtain sample spatio-temporal fusion features The specific formula is:
[0143]
[0144] In the formula, represents Hadamard product, W m , W h and W d are adaptively adjusted in a data-driven manner.
[0145] Step 680, the sample spatio-temporal fusion features and external factor features are spliced to obtain sample fusion features, and the specific formula for splicing is In the formula, the external factor features are obtained by first One-hot encoding the external factors and inputting them into a feature embedding network, and the specific formula is: the external factors corresponding to different time steps in the sample data are input into the feature embedding network for encoding, and the specific steps are: the weather, holiday, temperature, wind speed data and time coding are input into the environmental feature embedding network, and the formula is:
[0146] X ef = Relu (WX e +b)
[0147] In the formula, X e represents external factors, X ef represents the extracted external factor features, W represents a preset weight, b represents a preset offset, and Relu is an activation function, and the formula is:
[0148]
[0149] In the formula, alpha is a hyperparameter.
[0150] Step 690, the sample fusion features are subjected to multi-step regression data to obtain a preliminary prediction result, a loss is calculated according to the preliminary prediction result and an expected value of the sample data, and the parameters of the initial model are iteratively updated based on the calculated loss to obtain a prediction completion model.
[0151] The traffic prediction device provided by the application will be described below, and the traffic prediction device described below can be correspondingly referred to the traffic prediction method described above.
[0152] Figure 8 is a structural schematic diagram of the traffic prediction device provided by the application. As Figure 8As shown, the apparatus comprises a determination module 810 and a prediction module 820.
[0153] wherein,
[0154] The determination module 810 is configured to determine historical traffic data and a missing position matrix of the historical traffic data.
[0155] The prediction module 820 is configured to input the historical traffic data and the missing position matrix into a prediction completion model to obtain a prediction result output by the prediction completion model.
[0156] The prediction completion model is obtained by training an initial model based on weight parameters of a data completion module in the initial model, using sample data, sample missing data, sample data expected values, and a sample missing position matrix. The weight parameters of the data completion module in the initial model are pre-trained based on the sample data, the sample missing data, and the sample missing position matrix.
[0157] In the embodiments of the present application, the determination module is configured to determine historical traffic data and a missing position matrix of the historical traffic data. The prediction module is configured to input the historical traffic data and the missing position matrix into a prediction completion model to obtain a prediction result output by the prediction completion model. The prediction completion model is obtained by training an initial model based on weight parameters of a data completion module in the initial model, using sample data, sample missing data, sample data expected values, and a sample missing position matrix. The weight parameters of the data completion module in the initial model are pre-trained based on the sample data, the sample missing data, and the sample missing position matrix. In the process of training the prediction completion model, the parameters of the initial model of the prediction completion network model are updated according to the initial prediction result output, realizing information interaction between the prediction module and the data completion module in the prediction model, completing end-to-end prediction, improving instantaneity, and improving the accuracy of the prediction result.
[0158] Based on the above embodiments, the traffic prediction apparatus further comprises a prediction completion model training module, which comprises:
[0159] An initial model determination sub-module is configured to determine an initial model. The initial model comprises a data completion module and a prediction module.
[0160] A completion module pre-training sub-module is configured to pre-train the data completion module based on sample data, sample missing data, sample data expected values, and a sample missing position matrix to obtain weight parameters of the data completion module.
[0161] The initial model training submodule is configured to jointly train the data completion module and the prediction module based on the weight parameters, the sample data, the sample missing data, the sample data expected value, and the sample missing position matrix to obtain a prediction completion model.
[0162] According to any one of the above embodiments, the initial model training submodule comprises:
[0163] The joint loss calculation submodule is configured to jointly train the data completion module and the prediction module based on a joint training loss function. The joint training function is constructed based on the difference between the sample data expected value and the initial prediction result of the sample data output by the prediction module, and the difference between the sample missing data and the completion data of the sample data output by the data completion module.
[0164] According to any one of the above embodiments, the initial prediction submodule comprises:
[0165] The reconstructed data determination submodule is configured to determine sample reconstructed data based on the sample data and the completion data of the sample data.
[0166] The multi-time granularity reconstructed data determination submodule is configured to determine sample reconstructed data corresponding to each time granularity based on the sample reconstructed data and each time granularity.
[0167] The feature fusion submodule is configured to determine sample fusion features based on the sample reconstructed data corresponding to each time granularity.
[0168] The prediction submodule is configured to determine an initial prediction result based on the sample fusion features.
[0169] According to any one of the above embodiments, the feature fusion submodule comprises:
[0170] The spatio-temporal feature extraction submodule is configured to perform spatio-temporal feature extraction on the sample reconstructed data corresponding to each time granularity to obtain sample spatio-temporal features corresponding to each time granularity.
[0171] The spatio-temporal feature fusion submodule is configured to determine sample spatio-temporal fusion features based on the sample spatio-temporal features corresponding to each time granularity and adaptive weights.
[0172] The external factor splicing submodule is configured to determine sample fusion features based on the sample spatio-temporal fusion features and external factor features. The external factor features include weather factor features and / or time period factor features.
[0173] According to any one of the above embodiments, the completion module pre-training submodule comprises:
[0174] The sample information determination submodule is configured to determine the sample data, the sample missing data, and the sample missing position matrix.
[0175] The data completion acquisition submodule is configured to perform space-time feature extraction on the sample data, and perform data completion on the sample data based on the obtained sample space-time feature corresponding to the sample data, to obtain the completion data corresponding to the sample data.
[0176] The model training submodule is configured to determine a completion module loss based on the completion data, the missing data and the missing position matrix corresponding to the sample data, and iteratively update parameters of the data completion module based on the completion module loss, to obtain the weight parameters of the data completion module.
[0177] According to any one of the above embodiments, the sample information determination submodule comprises:
[0178] The original data determination submodule is configured to determine the original traffic data.
[0179] Each proportion sample information determination submodule is configured to randomly delete a number of traffic data of each preset proportion from the original traffic data, to obtain sample data corresponding to each preset proportion and missing data corresponding to each preset proportion.
[0180] Each proportion sample matrix determination submodule is configured to determine a missing position matrix corresponding to each preset proportion based on the space-time position of the original traffic data and the space-time position of the missing data corresponding to each preset proportion in the original traffic data.
[0181] The sample information and matrix determination submodule is configured to determine the sample data, the missing data and the missing position matrix based on the sample data corresponding to each preset proportion, the missing data corresponding to each preset proportion and the missing position matrix corresponding to each preset proportion.
[0182] Figure 9 An example of an entity structure diagram of an electronic device is shown in FIG. 1. Figure 9As shown, the electronic device can include a processor 910, a communications interface 920, a memory 930, and a communications bus 940, wherein the processor 910, the communications interface 920, and the memory 930 complete mutual communication through the communications bus 940. The processor 910 can invoke a logical instruction in the memory 930 to execute a traffic prediction method, the method comprising: determining historical traffic data and a missing position matrix of the historical traffic data; inputting the historical traffic data and the missing position matrix into a prediction completion model to obtain a prediction result output by the prediction completion model; the prediction completion model is trained based on weight parameters of a data completion module in an initial model, and the weight parameters of the data completion module in the initial model are pre-trained based on sample data, sample missing data, and a sample missing position matrix.
[0183] In addition, the logical instructions in the memory 930 described above can be implemented in the form of a software function unit and sold or used as an independent product, and can be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a plurality of instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the embodiments of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
[0184] In another aspect, the present application also provides a computer program product comprising a computer program, which can be stored on a non-transitory computer readable storage medium, and the computer program can be executed by a processor to enable a computer to perform the traffic prediction method provided by the above-mentioned methods, which comprises: determining historical traffic data and a missing position matrix of the historical traffic data; inputting the historical traffic data and the missing position matrix into a prediction completion model to obtain a prediction result output by the prediction completion model; the prediction completion model is trained based on weight parameters of a data completion module in an initial model, sample data, sample missing data, sample data expected values and a sample missing position matrix, and the weight parameters of the data completion module in the initial model are pre-trained based on the sample data, the sample missing data and the sample missing position matrix.
[0185] In another aspect, the present application also provides a non-transitory computer readable storage medium having a computer program stored thereon, and the computer program can be executed by a processor to implement the traffic prediction method provided by the above-mentioned methods, which comprises: determining historical traffic data and a missing position matrix of the historical traffic data; inputting the historical traffic data and the missing position matrix into a prediction completion model to obtain a prediction result output by the prediction completion model; the prediction completion model is trained based on weight parameters of a data completion module in an initial model, sample data, sample missing data, sample data expected values and a sample missing position matrix, and the weight parameters of the data completion module in the initial model are pre-trained based on the sample data, the sample missing data and the sample missing position matrix.
[0186] The device embodiments described above are only schematic, wherein the units illustrated as separate components can or can not be physically separate, and the components illustrated as units can or can not be physical units, i.e., can be located in one place or distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the present embodiment. Those skilled in the art can understand and implement it without creative labor.
[0187] Those skilled in the art can clearly understand the technical solutions of the various embodiments from the above description of the embodiments, and the various embodiments can be implemented by means of software with the necessary general hardware platforms, and of course, can also be implemented by hardware. Based on such understanding, the above technical solutions, essentially or in other words, the part of the prior art that makes a contribution, can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, and the like, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0188] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for some technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A traffic flow prediction method, characterized in that: include: determining historical traffic flow data and a missing location matrix for the historical traffic flow data; Inputting the historical traffic flow data and the missing position matrix into a prediction and completion model to obtain a prediction result output by the prediction and completion model; The prediction completion model is obtained by training the initial model using sample data, sample missing data, sample data expected value and sample missing position matrix based on the weight parameters of the data completion module in the initial model; The weight parameters of the data completion module in the initial model are obtained by pre-training based on the sample data, the sample missing data and the sample missing position matrix; The training steps of the prediction and completion model include: Determine the initial model; the initial model includes a data completion module and a prediction module; Pre-training the data completion module based on the sample data, the sample missing data, the sample data expected value, and the sample missing position matrix to obtain weight parameters of the data completion module; Based on the weight parameters, the sample data, the sample missing data, the sample data expected value and the sample missing position matrix, the data completion module and the prediction module are jointly trained to obtain the prediction completion model; The jointly training the data completion module and the prediction module includes: The data completion module and the prediction module are jointly trained based on a joint training loss function; the joint training loss function is constructed based on the difference between the expected value of the sample data and the initial prediction result of the sample data output by the prediction module, and the difference between the missing sample data and the completed data of the sample data output by the data completion module; The step of obtaining the initial prediction result includes: Determining sample reconstruction data based on the sample data and the complementary data of the sample data; Determining, based on the sample reconstruction data and each time granularity, the sample reconstruction data corresponding to each time granularity; Determining sample fusion features based on the sample reconstruction data corresponding to each time granularity; Determining the initial prediction result based on the sample fusion features; The determining of the sample fusion feature based on the sample reconstruction data corresponding to each time granularity includes: Extracting spatiotemporal features of the sample reconstruction data corresponding to each time granularity to obtain the spatiotemporal features of the samples corresponding to each time granularity; Determining the sample spatiotemporal fusion features based on the sample spatiotemporal features and adaptive weights corresponding to each time granularity; The sample fusion feature is determined based on the sample spatiotemporal fusion feature and the external factor feature; the external factor feature includes a weather factor feature and / or a time period factor feature.
2. The traffic flow prediction method according to claim 1, characterized in that: The pre-training of the data completion module based on the sample data, the sample missing data, the sample data expected value and the sample missing position matrix to obtain the weight parameters of the data completion module includes: Determining the sample data, the sample missing data, and the sample missing position matrix; Extracting spatiotemporal features from the sample data, and completing the sample data based on the obtained spatiotemporal features corresponding to the sample data to obtain completed data corresponding to the sample data; Based on the completion data corresponding to the sample data, the sample missing data and the sample missing position matrix, the completion module loss is determined, and based on the completion module loss, the parameters of the data completion module are iteratively updated to obtain the weight parameters of the data completion module.
3. The traffic flow prediction method according to claim 2, characterized in that: The steps of determining the sample data, the sample missing data and the sample missing position matrix are as follows: Determine the original traffic flow data; Randomly deleting a preset proportion of traffic flow data from the original traffic flow data to obtain sample data corresponding to the preset proportion and sample missing data corresponding to the preset proportion; Determine a sample missing position matrix corresponding to each preset proportion based on the spatiotemporal position of the original traffic flow data and the spatiotemporal position of the sample missing data corresponding to each preset proportion in the original traffic flow data; The sample data, the sample missing data and the sample missing position matrix are determined based on the sample data corresponding to each preset proportion quantity, the sample missing data corresponding to each preset proportion quantity and the sample missing position matrix corresponding to each preset proportion quantity.
4. A traffic flow prediction device, characterized in that: include: a determination module, configured to determine historical traffic flow data and a missing location matrix of the historical traffic flow data; A prediction module, configured to input the historical traffic flow data and the missing position matrix into a prediction and completion model to obtain a prediction result output by the prediction and completion model; The prediction completion model is obtained by training the initial model using sample data, sample missing data, sample data expected value and sample missing position matrix based on the weight parameters of the data completion module in the initial model; The weight parameters of the data completion module in the initial model are obtained by pre-training based on the sample data, the sample missing data and the sample missing position matrix; It also includes a prediction and completion model training module, which includes: The initial model determination submodule is used to determine the initial model; the initial model includes a data completion module and a prediction module; The completion module pre-training submodule is used to pre-train the data completion module based on sample data, sample missing data, sample data expected value and sample missing position matrix to obtain the weight parameters of the data completion module; The initial model training submodule is used to jointly train the data completion module and the prediction module based on weight parameters, sample data, sample missing data, sample data expected value and sample missing position matrix to obtain the prediction completion model; The initial model training submodule is specifically used for: The data completion module and the prediction module are jointly trained based on a joint training loss function. The joint training function is constructed based on the difference between the expected value of the sample data and the initial prediction result of the sample data output by the prediction module, as well as the difference between the missing sample data and the completed data of the sample data output by the data completion module. The initial model training submodule includes: A reconstruction data determination submodule, configured to determine sample reconstruction data based on the sample data and the complementary data of the sample data; A multi-time granularity reconstruction data determination submodule is used to determine the sample reconstruction data corresponding to each time granularity based on the sample reconstruction data and each time granularity; The feature fusion submodule is used to reconstruct data based on samples corresponding to each time granularity and determine the sample fusion features; The prediction submodule is used to determine the initial prediction result based on the sample fusion features; The feature fusion submodule is specifically used for: Extracting spatiotemporal features of the sample reconstruction data corresponding to each time granularity to obtain the spatiotemporal features of the samples corresponding to each time granularity; Determining the sample spatiotemporal fusion features based on the sample spatiotemporal features and adaptive weights corresponding to each time granularity; The sample fusion feature is determined based on the sample spatiotemporal fusion feature and the external factor feature; the external factor feature includes a weather factor feature and / or a time period factor feature.
5. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the traffic flow prediction method according to any one of claims 1 to 3 is implemented.
6. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the traffic flow prediction method according to any one of claims 1 to 3 is implemented.