A traffic flow probability prediction method, system, device and medium
By extracting the space and time embedded characteristics in the historical data of traffic flow, and using the time and space door map network and conditions to be returned to the flow, the probability distribution of traffic flow is predicted to solve the limitations and accuracy of traffic flow forecasting in existing technologies It has achieved more reliable and high accuracy of traffic flow forecasts.
Patent Information
- Application Number
- CN202411287766.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-09-14
AI Technical Summary
The existing traffic flow prediction method can only predict one flow value for each location in the future time, and cannot obtain the overall situation in the future. It lacks consideration of random factors such as weather and holidays and the spatial relationship between urban locations, resulting in prediction accuracy and adaptability. Poor.
The use of traffic flow probability prediction method is used to extract space embedded characteristics and time embedded characteristics based on the historical data of traffic flow in various locations of the predicted area to build initial space -time characteristics. Then use the pre -trained space -time door diagram network to extract time correlation and space correlation.
This method can output the probability distribution of traffic flow at each location and time, help the traffic management department understand the possible traffic conditions and potential abnormal conditions, and make traffic decisions in advance to improve the reliability and accuracy of the prediction results.
Smart Images

Figure CN118800076B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of intelligent transportation technology, and in particular relates to a traffic flow probability prediction method, system, equipment and medium. Background Art
[0002] Traffic flow prediction is the main research content of smart transportation. It collects and analyzes the traffic volume of urban roads in the past, captures the changing trend of urban traffic flow, and predicts future traffic changes, which is conducive to the transportation department to make decisions in advance and ensure urban traffic safety.
[0003] At present, researchers have proposed many traffic flow prediction methods based on deep learning, analyzing the changing trends of traffic flow from the perspective of time and space to obtain relatively accurate prediction results. However, there are still some problems with the current traffic flow prediction methods: most traffic flow prediction models are decision-making models, which can only predict a flow value at each location in the future, but cannot obtain the overall situation in the future based on a flow value, and cannot provide uncertainty in the prediction results. At the same time, urban traffic flow will be affected by random factors such as weather and holidays, causing traffic flow to suddenly rise or fall abnormally, and the decision-making model cannot intuitively express this abnormal situation; currently some traffic flow prediction models use spatiotemporal embeddings to represent spatiotemporal indication information, but these embeddings are randomly initialized and trained by neural networks, and do not contain the spatiotemporal information of the city itself, such as the location relationship of urban locations and traffic patterns at different times of the day.
[0004] At the same time, the spatial relationship of urban locations is different at different times. For example, the relationship between residential areas and work areas is relatively large in the morning, and a lot of traffic flows from work areas to commercial areas in the evening. At the same time, the time relationship is different in different locations. The traffic relationship at peak hours on the main roads is close, but the traffic in the suburbs is relatively stable and the correlation is not great. Therefore, in local time and space, the time and space relationship of the city is different and dynamic, and the existing traffic flow prediction methods do not take the above problems into account. Summary of the invention
[0005] The present invention provides a traffic flow probability prediction method, system, device and medium to solve the problem that the prior art can only predict a traffic flow value at each location in the future time and cannot obtain the overall situation in the future, and lacks consideration of the fact that urban traffic flow will be affected by random factors such as weather and holidays and the spatial relationship between urban locations, resulting in poor accuracy and adaptability of traffic flow prediction.
[0006] In order to solve the above technical problems, the embodiments of the present invention provide the following technical solutions:
[0007] An embodiment of the present invention provides a traffic flow probability prediction method, comprising:
[0008] Based on the historical traffic flow data of each location in the area to be predicted within a preset time period and the future time period to be predicted, spatial embedding features and temporal embedding features are extracted respectively; based on the spatial embedding features and temporal embedding features, initial spatiotemporal features are constructed;
[0009] Based on the initial spatiotemporal features, a pre-trained spatiotemporal gate graph network is used to extract temporal correlation and spatial correlation; based on the obtained temporal correlation and spatial correlation, a spatiotemporal conditional feature is obtained through a temporal attention mechanism; wherein the spatiotemporal gate graph network specifically performs the following processing: extracting local and global correlations in the temporal and spatial dimensions respectively, adjusting the local correlation using the global correlation as a gate, and obtaining the temporal and spatial correlations through a graph convolutional network based on the global correlation and the local correlation;
[0010] Based on the spatiotemporal condition characteristics, the traffic flow probability of each location in the future time period of the area to be predicted is obtained through conditional normalization flow.
[0011] Furthermore, the extraction of the time embedding feature is specifically as follows:
[0012] Based on the historical traffic flow data, the important timestamps of working days and weekends are determined according to preset rules; wherein the important timestamps include the time corresponding to the maximum flow value on working days or weekends, several times when the flow changes rapidly, and the time corresponding to the extreme point of the flow change curve;
[0013] For a certain moment, the sum of the embedding features within the week, the embedding features within the day, and the embedding of the traffic mode corresponding to the important timestamp closest to the current moment is used as the time embedding feature of the current moment.
[0014] Furthermore, the initial spatiotemporal features are constructed based on the spatial embedding features and the temporal embedding features, specifically: for a certain time at a certain location, based on its corresponding traffic flow, its high-dimensional features are obtained using a fully connected layer; the sum of the high-dimensional features, the temporal embedding features at the current time, and the spatial embedding features of the current location is used as the initial spatiotemporal features of the current location at the current time.
[0015] Furthermore, the extraction of the spatial embedding features is specifically as follows: based on a pre-constructed adjacency matrix diagram of each location in the area to be predicted, a DeepWalk algorithm is used to randomly walk on the adjacency matrix diagram to obtain the path from each location to its adjacent location, and the extraction of the spatial embedding features is realized based on the path.
[0016] Furthermore, the acquisition of the spatiotemporal conditional features is specifically as follows: based on the initial spatiotemporal features, using a pre-trained time-gated graph network to obtain the local time correlation corresponding to each location and the global time correlation of all locations; using the global time correlation as a gate to adjust the local time correlation, and using a graph convolution model to obtain the time correlation; and using a pre-trained space-gated graph network to obtain the local spatial correlation corresponding to each moment and the global spatial correlation of the entire time period; using the global spatial correlation as a gate to adjust the local spatial correlation, and using a graph convolution model to obtain the spatial correlation; obtaining the spatiotemporal features by iteratively executing the above process; and obtaining the spatiotemporal conditional features based on the spatiotemporal features through a temporal attention mechanism.
[0017] Furthermore, the traffic flow probability of each location in the future time period of the area to be predicted is obtained through the conditional normalized flow, and the RealNVP normalized flow is specifically used.
[0018] Furthermore, the spatiotemporal gate graph network includes a time gate graph network and a space gate graph network, wherein the time gate graph network specifically performs the following processing procedures: for the traffic data of each location at different times, a time correlation graph of each location is obtained using a time attention mechanism as a local time graph; the time embedding features of each time are organized into a matrix form, and the matrix is multiplied by its transpose to obtain a global time graph; the global time graph is used as a gate to adjust the local time graph, and then a graph convolution is used to capture the time correlation; the space gate graph network specifically performs the following processing procedures: for the traffic data of different locations at each moment, a spatial attention mechanism is used to obtain the spatial correlation at each moment as a local space graph; the spatial embedding features of each location are organized into a matrix form, and the matrix is multiplied by its transpose to obtain a global space graph; the global space graph is used as a gate to adjust the local space graph, and a graph convolution model is used to capture the spatial correlation.
[0019] Another aspect of the present invention provides a traffic flow probability prediction system, including:
[0020] An initial spatiotemporal feature extraction unit is used to extract spatial embedding features and temporal embedding features based on the historical traffic flow data of each location in the area to be predicted within a preset time period and the future time period to be predicted; and construct initial spatiotemporal features based on the spatial embedding features and temporal embedding features;
[0021] A spatiotemporal conditional feature extraction unit, which is used to extract time correlation and space correlation based on the initial spatiotemporal features by using a pre-trained spatiotemporal gate graph network; based on the obtained time correlation and space correlation, the spatiotemporal conditional features are obtained through a temporal attention mechanism; wherein the spatiotemporal gate graph network specifically performs the following processing: extracting local and global correlations in the time and space dimensions respectively, adjusting the local correlation using the global correlation as a gate, and obtaining the time and space correlations through a graph convolutional network based on the global correlation and the local correlation;
[0022] The traffic flow probability prediction unit is used to obtain the traffic flow probability of each location in the future time period of the area to be predicted through conditional normalization flow based on the spatiotemporal condition characteristics.
[0023] An embodiment of the present invention further provides an electronic device, comprising a processor, wherein the processor is configured to implement a traffic flow probability prediction method as described in any of the preceding items when executing a computer program stored in a memory.
[0024] Finally, an embodiment of the present invention further provides a non-transitory readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, a traffic flow probability prediction method as described in any of the preceding items is implemented.
[0025] Compared with the prior art, the present invention has the following beneficial effects:
[0026] The scheme of the present invention provides a traffic flow probability prediction method and system. The scheme is based on conditional normalized flow and spatiotemporal graph feature learning, and uses the spatiotemporal gate graph network to capture global and local spatiotemporal relationships, and provides them to the conditional normalized flow to estimate the probability distribution of future data. The scheme of this embodiment can output the probability distribution of traffic flow at each location and time, which is convenient for traffic management departments to understand possible traffic conditions and potential abnormal conditions, make traffic decisions in advance, and improve the reliability of prediction results. The scheme of the present invention constructs spatiotemporal embedding features by using spatiotemporal prior knowledge to capture the spatiotemporal information of the area to be predicted. At the same time, by considering the specific spatiotemporal relationship under local spatiotemporal conditions, it can capture complex and dynamic spatiotemporal relationships, provide effective spatiotemporal condition features to the conditional normalized flow, and more comprehensively and accurately predict the probability distribution of data; compared with the existing traffic flow prediction method, the scheme of the present invention can effectively use the specific spatiotemporal relationship to predict the probability distribution of traffic flow, and provide users with a traffic flow probability prediction system with strong reliability, high accuracy and fast prediction speed. Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0028] Figure 1 A flow chart of a traffic flow probability prediction method described in an embodiment of the present invention;
[0029] Figure 2 A schematic diagram of the overall training process described in an embodiment of the present invention;
[0030] Figure 3 It is a schematic diagram of the structure of the time gate graph network and the space gate graph network described in the embodiment of the present invention;
[0031] Figure 4 The figure is a schematic diagram of the structure of a traffic flow probability prediction system described in an embodiment of the present invention. DETAILED DESCRIPTION
[0032] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0033] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0034] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0035] After introducing the technical solutions of the embodiments of the present invention, various non-limiting implementation methods of the present application are described in detail below.
[0036] See first Figure 1 , Figure 1 A flow chart of a traffic flow probability prediction method provided by an embodiment of the present invention. The embodiment of the present invention is based on conditional normalized flow and spatiotemporal graph learning, uses a spatiotemporal gate graph network to capture global and local spatiotemporal relationships, and provides conditional normalized flow with an estimate of the probability distribution of future data. The method includes the following contents:
[0037] Step 1: Based on the historical traffic flow data of each location in the area to be predicted within a preset time period and the future time period to be predicted, spatial embedding features and temporal embedding features are extracted respectively; based on the spatial embedding features and temporal embedding features, initial spatiotemporal features are constructed;
[0038] First, it is necessary to obtain the traffic flow data within a preset time period of the known test area as the historical traffic flow data and the future time period to be predicted. The acquisition of the historical traffic flow data is based on sensors set at different locations on each road. The sensors on each road record the traffic flow at different times. By collecting the traffic flow of each road, the historical traffic flow data can be obtained.
[0039] In the specific implementation, it is also necessary to construct the adjacency matrix diagram of different locations in advance according to the connection relationship of the roads. , is the number of locations. Each value in the matrix represents the relationship between two locations, which is calculated by the Gaussian kernel function of the distance between the two locations. , represents the standard deviation of the distances to all locations, dist ( i , j )express i Location and j The distance between locations.
[0040] The step 1 specifically includes: using the known historical traffic flow data of a preset time period, the time embedding features corresponding to the historical time and the space embedding features corresponding to each location to construct the initial space-time features of the historical data; and using the future time period to be predicted, according to the time embedding features corresponding to the future time and the space embedding features corresponding to each location to construct the initial space-time features of the predicted data, and splicing the initial space-time features of the historical data and the initial space-time features of the predicted data in the time dimension to obtain the initial space-time features of all data.
[0041] In the specific implementation, based on the idea of using the historical traffic flow data of the past period of time to predict the joint probability distribution of traffic flow data of the future period of time, it is assumed that the length of the historical time is , the future time length is , the historical traffic data is expressed as , the future traffic data is expressed as We use the spatiotemporal decomposition method to separate the joint probability distribution of traffic data at all future locations into the conditional probability distribution of each future data at each location:
[0042]
[0043] in, express Place Traffic data at the moment, which is related to two conditions: one is the historical data of all locations , and the other is Place Traffic data before time .
[0044] In the specific implementation, we use temporal embedding features and spatial embedding features to represent the temporal and spatial indication information. For spatial embedding features, we use a learnable embedding feature matrix Learn the characteristics of each location. We use the DeepWalk algorithm to initialize the location embedding features. DeepWalk uses the adjacency matrix graph of the location The random walk on the map obtains the paths of adjacent locations and learns the embedded features of each location based on the adjacent relationship of the locations.
[0045] Among them, learnable means that the values in the matrix are obtained through network training. In the matrix, N Indicates the number of locations. C Represents the length of the embedded feature of each location. The DeepWalk algorithm is used to learn the embedded features of each location. The DeepWalk algorithm first initializes the embedded features of each location, and learns the embedded features of the location by minimizing the distance between the embedded features of adjacent locations according to the adjacent relationship between the locations. The embedded features of each location are organized to obtain the embedded feature matrix of all locations. .
[0046] For the temporal embedding features, we use a learnable embedding feature matrix and Represents the embedding features of the week and the embedding features of different times of the day, Indicates the day of the week, = 7, Indicates the number of timestamps in a day. Indicates the feature length of the embedded feature. Because the number of vehicles in the morning and evening peaks increases, more traffic management is needed. We believe that the morning and evening peaks are more important, so we select important timestamps of the day to capture the traffic pattern of the corresponding time period. Because the traffic flow changes on weekends and weekdays are different, we select important timestamps on weekdays and weekends respectively.
[0047] in, The matrix represents the embedding feature matrix of different days of the week, To represent the days of the week, for example, we use =7 means there are 7 days in a week. For each day, the network model is used to learn the parameters of the embedding features of that day. The feature length is C , organize the daily embedding features into a matrix form as , the actual training matrix dimension is 7×C, then the first row is the feature of Monday, and the seventh row is the feature of Sunday;
[0048] The matrix represents the embedding vector matrix at different times of the day. Indicates the number of timestamps in a day. For example, we collect traffic data every 5 minutes, there are 12 timestamps in an hour, and there are 24×12=288 timestamps in a day. Each timestamp is represented by an embedded feature with a feature length of C. The parameters of the embedded features are randomly initialized first, and then the embedded features at each moment are organized into a matrix form through network training. , the matrix dimension is 288×C.
[0049] Taking working days as an example, the traffic flow at different times of the working day is plotted, where the flow at each time is calculated using the average of the flow at that time at all locations and all working days; important timestamps are selected from the flow curve. The solution described in this embodiment selects three important timestamps:
[0050] The time corresponding to the maximum flow rate: At this time, the flow rate reaches its peak and more traffic management is needed. (2) The time when the flow rate changes rapidly: At this time, the flow rate rises or falls rapidly, causing an increased risk of traffic accidents. We use the absolute value of the first-order derivative to select the time when the flow rate changes rapidly. We select the d times with the largest absolute value of the first-order derivative, and then calculate the time interval. Select a time, there are timestamp.
[0051] (3) Extreme point of the traffic change curve: This time captures the trend of traffic change. We take the union of these three times as the important timestamps of weekdays. Similarly, we also use the same method to select the important timestamps of weekends.
[0052] Important timestamps divide a day into different time periods. Traffic patterns in the same time period are similar, while traffic patterns in different time periods are dissimilar. and Embedded features representing the traffic patterns of the time periods corresponding to important timestamps on weekdays and weekends, and Indicates the number of important timestamps selected for weekdays and weekends. , we select the traffic mode embedding feature corresponding to the nearest important timestamp as its traffic mode embedding feature We will time Corresponding traffic mode embedding features , weekday embedding feature and embedding features at different times of the day Add as temporal embedding features:
[0053]
[0054] Specifically, Embedded features representing traffic patterns corresponding to different important timestamps on weekdays, Indicates the number of important timestamps on weekdays. For example, the important timestamps we choose are 8 am, 10 am, and 6 pm. Each moment has an embedded feature with a feature length of C. This embedded feature represents the traffic mode feature of this timestamp. The traffic mode represents the traffic conditions at the corresponding moment. For example, the traffic conditions at 8 am are congested during the morning rush hour, the traffic conditions at 10 am are relatively smooth, and the traffic is relatively congested at 6 pm. The traffic mode is represented by embedded features, and the values of the embedded features are obtained by network initialization and training. In the above example, there are 3 important timestamps on weekdays. The dimension is 3×C, and each row represents the characteristics of the traffic mode at the corresponding timestamp.
[0055] Embedded features representing traffic patterns corresponding to important timestamps on weekends, Indicates the number of important timestamps on weekends. For example, the important timestamps we choose are 10 am, 2 pm and 8 pm. Each timestamp has an embedded feature to represent the traffic pattern characteristics at this time. For example, at 10 am on weekends, people go out and traffic begins to get congested. At 2 pm, the traffic is relatively smooth, and at 8 pm, the road is congested. The traffic pattern of each timestamp is represented by an embedded feature with a feature length of C. The embedded feature is initialized and trained by the network. In this example, there are 3 important timestamps on weekends. The dimension is 3×C, and each row represents the characteristics of the traffic mode at the corresponding timestamp.
[0056] By learning the initial embedding features of each historical data. Place Traffic flow at the moment , use the fully connected layer (FC) to turn it into a high-dimensional feature ; Its high-dimensional features correspond to the time features and location characteristics Add as its initial space-time characteristics .
[0057] For each future data , its corresponding time feature and location characteristics Add together as the initial spatiotemporal features of future data .
[0058] We organize the initial spatiotemporal features of all historical data into , the initial spatiotemporal characteristics of future data are , the historical initial spatiotemporal features and the future initial spatiotemporal features are spliced in the time dimension to obtain the initial spatiotemporal features of all data .
[0059] Step 2: Based on the initial spatiotemporal features, a pre-trained spatiotemporal gate graph network is used to extract temporal correlation and spatial correlation; based on the obtained temporal correlation and spatial correlation, a spatiotemporal conditional feature is obtained through a temporal attention mechanism; wherein the spatiotemporal gate graph network specifically performs the following processing: extracting local and global correlations in the temporal and spatial dimensions respectively, adjusting the local correlation using the global correlation as a gate, and obtaining the temporal and spatial correlations through a graph convolutional network based on the global correlation and the local correlation;
[0060] The step 2 specifically includes the following processing steps:
[0061] For each conditional probability distribution , the solution described in this embodiment requires obtaining input data and its conditions and First, the scheme uses the spatiotemporal gate graph network to learn and The spatiotemporal gate graph network includes the time gate graph network and the space gate graph network. We input the initial spatiotemporal features of all data ,First, the local and global temporal correlation of traffic data is learned through the ,temporal gate graph network, and the output features of the ,temporal gate graph network are input into the spatial gate graph ,network to learn the local and global spatial correlation of traffic data.
[0062] like Figure 3 As shown, the time gate graph network specifically performs the following processing: for the traffic data of each location at different times, the time correlation graph of each location is obtained using the time attention mechanism as the local time graph; the time embedding features of each time are organized into a matrix form, and the matrix is multiplied by its transpose to obtain the global time graph; the global time graph is used as a gate to adjust the local time graph, and then the graph convolution is used to capture the time correlation;
[0063] The spatial gate graph network specifically performs the following processing process: for traffic data at different locations at each moment, a spatial attention mechanism is used to obtain the spatial correlation at each moment as a local spatial graph; the spatial embedding features of each location are organized into a matrix form, which is multiplied with its transpose to obtain a global spatial graph, the global spatial graph is used as a gate to adjust the local spatial graph, and then a graph convolution model is used to capture the spatial correlation.
[0064] We use the time-gated graph network to capture local and global temporal correlations. In the time dimension, data at different times have strong temporal correlations. The temporal correlations are different in different locations. For example, on the main roads, the number of vehicles increases during peak hours, and the temporal correlation is relatively large. In the suburbs, the traffic is relatively stable throughout the day, and the temporal correlation is relatively small. Therefore, we learn the local temporal correlation at each location. The characteristics of the data at different times are , we use Study Place The following time dependencies:
[0065]
[0066] in, is the parameter matrix, Mapping to a higher-order space. Indicate location It represents the temporal correlation under the local time graph and learns the unique temporal correlation under the specific location. We organize the temporal embedding features of each moment into . Represents the characteristics of each moment, we use Learning a global temporal graph:
[0067]
[0068] in, Represents the correlation of time itself, which is the global temporal correlation of all locations. We use the global graph as a gate to adjust the local graph, filter out unimportant edges in the local graph, and then use the graph convolution model to capture the temporal correlation:
[0069]
[0070] in, It is Hadamard. It means that the parameter matrix maps the features to a high-dimensional space. Indicate location Features at different times, capturing the location We learn the temporal features of each location and organize them into a tensor .
[0071] We use the spatial gate graph network to learn global and local spatial relationships. The spatial relationship is different at different times. In the morning, the flow from residential areas to work areas is relatively large, while in the evening, the flow from work areas to commercial areas is relatively large. We learn the local spatial relationship at each time. The location characteristics are , we use Learning moments The following spatial relationships:
[0072]
[0073] in, is a learnable parameter matrix, Mapping to a higher-order space. Indicates time The spatial relationship under the local dynamic spatial relationship is captured. At the same time, the location embedding feature matrix After learning the geographical relationship of the locations, we use Learn global location relationships:
[0074]
[0075] in, is the global location graph, capturing the time-invariant relationships of the location itself. We use the global spatial graph as a gate to retain the more important relationships in the local spatial graph, and use a graph convolutional model to capture spatial relationships:
[0076]
[0077] in, is the learnable parameter matrix, Indicates time The characteristics of different locations capture the global geographic location correlation and time We learn the location features at different times and organize them into a tensor , we transpose it into .
[0078] We regard the time-gated graph network and the space-gated graph network as the space-time gated graph network , we stack multiple layers to extract higher-order spatiotemporal features:
[0079]
[0080] It is The output of the layer is The first layer input is the initial spatiotemporal features , we superimpose layer, the output of the last layer is .
[0081] We capture this with a spatiotemporal gate graph network and all location history data Next, we use the time attention network to capture and time conditions Time conditions The corresponding spatiotemporal features learned in the spatiotemporal gate graph network are , we concatenate the temporal condition and the corresponding spatiotemporal features as the temporal condition feature We use the attention mechanism to capture and time conditions Time relationship:
[0082]
[0083] in, Will Mapped to a higher-order space, Will Mapping to a higher-order space, using and capture and and fuses the features of the temporal conditions based on the correlation. express The conditional characteristics include and historical data for all locations The relationship between relationship.
[0084] Step 3: Based on the spatiotemporal condition characteristics, the traffic flow probability of each location in the future time period of the area to be predicted is obtained through conditional normalization flow.
[0085] In the specific implementation, for each prediction data , first sample from the Gaussian distribution to obtain the sampled value , and then use the inverse mapping of the conditional normalization flow to conditional features For conditional information, obtain the predicted value of each data , the predicted value at this moment will be used as the time condition information of the traffic flow at the next predicted moment; through autoregression, the traffic flow at each time can be predicted; the prediction process from the first prediction moment to the last prediction moment will be repeated many times, and multiple prediction values will be obtained for each prediction data to represent its probability distribution.
[0086] Specifically, the normalized flow is a arrive The mapping of Obey a complex distribution , Follows a simple distribution , such as Gaussian distribution. By mapping , by converting a complex distribution into a simple distribution, probability density and simple sampling can be calculated. According to the variable change formula, we can calculate The probability density of is:
[0087]
[0088] in, is a mapping exist The important property of normalized flow is that the determinant of the Jacobian matrix is easy to calculate and the inversion mapping can be easily found. .
[0089] RealNVP is a normalized flow that satisfies the property. It proposes a coupling layer to input Divided into two parts: one part Directly as output, the other part The output is transformed into:
[0090] (12)
[0091] in, and is from arrive Through the construction of the coupling layer, the Jacobian matrix of RealNVP is a lower triangular matrix, the determinant of its Jacobian matrix is easy to calculate, and its inverse mapping can be simply calculated.
[0092] Conditional normalization flow adds conditional features to the normalized flow To strengthen the flow. The conditional normalization flow is a mapping , we calculate based on the change of variables by The probability density conditional on is:
[0093]
[0094] RealNVP concatenates the input variables and conditional information as the input of the nonlinear layer, that is, and .
[0095] By using the spatiotemporal decomposition method, the joint distribution of future data is divided into the conditional probability distribution of traffic data at each location and at each time. , the relationship between input and condition is learned by using the spatiotemporal gate graph module and the time attention model to obtain conditional features We use the conditional normalization flow to is the conditional feature estimate The conditional probability distribution of :
[0096]
[0097] By using the mapping method of RealNVP, it can be simply and effectively calculated The conditional probability distribution of and the inverse mapping is easily obtained.
[0098] In the specific implementation, Figure 2 As shown, the traffic flow probability prediction method described in this embodiment requires network training in advance for the overall network structure, which specifically includes the following process:
[0099] By using the negative maximum likelihood of the joint probability distribution of future traffic data as the loss function, using the spatiotemporal decomposition method (i.e., formula (1)) and the conditional normalized flow estimation method (i.e., formula (14)), the loss function is:
[0100]
[0101]
[0102] The network is trained based on the above loss function until the loss value stops decreasing or reaches the maximum number of training times, and the parameters of the network model are saved.
[0103] Thus, based on the above design, the scheme described in the above embodiment is based on conditional normalized flow and spatiotemporal graph feature learning, and uses the spatiotemporal gate graph network to capture global and local spatiotemporal relationships, and provides the conditional normalized flow with the probability distribution of estimated future data; on the one hand, the scheme described in this embodiment can output the probability distribution of traffic flow at each location and each time, which is convenient for the traffic management department to understand the possible traffic conditions and potential abnormal conditions, make traffic decisions in advance, and provide the reliability of the model prediction results; on the other hand, the scheme described in this embodiment uses spatiotemporal prior knowledge to construct spatiotemporal embedding features to capture the spatiotemporal information of the city itself, while considering the specific spatiotemporal relationships under local spatiotemporal conditions, which is conducive to capturing complex and dynamic spatiotemporal relationships, providing effective spatiotemporal conditional features to the conditional normalized flow, and more comprehensively and accurately predicting the probability distribution of data; compared with the existing traffic flow prediction method, the scheme described in this embodiment can effectively utilize the specific spatiotemporal relationship to predict the probability distribution of traffic flow, and provide users with a traffic flow probability prediction system with strong reliability, high accuracy and fast prediction speed.
[0104] In one or more embodiments, for the above-mentioned traffic flow probability prediction method, such as Figure 4 The embodiment shown here corresponds to a traffic flow probability prediction system, including:
[0105] An initial spatiotemporal feature extraction unit is used to extract spatial embedding features and temporal embedding features based on the historical traffic flow data of each location in the area to be predicted within a preset time period and the future time period to be predicted; and construct initial spatiotemporal features based on the spatial embedding features and temporal embedding features;
[0106] A spatiotemporal conditional feature extraction unit, which is used to extract time correlation and space correlation based on the initial spatiotemporal features by using a pre-trained spatiotemporal gate graph network; based on the obtained time correlation and space correlation, the spatiotemporal conditional features are obtained through a temporal attention mechanism; wherein the spatiotemporal gate graph network specifically performs the following processing: extracting local and global correlations in the time and space dimensions respectively, adjusting the local correlation using the global correlation as a gate, and obtaining the time and space correlations through a graph convolutional network based on the global correlation and the local correlation;
[0107] The traffic flow probability prediction unit is used to obtain the traffic flow probability of each location in the future time period of the area to be predicted through conditional normalization flow based on the spatiotemporal condition characteristics.
[0108] In further embodiments, there is also provided:
[0109] An electronic device includes a processor, wherein the processor is used to implement a traffic flow probability prediction method when executing a computer program stored in a memory.
[0110] A non-transitory readable storage medium having a computer program stored thereon, wherein the computer program implements the traffic flow probability prediction method when executed by a processor.
Claims
1. A traffic flow probability prediction method, characterized in that: include: Based on the historical traffic flow data of each location in the area to be predicted within a preset time period and the future time period to be predicted, spatial embedding features and temporal embedding features are extracted respectively; Based on the spatial embedding features and the temporal embedding features, constructing initial spatiotemporal features; The extraction of the time embedding feature is specifically as follows: based on the historical data of traffic flow, the important timestamps of working days and weekends are determined according to preset rules; wherein the important timestamps include the time corresponding to the maximum flow value on working days or weekends, several times when the flow changes rapidly, and the time corresponding to the extreme point of the flow change curve; for a certain moment, the sum of the embedding features of the weekly embedding features, the daily embedding features and the traffic mode embedding corresponding to the important timestamp closest to the current moment is used as the time embedding feature of the current moment; the extraction of the spatial embedding feature is specifically as follows: based on the pre-constructed adjacency matrix diagram of each location in the area to be predicted, the DeepWalk algorithm is used to randomly walk on the adjacency matrix diagram to obtain the path from each location to its adjacent location, and the spatial embedding feature is extracted based on the path; the initial spatiotemporal feature is constructed based on the spatial embedding feature and the time embedding feature, specifically as follows: for a certain moment at a certain location, based on its corresponding traffic flow, its high-dimensional features are obtained using a fully connected layer; the sum of the high-dimensional features, the time embedding features of the current moment and the spatial embedding features of the current location is used as the initial spatiotemporal feature of the current location at the current moment; Based on the initial spatiotemporal features, a pre-trained spatiotemporal gate graph network is used to extract temporal correlation and spatial correlation; based on the obtained temporal correlation and spatial correlation, a spatiotemporal conditional feature is obtained through a temporal attention mechanism; wherein the spatiotemporal gate graph network specifically performs the following processing: extracting local and global correlations in the temporal and spatial dimensions respectively, adjusting the local correlation using the global correlation as a gate, and obtaining the temporal and spatial correlations through a graph convolutional network based on the global correlation and the local correlation; The spatiotemporal gate graph network includes a time gate graph network and a space gate graph network, wherein the time gate graph network specifically performs the following processing procedures: for the traffic data of each location at different times, a time correlation graph of each location is obtained using a time attention mechanism as a local time graph; the time embedding features of each time are organized into a matrix form, and the matrix is multiplied by its transpose to obtain a global time graph; the global time graph is used as a gate to adjust the local time graph, and then a graph convolution is used to capture the time correlation; the space gate graph network specifically performs the following processing procedures: for the traffic data of different locations at each moment, a spatial attention mechanism is used to obtain the spatial correlation at each moment as a local space graph; the spatial embedding features of each location are organized into a matrix form, and the matrix is multiplied by its transpose to obtain a global space graph; the global space graph is used as a gate to adjust the local space graph, and a graph convolution model is used to capture the spatial correlation; based on the spatiotemporal conditional features, the traffic flow probability of each location in the future time period of the area to be predicted is obtained through conditional normalization flow.
2. A traffic flow probability prediction method as claimed in claim 1, characterized in that: The acquisition of the spatiotemporal conditional features is specifically as follows: based on the initial spatiotemporal features, using a pre-trained time-gated graph network to obtain the local time correlation corresponding to each location and the global time correlation of all locations; using the global time correlation as a gate to adjust the local time correlation, and using a graph convolution model to obtain the time correlation; and using a pre-trained space-gated graph network to obtain the local spatial correlation corresponding to each moment and the global spatial correlation of the entire time period; The global spatial correlation is used as a gate to adjust the local spatial correlation, and the graph convolution model is used to obtain the spatial correlation; the spatiotemporal features are obtained by iteratively executing the above process; based on the spatiotemporal features, the spatiotemporal conditional features are obtained through the temporal attention mechanism.
3. A traffic flow probability prediction method as claimed in claim 1, characterized in that: Through the conditional normalized flow, the traffic flow probability of each location in the future time period of the area to be predicted is obtained, and the RealNVP normalized flow is specifically used.
4. A traffic flow probability prediction system, characterized in that: include: An initial spatiotemporal feature extraction unit is used to extract spatial embedding features and temporal embedding features based on the historical traffic flow data of each location in the area to be predicted within a preset time period and the future time period to be predicted; and construct initial spatiotemporal features based on the spatial embedding features and temporal embedding features; The extraction of the time embedding feature is specifically as follows: based on the historical traffic flow data, the important timestamps of working days and weekends are determined according to preset rules; wherein the important timestamps include the time corresponding to the maximum flow value on working days or weekends, several times when the flow changes rapidly, and the time corresponding to the extreme point of the flow change curve; for a certain moment, the sum of the embedding features within the week, the embedding features within the day, and the traffic mode embedding corresponding to the important timestamp closest to the current moment is used as the time embedding feature of the current moment; The extraction of the spatial embedding features is specifically as follows: based on a pre-constructed adjacency matrix diagram of each location in the area to be predicted, a DeepWalk algorithm is used to randomly walk on the adjacency matrix diagram to obtain a path from each location to its adjacent location, and the spatial embedding features are extracted based on the path; The initial spatiotemporal features are constructed based on the spatial embedding features and the temporal embedding features, specifically: for a certain time at a certain location, based on its corresponding traffic flow, a high-dimensional feature is obtained using a fully connected layer; the sum of the high-dimensional feature, the temporal embedding feature at the current time, and the spatial embedding feature of the current location is used as the initial spatiotemporal features of the current location at the current time; A spatiotemporal conditional feature extraction unit, which is used to extract time correlation and space correlation based on the initial spatiotemporal features by using a pre-trained spatiotemporal gate graph network; based on the obtained time correlation and space correlation, the spatiotemporal conditional features are obtained through a temporal attention mechanism; wherein the spatiotemporal gate graph network specifically performs the following processing: extracting local and global correlations in the time and space dimensions respectively, adjusting the local correlation using the global correlation as a gate, and obtaining the time and space correlations through a graph convolutional network based on the global correlation and the local correlation; The spatiotemporal gate graph network includes a time gate graph network and a space gate graph network, wherein the time gate graph network specifically performs the following processing process: for traffic data at different times of each location, a time correlation graph of each location is obtained using a time attention mechanism as a local time graph; the time embedding features of each time are organized into a matrix form, and the matrix is multiplied by its transpose to obtain a global time graph; the global time graph is used as a gate to adjust the local time graph, and then the graph convolution is used to capture the time correlation; the space gate graph network specifically performs the following processing process: for traffic data at different locations at each moment, a spatial attention mechanism is used to obtain the spatial correlation at each moment as a local space graph; the spatial embedding features of each location are organized into a matrix form, and the matrix is multiplied by its transpose to obtain a global space graph; the global space graph is used as a gate to adjust the local space graph, and the graph convolution model is used to capture the spatial correlation; The traffic flow probability prediction unit is used to obtain the traffic flow probability of each location in the future time period of the area to be predicted through conditional normalization flow based on the spatiotemporal condition characteristics.
5. An electronic device, comprising a processor, characterized in that: The processor is used to implement a traffic flow probability prediction method as described in any one of claims 1-3 when executing a computer program stored in the memory.
6. A non-transitory readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, a traffic flow probability prediction method as described in any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Traffic flow prediction method based on global diffusion convolution residual network
CN112071065A
Traffic flow prediction method and system based on trend space-time diagram convolution, and medium
CN116895157A