Traffic flow prediction method based on spatial division and static weighting
Through a method based on spatial division and static weighting, combined with long and short-term memory neural network model, the problem of low traffic prediction accuracy in the existing technology is solved, and efficient and accurate prediction of complex urban road networks is achieved.
Patent Information
- Application Number
- CN202411270738.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2044-09-11
AI Technical Summary
现有的交通流量预测方法在处理复杂城市路网和异常数据时预测精度较差,尤其是基于深度学习模型对低质量和异常样本敏感,难以在实际应用中实现准确预测。
Using a method based on spatial division and static weighting, by calculating the specificity and outlier metrics of traffic flow historical data, differentiated value weights are given to observation records, and predictions are made in combination with long and short-term memory neural network models.
It improves the accuracy of traffic flow prediction, reduces the negative impact of invalid data and abnormal data, and achieves low-cost and accurate traffic flow prediction.
Smart Images

Figure CN118820686B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of road traffic flow monitoring, and in particular to a traffic flow prediction method based on space division and static weighting. Background Art
[0002] Due to the high complexity of urban road networks, the strong randomness of traffic flow changes, and the large number of abnormal points in traffic data, it is very difficult to achieve accurate traffic flow prediction.
[0003] At present, the technical methods that can be used for traffic flow prediction include prediction methods based on statistics, prediction methods based on traditional machine learning models, and prediction methods based on deep learning models. However, there are some problems in all of them, which are mainly manifested in:
[0004] a) Statistical prediction methods use the statistical laws of historical traffic data to predict future traffic flow by calculating the average or weighted average of historical data, or by analyzing the laws of historical data changes over time to establish a mathematical model to predict future traffic flow. This type of method has low computational cost and simple deployment, but is sensitive to abnormal data and has poor prediction accuracy when the data distribution is complex.
[0005] b) The prediction method based on the traditional machine learning model uses a model with a small number of parameters to learn the functional mapping relationship from the observed information features to the traffic flow features or fit the change pattern of the traffic flow. Typical traditional machine learning models include linear regression models, support vector machine regression models, decision tree regression models, etc. The prediction method based on the traditional machine learning model has a low requirement for the amount of traffic flow data, but it is usually difficult to capture more complex traffic change patterns and is more sensitive to abnormal samples.
[0006] c) Prediction based on deep learning models is a type of method widely used in traffic flow prediction in recent years. It can automatically extract high-level features from data and make predictions. By building complex models such as multi-layer perceptrons, convolutional neural networks or recurrent neural networks and training them on traffic flow data, the model can learn the law of traffic flow changes and achieve predictions. Prediction methods based on deep learning models are highly dependent on the quality of training data and the effectiveness of the training process. However, since traffic flow data often has problems such as uneven sample distribution, a large number of low-quality samples and widespread abnormal samples, the prediction performance of deep learning models trained using conventional techniques is low, making it difficult to accurately predict road flow in practical applications. Summary of the invention
[0007] The purpose of the present invention is to solve the above-mentioned defects in the prior art and to provide a traffic flow prediction method based on space division and static weighting.
[0008] The purpose of the present invention can be achieved by adopting the following technical solutions:
[0009] A traffic flow prediction method based on space division and static weighting, the traffic flow prediction method comprising the following steps:
[0010] S1. Use the historical observation data of traffic flow to perform spatial division based on the characteristics of traffic observation information to form a set of data subspaces, and map the observation record data of all moments in the historical observation data of traffic flow to the corresponding data subspaces at different moments;
[0011] S2. Calculate the standard deviation of the observation information characteristics of each data subspace, count the average standard deviation of the observation information characteristics of all non-empty data subspaces, and calculate the specificity measure of the observation records at each moment in the traffic flow history data based on the observation records at all moments and the affiliation relationship of the data subspaces;
[0012] S3, calculating the standard deviation of the traffic flow characteristics of each data subspace, and calculating the outlier measure of the observation records at each moment in the traffic flow historical data according to the observation records at all moments and the affiliation relationship of the data subspace;
[0013] S4, traverse all observation records in the historical traffic flow data, calculate the value weight of the observation record at each moment according to the specificity measurement and outlier measurement of the observation record at each moment, and save the mapping relationship between the observation record index and the observation record value weight in the form of an array;
[0014] S5. Use the historical observation data of traffic flow and the value weight array of observation records at each moment to train the long short-term memory neural network model, and use the trained long short-term memory neural network model to predict traffic flow.
[0015] Furthermore, the implementation process of step S1 is as follows:
[0016] S11. For historical traffic flow observation data, define is the set of all observation record data, where Indicates Observation records, , Respectively timestamp of each observation record, feature vector of observation information, traffic flow characteristics, is the size of historical traffic flow observation data; timestamp Provides the timing information between observation records, the observation information feature vector Provides road condition information closely related to traffic flow, traffic flow characteristics For prediction target.
[0017] S12. Define the observation information feature vector ,in For the The first observation record Observation information features, , is the number of observed information features; according to the pre-set partitioning parameters The value range of each observation information feature in the data set is evenly divided into intervals, is a positive integer greater than 1, so the total data subspace; definition For the The data subspace is The interval index on the dimensional observation information feature, , define Data subspace The identification is ,in Indicates the splicing operation; pre-set partitioning parameters The value range of is generally [2, 20]. The value of controls the size of the data subspace, which in turn determines the analysis of the statistical distribution characteristics of the observation records within a controllable neighborhood.
[0018] S13. For The first observation record Dimensional observation information features , through the formula Calculate the Observation records In the The interval index on the dimensional observation information feature, For the The maximum value of the dimensional observation information feature, For the The minimum value of the observation information feature; based on the partition parameter Calculating the interval index of the observation record on each observation information feature is an operation of linear complexity, that is, the computational complexity is linearly related to the number of observation records and the number of observation feature information dimensions, so it has the advantage of high efficiency.
[0019] S14, traverse the historical observation data of traffic flow, for each observation record , through the formula calculate The data subspace Dimensional indexing and concatenation to obtain data subspace , record the observations Map to Create observation records in the identified data subspace and the data subspace A bidirectional index that maps one-to-one between All the observation records contained can be mapped. The mapping of observation records to data subspaces is implemented using an array, that is, a hash function is used to map the timestamp of the observation record to an index and the index of the data subspace is stored in the array element pointed to by the index; the mapping of the data subspace to all the observation records contained is implemented using an object list, where each object corresponds to a data subspace and stores the index of all the observation records contained. The implementation method allows the space division to be completed and a bidirectional index between the observation record and the data subspace to be established by traversing the historical observation data of traffic flow once.
[0020] Furthermore, the implementation process of step S2 is as follows:
[0021] S21. For each data subspace , , through the formula Compute data subspace The standard deviation of the observation information characteristics ,in The data subspace The number of observation records in The data subspace The average value of the observation information feature vector of all samples in represents the square of the vector's two-norm, represents the observation records in the data subspace, and Respectively represent the observation information feature vector and traffic flow characteristics of the observation record; the calculation formula of the standard deviation of the observation information feature is Able to process one-dimensional and multi-dimensional observation information features, thus accurately describing arbitrary dimensional data subspaces The similarity between the observation records in ; when there is only one-dimensional observation information feature, Represents the square of the difference between the observed information feature and the average value of the observed information feature. When there are multi-dimensional observed information features, Represents the square of the Euclidean distance between the observed information feature vector and the average value of the observed information feature vector.
[0022] S22, through the formula Calculate the average standard deviation of the multidimensional observation information characteristics of all non-empty data subspaces The average value of the standard deviation of the multidimensional observation information characteristics reflects the uniformity of the distribution of the entire traffic flow historical observation data. Excluding empty data subspaces can avoid invalid value areas of the observation information characteristics.
[0023] S23. For each data subspace , , through the formula Calculate the corresponding subspace specificity metric; for each observation record By formula calculate Specificity measure ,in is the indicator function, when the observation record Belongs to the data subspace When , it takes 1, otherwise it takes 0. The subspace specificity metric calculated in this step is assigned to all observation records in the corresponding data subspace. At the same time, the specificity metric of each observation record is only related to the data subspace in which it is located. Therefore, it is possible to measure whether each observation record has relatively special observation information characteristics with very low computational complexity.
[0024] Furthermore, the implementation process of step S3 is as follows:
[0025] S31. For each data subspace , , through the formula Compute data subspace The standard deviation of traffic flow characteristics ,in The data subspace The number of observation records in The data subspace The average value of traffic flow characteristics of all observation records in represents the square of the vector's two-norm, represents the observation records in the data subspace, and They represent the observation information feature vector and traffic flow characteristics of the observation record respectively; the standard deviation of the traffic flow characteristics in the data subspace reflects the overall situation of the deviation of the traffic flow characteristics of all observation records in a data subspace from the average value. The calculation method in this step uses the vector bi-norm to expand the definition of standard deviation in statistics, so it can adapt to the prediction of multi-dimensional traffic flow characteristics.
[0026] S32. For each observation record , , through the formula calculate Outlier measure ,in is the indicator function, is the norm algorithm parameter, Express - Norm extraction In this step, the outlier measurement of the observation record not only considers the absolute distance between the traffic flow characteristics and the average value of the traffic flow characteristics, but also considers the overall situation of the traffic flow characteristics of the observation records in the data subspace deviating from the average value, so as to scientifically quantify the risk of abnormal traffic flow characteristics of each observation record.
[0027] Furthermore, the implementation process of step S4 is as follows:
[0028] S41. For each observation record , , define the importance function , where the observation information feature vector and traffic flow characteristics Substitute the calculation result of the importance function For observation record The importance function combines the specificity metric and the outlier metric to quantify the learning value of each observation record. High-value observation records are given greater weights to improve the effectiveness of prediction model training.
[0029] S42. Traverse the historical observation data of traffic flow and use the importance function to calculate the value weight of all observation record data And in array Persistent storage in the form of The persistent storage of the value weights of all observation record data enables the use of static weighting technology to scale the gradient during the prediction model training process, avoiding the cost of secondary calculations.
[0030] Furthermore, the implementation process of step S5 is as follows:
[0031] S51. Initialize a long short-term memory neural network model , The parameters to be trained are recorded as The input of the long short-term memory neural network model is the information feature vector of the historical observation data of traffic flow, and the output of the long short-term memory neural network model is the predicted value of traffic flow; the long short-term memory neural network model can effectively extract the sequence information composed of the observation records, so as to use the observation information characteristics of multiple moments to accurately predict the traffic flow at the next moment.
[0032] S52. Randomly select a batch of observation records from the historical traffic flow observation data, including The number of records, according to the index of the batch of observation records An array of weights from the values of the observation record data Take out the corresponding element And construct the diagonal matrix , For index The value weight corresponding to the observation record; input the batch of observation records into the long short-term memory neural network model and collect the traffic flow prediction value output by it , For index The traffic flow prediction value corresponding to the observation record is calculated using the loss function Calculate the index separately Observation records about the parameters of the long short-term memory neural network model Gradient , and arranged in the form of column vectors , , For index The actual traffic flow value corresponding to the observation record is converted into a value weight diagonal matrix Left multiply gradient column vector Get the weighted gradient , for the weighted gradient Find the average , using a gradient-based optimization algorithm and weighted gradient averaging Long Short-Term Memory Neural Network Model Parameters Update; the gradient weighting method based on matrix-vector multiplication adopted in this step can effectively utilize the existing operators of the programming framework, the operator optimization of the compiler and the underlying hardware acceleration technology to achieve efficient weighted operations.
[0033] S53, repeating step S52 until the number of parameter iteration updates reaches a preset upper limit;
[0034] S54, change the historical time from 0 to Traffic observation information feature vector and the current moment Traffic observation information feature vector Input the long short-term memory neural network model in sequence , computing the long short-term memory neural network model Output , get the next moment Traffic flow prediction value In this step, the traffic observation information features of the historical moments are implicitly expressed as implicit states in the long short-term memory neural network model, so that the traffic flow prediction at the next moment can utilize rich historical information.
[0035] Furthermore, the observation information features include one or more of road flow information, average vehicle speed, average lane occupancy, congestion level, and number of parked vehicles. Each observation information feature reflects an objective factor affecting traffic flow, and this method is applicable to scenarios containing one or more observation information features.
[0036] Furthermore, the loss function is the mean square error loss function Or Huber loss function ,in is the threshold parameter. This step extends the definition of the mean square error loss function and the Huber loss function, so it can be applied to the case of one-dimensional and multi-dimensional traffic flow characteristics.
[0037] Furthermore, the Data subspace The identification is ,in Represents a splicing operation, For the The data subspace is Interval index on dimensional observation information features; data subspace A neighborhood with a definite boundary is defined, and any observation record in the neighborhood Eligible
[0038]
[0039] ,in For the The maximum value of the dimensional observation information feature, For the The minimum value of the observation information feature; the definition of data subspace can quickly determine the neighborhood of all observation records through one data traversal, with low calculation cost.
[0040] Furthermore, the long short-term memory neural network model Contains one or more hidden layers, and the parameters to be trained of the hidden layer are the parameters to be trained of the entire long short-term memory neural network model A subset of , where each hidden layer performs the following calculation: , , , , , ,in , , , Respectively The output of the input gate, forget gate, cell gate and output gate at all times. For the The cell status at the moment, For the The implicit state of the moment, is the output from the input layer or the previous hidden layer, , are the sigmoid function and the hyperbolic tangent function respectively, , , , are the input transformation parameters of the input gate, forget gate, cell gate and output gate respectively. , , , are the implicit state transformation parameters of the input gate, forget gate, cell gate and output gate respectively, , , , They are the input bias parameters of the input gate, forget gate, cell gate, and output gate, respectively. , , , are the implicit state bias parameters of the input gate, forget gate, cell gate, and output gate, respectively. Represents Hadamard product. The gating mechanism used in the hidden layer of the long short-term memory neural network model can effectively retain information of different time spans, and combined with the value weight of the observed record data, it can accurately learn the change pattern of traffic flow.
[0041] Furthermore, the long short-term memory neural network model Parameters The stochastic gradient descent algorithm or Adam algorithm is used for update, where the update rule of the stochastic gradient descent algorithm is: , is the pre-set learning rate parameter; the Adam algorithm update rule is , is the bias-corrected first-order moment estimate, is the bias-corrected second-order raw moment estimate, the biased first-order moment estimate The initial value of is 0, and the update formula is , with partial second-order moment raw estimates The initial value of is 0, and the update formula is , is the first-order moment estimate of the decay rate parameter, Estimate the decay rate parameter for the second-order moment, To achieve numerical stability parameters, , They are , The stochastic gradient descent algorithm and the Adam algorithm both update the model parameters based on the gradient. The use of the gradient weighting technology in step S52 can improve the effectiveness of these two algorithms in updating the parameters of the long short-term memory neural network model.
[0042] Compared with the prior art, the present invention has the following advantages and effects:
[0043] (1) The present invention uses a preprocessing method to complete the analysis of traffic flow data and the calculation of value weights. Combined with the long short-term memory neural network model, it can effectively improve the prediction accuracy of traffic flow and almost does not increase the time cost of model training.
[0044] (2) The present invention can quickly perform spatial division on traffic flow data and scientifically characterize the specificity and degree of outlier of each observation record in the data subspace, thereby quantifying the value of each observation record and helping the long short-term memory neural network model to accurately learn the changing pattern of traffic flow.
[0045] (3) The present invention combines traffic observation information characteristics and traffic flow characteristics to perform differentiated weighting on data, which can effectively avoid or reduce the negative impact of invalid data, low-quality data and abnormal data, reduce the prediction error of the long short-term memory neural network model on traffic flow, and achieve low-cost and accurate traffic flow prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0047] Figure 1 It is a flow chart of the implementation steps of the traffic flow prediction method based on space division and static weighting disclosed in the present invention;
[0048] Figure 2 It is a schematic diagram of training a long short-term memory neural network model using historical traffic flow observation data and value weight array. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] Example 1
[0051] This embodiment discloses a traffic flow prediction method based on spatial division and static weighting. This method divides traffic flow data into spatial partitions and quantifies the specificity and outlier degree of each observation record. It uses static weighting to assign differentiated value weights to different observation records, and combines long short-term memory neural network to achieve accurate prediction of traffic flow. Figure 1 , Figure 2 As shown in Table 1, a specific embodiment of a traffic flow prediction method based on spatial division and static weighting is used to illustrate the precise and practical method proposed in the present invention in detail.
[0052] The actual traffic flow data comes from traffic observation data records of multiple areas in the urban area of Birmingham, a British city. These records contain traffic flow feature information and specific timestamps collected by the Birmingham City Management Committee from 30 areas from 8:00 am to 16:30 pm, and the recording time interval is 30 minutes. The present invention selects traffic flow feature information of seven areas (BHMBCCMKT01, BHMBCCPST01, BHMBCCTHL01, BHMBRCBRG01, BHMBRCBRG02, BroadStreet, Bull Ring) from October 4, 2016 to December 9, 2016, of which the traffic flow characteristics of BroadStreet and Bull Ring are used as prediction targets, and the traffic flow characteristics of the other five areas are used as observation information features; the first 70% of the data records in the traffic flow data are used for spatial division and static weighting and training of long short-term memory neural network models, and the last 30% of the data records are used for testing.
[0053] like Figure 1 As shown, the traffic flow prediction method based on space division and static weighting in the present invention includes the following steps:
[0054] S1. Use the historical traffic flow data to perform spatial division based on the observation information characteristics to form a set of data subspaces, and map the observation records at all times in the data to the corresponding data subspaces. In this embodiment, step S1 is specifically as follows:
[0055] S11. Definition is the set of all observation record data, where Indicates Observation records ( ), For the The timestamp of each observation record, For the The observation information feature vector of each observation record (i.e., the vector composed of the observation information features of the five regions BHMBCCMKT01, BHMBCCPST01, BHMBCCTHL01, BHMBRCBRG01, and BHMBRCBRG02), For the The traffic flow characteristics of the target area (i.e. Broad Street and Bull Ring) recorded by observations, is the number of observation records;
[0056] S12. Observation records ( ), define its observation information feature vector ,in For the Observation records ( ) Observation information features ( ), is the number of observed information features (in this embodiment ); according to the pre-set partition parameters (In this embodiment, ) Divide the value range of each observation information feature in the data set evenly into intervals, and thus a total of data subspace; definition ( ) is the The data subspace is The interval index on the observation information feature is defined as Data subspace The identification is ,in Represents a splicing operation;
[0057] S13. For each observation record ( ) for each observation information feature ( ), through the formula Calculate observation records In the The interval index on the observation information feature, where is a pre-set partition parameter (in this embodiment, ), For the The maximum value of the observation information feature, For the The minimum value of the observed information features;
[0058] S14, traverse all observation record data, for each observation record ( ), through the formula Calculate its first Dimension Index ( ) and concatenate them to obtain , mapping the observation records to In the identified data subspace, a bidirectional index is established so that a given observation record can be mapped one by one to the subspace it is in, and a given subspace can be mapped one by one to all the observation records it contains;
[0059] S2, calculate the standard deviation of the observation information characteristics of each data subspace, count the average standard deviation of the observation information characteristics of all non-empty subspaces, and further calculate the specificity metric of each observation record in the historical data based on the affiliation between the observation record and the data subspace; in this embodiment, step S2 is specifically as follows:
[0060] S21. For each data subspace ( ), through the formula Compute data subspace The standard deviation of the observation information characteristics ,in Subspace The number of samples within The data subspace The average value of the observation information feature vector of all samples in represents the square of the vector's two-norm;
[0061] S22, through the formula Calculate the average standard deviation of the observed information characteristics of all non-empty subspaces ;
[0062] S23. For each data subspace ( ), through the formula Calculate the corresponding subspace specificity metric; for each observation record By formula Calculate its specificity metric ,in is the indicator function (when the observation record Belongs to the data subspace 1 if yes, 0 otherwise);
[0063] S3, calculating the standard deviation of the traffic flow characteristics of each data subspace, and calculating the outlier measure of each observation record in the traffic flow history data according to the membership relationship between the observation record and the data subspace; in this embodiment, step S3 is specifically as follows:
[0064] S31. For each data subspace ( ), through the formula Calculate the standard deviation of its traffic flow characteristics ,in Subspace The number of observation records in Subspace The average value of traffic flow characteristics of all observation records in the
[0065] S32. For each observation record ( ), through the formula Calculate its outlier measure ,in is the indicator function, are algorithm parameters, Express - Norm extraction In this embodiment, ;
[0066] S4, traverse all observation records in the historical traffic flow data, calculate their value weights according to their specificity metrics and outlier metrics, and save the mapping relationship between the observation record index and the observation record value weight in the form of an array; in this embodiment, step S4 is as follows:
[0067] S41. For each observation record ( ), define the importance function , where the observation information feature vector and traffic flow characteristics Substitute the calculation result of the importance function The value weights recorded for the observations;
[0068] S42. Traverse the historical traffic flow data and use the importance function to calculate the value weight of all observed record data And in array Persistent storage in the form of is the importance function;
[0069] S5. Use the historical traffic flow data and the value weight array to train a long short-term memory neural network model, and use the model to predict traffic flow, such as Figure 2 As shown, step S5 in this embodiment is specifically as follows:
[0070] S51. Initialize a long short-term memory neural network model , and its parameters to be trained are recorded as ,This embodiment uses a long short-term memory neural network model including 1 input layer, 1 hidden layer and 1 output layer. The input of the model is the observation information feature vector, and the output of the model is the predicted value of the traffic flow feature;
[0071] S52, randomly select a batch of observation records from the historical traffic flow data (the number of records is ), according to its index An array of weights from the values of the observation record data Take out the corresponding element And construct the diagonal matrix ; Input these observation records into the long short-term memory neural network model and collect the traffic flow prediction value output by it , using the Huber loss function Calculate the parameters of the long short-term memory neural network model for this batch of observation records Gradient ( ) and arranged in the form of a column vector , the value weight diagonal matrix Left multiply gradient column vector Get the weighted gradient , further weighted gradient Find the average value (the result is recorded as ), using stochastic gradient descent (SGD) and weighted gradient averaging Long Short-Term Memory Neural Network Model Parameters An update is performed, that is, ,in is the pre-set learning rate parameter;
[0072] S53, repeating step S52 until the number of parameter iteration updates reaches a preset upper limit;
[0073] S54, the observation information feature vector of the historical moment and the current moment Input the long short-term memory neural network model in sequence , calculate the final output of the model , get the predicted value of traffic flow characteristics at the next moment By predicting the traffic flow characteristics of the target area (i.e. Broad Street and Bull Ring), the results are shown in Table 1.
[0074] Table 1. Comparison of average prediction errors of different methods
[0075]
[0076] This embodiment uses the average prediction error of the vector to evaluate the prediction result:
[0077]
[0078] in is the number of records used for testing (in this embodiment =340), represents the Euclidean distance, is the predicted value of traffic flow characteristics, is the true value of traffic flow characteristics. Using the long short-term memory neural network model (LSTM) as the prediction model, the common methods using mean square error (MSE), Huber and LQR as loss functions cannot achieve an average prediction error of less than 20%. The technology based on spatial division and static weighting assigns differentiated value weights to all observation record data points, thereby improving the performance of the prediction model. In summary, from the analysis of the average prediction error results of different methods obtained in Table 1, the prediction error control of the traffic flow prediction method based on spatial division and static weighting proposed in the present invention is at least 5 percentage points lower than that of other prediction methods.
[0079] Example 2
[0080] This embodiment discloses a traffic flow prediction method based on spatial division and static weighting. This method spatially divides traffic flow data and quantifies the specificity and outlier degree of each observation record. It uses static weighting to assign differentiated value weights to different observation records, and combines long-term and short-term memory neural networks to achieve accurate prediction of traffic flow. Figure 1 , Figure 2 As shown in Table 2, a specific example of a traffic flow prediction method based on spatial division and static weighting is used to illustrate the precise and practical method proposed in the present invention in detail.
[0081] The actual traffic flow data comes from traffic flow observation data in urban areas of California. These data contain observation records collected by the Caltrans performance measurement system from 307 traffic flow monitoring points in the area, with a time span of January to February 2018, an original measurement interval of 30 seconds, and an observation record time interval of 5 minutes after aggregation. Each observation record contains timestamp, vehicle flow, average lane occupancy and average vehicle speed information. The present invention selects observation records of three adjacent traffic flow monitoring points (monitoring point #242, monitoring point #243 and monitoring point #28), and uses the current traffic flow, average lane occupancy and average vehicle speed recorded by these three monitoring points as traffic observation information features (i.e., a total of 9 observation information features) to predict the traffic flow at the next moment of monitoring point #28. The first 70% of the data records in the traffic flow data are used for spatial division and static weighting as well as the training of the long short-term memory neural network model, and the last 30% of the data records are used for testing.
[0082] like Figure 1 As shown, the traffic flow prediction method based on space division and static weighting in the present invention includes the following steps:
[0083] S1. Use the historical traffic flow data to perform spatial division based on the observation information characteristics to form a set of data subspaces, and map the observation records at all times in the data to the corresponding data subspaces. In this embodiment, step S1 is specifically as follows:
[0084] S11. Definition is the set of all observation record data, where Indicates Observation records ( ), For the The timestamp of each observation record, For the The observation information feature vector of observation records (i.e., the vector composed of 9 observation information features including the current traffic flow, average lane occupancy rate and average vehicle speed recorded at monitoring point #242, monitoring point #243 and monitoring point #28), For the Traffic flow characteristics of observation records (i.e., the traffic flow at the next moment of monitoring point #28), is the number of observation records;
[0085] S12. Observation records ( ), define its observation information feature vector ,in For the Observation records ( ) Observation information features ( ), is the number of observed information features (in this embodiment ); according to the pre-set partition parameters (In this embodiment, ) Divide the value range of each observation information feature in the data set evenly into intervals, and thus a total of data subspace; definition ( ) is the The data subspace is The interval index on the observation information feature is defined as Data subspace The identification is ,in Represents a splicing operation;
[0086] S13. For each observation record ( ) for each observation information feature ( ), through the formula Calculate observation records In the The interval index on the observation information feature, where is a pre-set partition parameter (in this embodiment, ), For the The maximum value of the observation information feature, For the The minimum value of the observed information features;
[0087] S14, refer to step S14 of embodiment 1;
[0088] S2, calculate the standard deviation of the observation information characteristics of each data subspace, count the average standard deviation of the observation information characteristics of all non-empty subspaces, and further calculate the specificity metric of each observation record in the historical data according to the affiliation relationship between the observation record and the data subspace; step S2 in this embodiment can be implemented with reference to step S2 in embodiment 1, specifically as follows:
[0089] S21, refer to step S21 of embodiment 1;
[0090] S22, refer to step S22 of embodiment 1;
[0091] S23, refer to step S23 of embodiment 1;
[0092] S3, calculating the standard deviation of the traffic flow characteristics of each data subspace, and calculating the outlier measure of each observation record in the traffic flow history data according to the membership relationship between the observation record and the data subspace; in this embodiment, step S3 is specifically as follows:
[0093] S31, refer to step S31 of embodiment 1;
[0094] S32. For each observation record ( ), through the formula Calculate its outlier measure ,in is the indicator function, are algorithm parameters, Express - Norm extraction In this embodiment, ;
[0095] S4, traverse all observation records in the historical traffic flow data, calculate their value weights according to their specificity metrics and outlier metrics, and save the mapping relationship between the observation record index and the observation record value weight in the form of an array; step S4 in this embodiment can be implemented with reference to step S4 in embodiment 1, specifically as follows:
[0096] S41, refer to step S41 of embodiment 1;
[0097] S42, refer to step S42 of embodiment 1;
[0098] S5. Use the historical traffic flow data and the value weight array to train a long short-term memory neural network model, and use the model to predict traffic flow, such as Figure 2 As shown, step S5 in this embodiment is specifically as follows:
[0099] S51. Initialize a long short-term memory neural network model , and its parameters to be trained are recorded as ,This embodiment uses a long short-term memory neural network model including 1 input layer, 2 hidden layers and 1 output layer. The input of the model is the observation information feature vector, and the output of the model is the predicted value of the traffic flow feature;
[0100] S52, randomly select a batch of observation records from the historical traffic flow data (the number of records is ), according to its index An array of weights from the values of the observation record data Take out the corresponding element And construct the diagonal matrix ; Input these observation records into the long short-term memory neural network model and collect the traffic flow prediction value output by it , using the least squares loss function Calculate the parameters of the long short-term memory neural network model for this batch of observation records Gradient ( ) and arranged in the form of a column vector , the value weight diagonal matrix Left multiply gradient column vector Get the weighted gradient , further weighted gradient Find the average value (the result is recorded as ), using the Adam algorithm and weighted gradient average Long Short-Term Memory Neural Network Model Parameters An update is performed, that is, ,in is the pre-set learning rate parameter, is the bias-corrected first-order moment estimate, is the bias-corrected second-order raw moment estimate, the biased first-order moment estimate The initial value of is 0, and the update formula is , with partial second moment raw estimate The initial value of is 0, and the update formula is , , , These are all Adam algorithm parameters;
[0101] S53, repeating step S52 until the number of parameter iteration updates reaches a preset upper limit;
[0102] S54, the observation information feature vector of the historical moment and the current moment Input the long short-term memory neural network model in sequence , calculate the final output of the model , get the predicted value of traffic flow characteristics at the next moment The results obtained by conducting experiments on the observation records of monitoring point #242, monitoring point #243 and monitoring point #28 are shown in Table 2.
[0103] Table 2. Comparison of average prediction errors of different methods
[0104]
[0105] This embodiment uses the average prediction error for the scalar to evaluate the prediction results:
[0106]
[0107] in is the number of records used for testing (in this embodiment =5097), is the predicted value of traffic flow characteristics, is the true value of the traffic flow characteristics. The linear regression method based on the traditional machine learning model, the autoregressive integrated moving average (ARIMA) method based on statistics, and the LSTM-MSE method based on the deep learning model all produce large average prediction errors due to the uneven distribution of observation record data and abnormal observation records. The technology based on spatial division and static weighting assigns differentiated value weights to all observation record data points, reduces the negative impact of abnormal observation record data, and improves the performance of the prediction model. In summary, from the analysis of the average prediction error results of different methods obtained in Table 2, the prediction error of the traffic flow prediction method based on spatial division and static weighting proposed in the present invention is controlled at 15%, which is at least 4 percentage points lower than other prediction methods.
[0108] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. A traffic flow prediction method based on spatial division and static weighting, characterized in that: The traffic flow prediction method comprises the following steps: S1. Use the historical observation data of traffic flow to perform spatial division based on the characteristics of traffic observation information to form a set of data subspaces, and map the observation record data of all moments in the historical observation data of traffic flow to the corresponding data subspaces at different moments; S2. Calculate the standard deviation of the observation information characteristics of each data subspace, count the average standard deviation of the observation information characteristics of all non-empty data subspaces, and calculate the specificity measure of the observation records at each moment in the traffic flow history data based on the observation records at all moments and the affiliation relationship of the data subspaces; S3, calculating the standard deviation of the traffic flow characteristics of each data subspace, and calculating the outlier measure of the observation records at each moment in the traffic flow historical data according to the observation records at all moments and the affiliation relationship of the data subspace; S4, traverse all observation records in the historical traffic flow data, calculate the value weight of the observation record at each moment according to the specificity measurement and outlier measurement of the observation record at each moment, and save the mapping relationship between the observation record index and the observation record value weight in the form of an array; S5. Use the historical observation data of traffic flow and the value weight array of observation records at each moment to train the long short-term memory neural network model, and use the trained long short-term memory neural network model to predict traffic flow.
2. The traffic flow prediction method based on space division and static weighting according to claim 1 is characterized in that: The implementation process of step S1 is as follows: S11. For the historical observation data of traffic flow, define T = {(t1, x1, y1), ..., (t i , x i ,y i ),...,(t n , x n ,y n )} is the set of all observed record data, where (t i , x i ,y i ) represents the i-th observation record, i = 1, 2, ..., n, t i , x i ,y i are the timestamp, observation information feature vector, and traffic flow characteristics of the i-th observation record, respectively, and n is the size of the historical observation data of traffic flow; S12. Define the observation information feature vector in is the jth observation information feature of the ith observation record, j = 1, 2, ..., m, m is the number of observation information features; the value range of each observation information feature in the data set is evenly divided into λ intervals according to the pre-set partition parameter λ, λ is a positive integer greater than 1, and a total of λ m data subspace; definition is the interval index of the k-th data subspace on the j-th dimension observation information feature, k = 1, 2, ..., λ m , define the kth data subspace D k The identification is in Indicates a splicing operation, wherein the observation information features include one or more of road flow information, average vehicle speed, average lane occupancy rate, congestion level, and number of parked vehicles; S13, for the j-th dimension observation information feature of the i-th observation record By formula Calculate the i-th observation record (t i , x i ,y i ) is the interval index on the j-th dimension observation information feature, is the maximum value of the j-th dimension observation information feature, is the minimum value of the jth observation information feature; S14, traverse the historical observation data of traffic flow, for each observation record (t i , x i ,y i ), through the formula Calculate (t i , x i ,y i ) and concatenate the j-th dimension of the data subspace to obtain the data subspace The observation record (t i , x i ,y i ) is mapped to P i In the data subspace marked with i , x i ,y i ) and the data subspace Pi in which it is located. Through this bidirectional index, a given data subspace P i All observation records contained can be mapped.
3. The traffic flow prediction method based on space division and static weighting according to claim 2 is characterized in that: The implementation process of step S2 is as follows: S21. For each data subspace D k , k = 1, 2, ..., λ m , through the formula Calculate the data subspace D k The standard deviation of the observation information characteristic σ x (D k ), where n k is the data subspace D k The number of samples within is the data subspace D k The average value of the observation information feature vector of all samples in represents the square of the vector bi-norm, (x, y) represents the observation record in the data subspace, x and y represent the observation information feature vector and traffic flow characteristics of the observation record respectively; S22, through the formula Calculate the average standard deviation of the multidimensional observation information characteristics of all non-empty data subspaces S23. For each data subspace D k , k = 1, 2, ..., λ m , through the formula The corresponding subspace specificity metric is calculated; for Each observation record (t i , x i ,y i ) through the formula Calculate (t i , x i ,y i ) is a measure of specificity μ(x) i ,y i ),in is the indicator function, when the observation record (t i , x i ,y i ) belongs to the data subspace D k It takes 1 when it is, otherwise it takes 0.
4. The traffic flow prediction method based on space division and static weighting according to claim 3 is characterized in that: The implementation process of step S3 is as follows: S31. For each data subspace D k , k = 1, 2, ..., λ m , through the formula Calculate the data subspace D k The standard deviation of traffic flow characteristics σ y (D k ), where n k is the data subspace D k The number of observation records in is the data subspace D k The average value of traffic flow characteristics of all observation records in represents the square of the vector bi-norm, (x, y) represents the observation record in the data subspace, x and y represent the observation information feature vector and traffic flow characteristics of the observation record respectively; S32, for each observation record (t i , x i ,y i ), i = 1, 2, ..., n, by the formula Calculate (t i , x i ,y i ) is an outlier measure γ(x i ,y i ),in is the indicator function, α∈{1,2} is the norm algorithm parameter, It means raising the α-norm to the power of α.
5. The traffic flow prediction method based on space division and static weighting according to claim 4 is characterized in that: The implementation process of step S4 is as follows: S41, for each observation record (t i , x i ,y i ), i = 1, 2, ..., n, define the importance function The observation information feature vector x i and traffic flow characteristics y i Substitute the calculated result of importance function ω(x i ,y i ) is the observation record (t i , x i ,y i )’s value weight; S42, traverse the historical observation data of traffic flow, and use the importance function to calculate the value weights of all observation record data ω(x1, y1), ω(x2, y2), ..., ω(x i ,y i ), ..., ω(x n ,y n ) and stored persistently in the form of an array W, where ω(·) is the importance function.
6. The traffic flow prediction method based on space division and static weighting according to claim 2 is characterized in that: The implementation process of step S5 is as follows: S51. Initialize a long short-term memory neural network model F θ , F θ The parameter to be trained is denoted as θ, the input of the LSTM neural network model is the information feature vector of the historical observation data of traffic flow, and the output of the LSTM neural network model is the predicted value of traffic flow; S52, randomly extract a batch of observation records from the historical traffic flow observation data, including b number of records, and according to the indexes i1, i2, .., i b Take the corresponding element from the value weight array W of the observed record data And construct the diagonal matrix For index i1, i2, .., i b The value weight corresponding to the observation record; input the batch of observation records into the long short-term memory neural network model and collect the traffic flow prediction value output by it For index i1, i2, .., i b The traffic flow prediction value corresponding to the observation record is calculated using the loss function Calculate the indexes i1, i2, .., i respectively b The observation record of the gradient of the long short-term memory neural network model parameter θ Arranged in the form of column vectors i v =i1,i2,..,i b , For index i1, i2, .., i b The actual value of traffic flow corresponding to the observation record is left-multiplied by the gradient column vector of the value weight diagonal matrix Ω Get the weighted gradient Weighted Gradient Find the average Using gradient-based optimization algorithms and weighted gradient averaging For the long short-term memory neural network model F θ The parameters θ are updated; wherein the loss function is the mean square error loss function Or Huber loss function S53, repeating step S52 until the number of parameter iteration updates reaches a preset upper limit; S54, sequentially inputting the traffic observation information feature vectors x(0), x(1), x(2), ..., x(t-1) at historical times 0 to t-1 and the traffic observation information feature vector x(t) at the current time t into the long short-term memory neural network model F θ In the calculation of the long short-term memory neural network model F θ Output Get the traffic flow prediction value at the next time t+1 7. The traffic flow prediction method based on space division and static weighting according to claim 2 is characterized in that: The kth data subspace D k The identification is in Represents a splicing operation, is the interval index of the k-th data subspace on the j-th dimension observation information feature; data subspace D k A neighborhood with a definite boundary is defined, and any observation record (t i , x i ,y i ) meets the conditions ,in is the maximum value of the j-th dimension observation information feature, is the minimum value of the jth observation information feature.
8. The traffic flow prediction method based on space division and static weighting according to claim 6 is characterized in that: Long short-term memory neural network model F θ It contains one or more hidden layers, and the parameters to be trained of the hidden layer are a subset of the parameters θ to be trained of the entire long short-term memory neural network model, where each hidden layer performs the following calculation: t =σ(W ii x t +b ii +W hi h t-1 +b hi ), f t =σ(W if x t +b if +W hf h t-1 +b hf ), g t =tanh(W ig x t +b ig +W hg h t-1 +b hg ), o t =σ(W io x t +b io +W h oh t-1 +b ho ), c t =f t ⊙ ct x t-1 +i t ⊙g t ,h t =o t ⊙tanh(c t ), where i t 、f t , g t , o t are the outputs of the input gate, forget gate, cell gate, and output gate at time t, respectively. t is the cell state at time t, h t-1 is the implicit state at time t-1, x t is the output from the input layer or the previous hidden layer, σ and tanh are the sigmoid function and the hyperbolic tangent function respectively, W ii , W if , W ig , W io are the input transformation parameters of the input gate, forget gate, cell gate and output gate respectively, W hi , W hf , W hg , W ho are the implicit state transformation parameters of the input gate, forget gate, cell gate and output gate, respectively, and b ii 、b if 、b ig 、b io are the input bias parameters of the input gate, forget gate, cell gate and output gate, respectively, and b hi 、b hf 、b hg 、b ho are the implicit state bias parameters of the input gate, forget gate, cell gate and output gate respectively, and ⊙ represents the Hadamard product.
9. The traffic flow prediction method based on space division and static weighting according to claim 6 is characterized in that: Long short-term memory neural network model F θ The parameter θ is updated using the stochastic gradient descent algorithm or the Adam algorithm, where the stochastic gradient descent algorithm update rule is: η is a pre-set learning rate parameter; the Adam algorithm update rule is: is the bias-corrected first-order moment estimate, is the bias-corrected second-order original moment estimate, the initial value of the biased first-order moment estimate s is 0, and the update formula is The initial value of the biased second-order moment original estimate Z is 0, and the update formula is β1 is the first-order moment estimation decay rate parameter, β2 is the second-order moment estimation decay rate parameter, and ε is the parameter for achieving numerical stability. They are the t-th power of β1 and β2 respectively.
Citation Information
Patent Citations
Controlled airspace strategic flow prediction method based on gray long-short-term memory network
CN110210648A
Method for estimating and predicting short-term traffic circulation state of urban road network
WO2021109318A1