Urban area traffic flow prediction method considering multiple space-time granularities
By constructing distance maps and semantic maps, organizing multi-grained sub-tensters, and combining non-stationary Transformer, the problem of ignoring user travel modes and land use characteristics in the existing technology is solved, and the accuracy and accuracy of traffic flow prediction is improved, and the promotion of traffic flow prediction is promoted. The development of smart cities.
Patent Information
- Application Number
- CN202411182775.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2024-12-20
AI Technical Summary
The existing urban area traffic flow prediction methods cannot fully utilize the potential characteristics in traffic data, especially ignore user travel patterns and land use characteristics, and it is difficult to effectively model complex topological structures and long-term time dependencies, resulting in low prediction accuracy.
Design a traffic flow prediction method that considers multi-spatial-time particle size, captures spatial correlation by constructing distance graphs and semantic graphs, organizes traffic data as multi-grained sub-tensters, combines non-stationary Transformer to capture time features, and integrates weather and date attributes. Build spatiotemporal network blocks for prediction.
It improves the accuracy of urban regional traffic flow prediction, can better capture multimodal spatial correlation and non-stationary time characteristics, improves prediction accuracy, alleviates traffic congestion, and promotes the construction of smart cities.
Smart Images

Figure CN119169809A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of information technology, and in particular relates to a method for predicting urban area traffic flow considering multiple spatiotemporal granularities. Background Art
[0002] Accurate prediction of urban area traffic flow can not only improve the operating efficiency of urban traffic, but also promote the sustainable development of cities and improve the quality of life of residents. Early traffic flow prediction models used statistical methods or traditional machine learning methods to predict regional inflows and outflows, which required manual feature extraction and could not fully utilize the potential features contained in traffic data. With the development of deep learning, researchers began to build end-to-end neural network models to predict traffic flow. Among them, convolutional neural networks are used to capture spatial correlation dependencies, while recurrent neural networks are used to capture temporal correlation dependencies. However, convolutional neural networks can only be used for regular grids and Euclidean spaces, and cannot effectively model traffic networks with complex topological structures.
[0003] In recent years, researchers have modeled the spatial dependencies of regional traffic flow data by constructing predefined graph structures and using graph convolutional neural networks. These graph structures usually only consider the distance association between regions, ignore the travel patterns of users, and rarely consider the surrounding land use characteristics that affect the travel patterns, which limits the model to prior knowledge. In terms of capturing temporal dependencies, commonly used models are long short-term memory networks (LSTM) or gated recurrent networks (GRU), but they have gradient vanishing problems and are difficult to model long-term dependencies. In addition, historical traffic flow will affect future traffic in different ways, such as traffic within adjacent hours and traffic at specific time points in the past date will affect traffic at a certain time point in the future. Traffic data also has non-stationary characteristics, that is, its statistical characteristics and joint distribution will change over time. Therefore, it is necessary to design a method for predicting urban regional traffic flow, which can improve the accuracy of regional traffic prediction by constructing an effective graph structure to encode features related to distance and user travel behavior, while considering the temporal multi-granularity characteristics and non-stationarity of the data. Summary of the invention
[0004] In view of the above problems, the present invention designs a method for predicting urban regional traffic flow that considers multiple spatiotemporal granularities. In terms of space, the distance correlation and flow similarity between regions are captured simultaneously, and the impact of regional land use characteristics on travel patterns is considered. In terms of time, the time correlation and non-stationary characteristics of data at different granularities are captured, and weather and date attributes are integrated into the model to improve the accuracy of regional flow prediction, better alleviate traffic congestion, and promote the construction of smart cities.
[0005] A method for predicting urban area traffic flow considering multiple spatiotemporal granularities includes the following steps:
[0006] Step 1: Obtain traffic flow dataset, regional dataset, weather dataset and Points of Interest (POI) dataset.
[0007] Step 2: Preprocess the data in the traffic flow dataset and construct attribute features.
[0008] Step 3: Based on the preprocessed traffic flow data, construct traffic sub-tensors at three time granularities.
[0009] Since traffic flow in different periods of the past will affect future traffic flow in different ways, the present invention defines the temporal pattern of regional traffic flow from three time granularities, including recent pattern, daily cycle pattern, and weekly cycle pattern. Organized into three sub-tensors, reflecting these three modes respectively.
[0010] Step 4: For each region, construct a region association graph, including a distance graph and a semantic graph.
[0011] Different spatial correlations can affect the traffic flow patterns of regions. First, there may be close traffic correlations between adjacent regions. Second, due to the spatial differences in land use characteristics that affect travel activities, two distant regions may also have similar usage patterns. For example, the area where the business district is located has a large number of inbound traffic during the morning peak hours. Therefore, for each region, two types of regional correlation graphs are constructed: distance graphs and semantic graphs, which capture spatial proximity relationships and semantic relationships with similar functional attributes, respectively.
[0012] Step 5: Construct a spatiotemporal network block. Based on the distance graph and semantic graph, combine the attribute features and the flow sub-tensors at three time granularities, and obtain the spatiotemporal representation at the time granularity through the spatiotemporal network block.
[0013] Step 6: Fuse the spatiotemporal representation of data at each time granularity to predict traffic, and perform reverse training to obtain the model.
[0014] The model calculates the loss and optimizes the parameters through back propagation. After the model is constructed, the prediction model is used to predict based on the test data to obtain the final regional traffic prediction results.
[0015] Advantages and effects of this application compared to the prior art
[0016] The characteristics and innovations of the method of the present invention are that the existing urban area traffic flow prediction methods only capture spatiotemporal information from a single time or space granularity, which reduces the prediction accuracy. The present invention proposes a method for predicting urban area traffic flow that takes into account multiple spatiotemporal granularities. In space, distance graphs and semantic graphs are constructed to reflect the geographical adjacency and semantic correlation between regions, so as to better capture multimodal spatial correlation relationships. In time, the original traffic data is organized into recent sub-tensors, daily period sub-tensors, and weekly period sub-tensors to represent the temporal characteristics of urban area traffic at three granularities, and a non-stationary Transformer is used to capture the non-stationary characteristics of traffic data at each time granularity, thereby improving the accuracy of urban area traffic flow prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 For data processing and model structure diagram;
[0018] Figure 2 It is a space-time network block (STN block) structure. DETAILED DESCRIPTION
[0019] A method for predicting urban area traffic flow considering multiple spatiotemporal granularities, with the structure Figure 1 As shown, the following steps are included:
[0020] Step 1: Obtain traffic flow dataset, regional dataset, weather dataset and Points of Interest (POI) dataset.
[0021] Obtain traffic flow datasets, such as taxi datasets, shared bicycle datasets, etc. Each record in the dataset contains entry time, entry area ID, exit time, and exit area ID.
[0022] Get the region dataset. Each record in the dataset contains the region ID, the longitude and latitude of the region center, and the region boundary information.
[0023] Get the points of interest dataset, which contains POI type tags related to locations, such as schools, companies, tourist attractions, etc. Each record contains the latitude and longitude of a location and the corresponding POI type tag.
[0024] Get the weather data set, which includes temperature, precipitation, and weather conditions. The weather conditions include sunny, light rain, heavy rain, light snow, heavy snow, etc.
[0025] Step 2: Preprocess the data in the traffic flow dataset and construct attribute features.
[0026] Step 2.1: Preprocess the traffic flow data.
[0027] The records in the traffic flow dataset are aggregated hourly according to the entry time to obtain the historical traffic sequence of each area in the city. Assuming that the city contains N areas, use Represents the regional flow tensor, where T represents the time step length in hours. t is the flow matrix of all areas in the city at time t. F represents the number of flow characteristics, including inflow and outflow.
[0028] Step 2.2: Construct attribute features.
[0029] Construct attribute features Attr, including date attribute features Attr date and weather attribute feature Attr wea For a time step, Attr date Contains 3 features: whether it is a weekday, the hour of the day, and the day of the week; Attr wea It includes temperature, precipitation and weather conditions. The weather conditions are encoded in the form of compound hot coding, that is, the corresponding bits can be 1 in multiple positions at the same time.
[0030] Step 3: Based on the preprocessed traffic flow data, construct traffic sub-tensors at three time granularities.
[0031] Since traffic flow in different periods of the past will affect future traffic flow in different ways, the present invention defines the temporal pattern of regional traffic flow from three time granularities, including recent pattern, daily cycle pattern, and weekly cycle pattern. It is organized into three sub-tensors, reflecting the three modes respectively. Assume that t0-1 represents the current time, t0 represents the predicted time point, and the recent sub-tensor Includes the region's traffic in the past few hours, defined as:
[0032]
[0033] Where N is the number of regions, F is the number of features, T r is the historical window size at adjacent time granularity.
[0034] Subtensors by daily period It consists of the traffic at the same hour as the forecast time point in the past few days, defined as:
[0035]
[0036] Where T d is the size of the historical window at the daily cycle time granularity, that is, the number of past days considered. d =24, indicating that a day consists of 24 hours.
[0037] Periodic subtensors It consists of the traffic with the same weekly attributes and time points as the predicted time point in the past few weeks. For example, for the data at 7 o'clock on Monday, get the traffic at 7 o'clock on Monday in the previous weeks. Defined as:
[0038]
[0039] Where T w is the size of the historical window at weekly time granularity, that is, the number of past weeks considered. w =168, which represents the number of hours in a week.
[0040] Step 4: For each region, construct a region association graph, including a distance graph and a semantic graph.
[0041] Different spatial correlations can affect the traffic flow patterns of regions. First, there may be close traffic correlations between adjacent regions. Second, due to the spatial differences in land use characteristics that affect travel activities, two distant regions may also have similar usage patterns. For example, the area where the business district is located has a large number of inbound traffic during the morning peak hours. Therefore, for each region, two types of regional correlation graphs are constructed: distance graphs and semantic graphs, which capture spatial proximity relationships and semantic relationships with similar functional attributes, respectively.
[0042] Step 4.1 Construct distance map
[0043] Using distance graph G d =(V,E d ,A d ) encodes the geographic connections between regions, represents the set of regional center points and the set of edges (v i ,v j )∈E d Represents the geographical connection between regions, the adjacency matrix A d Each element A d (i,j) is defined as:
[0044]
[0045] where dis(i,j) represents the distance between region i and region j, λ d is a predefined distance threshold. norm() represents the normalization operation. If norm(dis(i,j))≤λ d , indicating that the distance between region i and region j is relatively close, and the two are geographically adjacent. d (i,j)=1, that is, (v i ,v j )∈Ed , otherwise A d (i,j)=0, that is
[0046] Step 4.2 Build a semantic graph
[0047] Using semantic graph G s =(V,E s ,A s ,R s ) encodes the semantic relationship between regions, represents the set of regional center points, and the edge (v i ,v j )∈E s Represents the semantic connection relationship between regions, A s Represents the adjacency matrix of the semantic graph, R s Represents a collection of node types.
[0048] First, the Pearson correlation coefficient (PCC) is used to calculate the similarity between nodes based on the historical traffic patterns of the region. The historical traffic of region i can be expressed as Where T is the time step length, and represents the inflow and outflow of region i at time step t, node v i and v j Similarity PCC i,j Defined as:
[0049]
[0050] in, and is the average flow rate of area i and area j, and t is the time step.
[0051] Then, based on the regional center point set V and the PCC similarity between nodes, the complex network construction algorithm is used to construct the edge set E of the semantic graph. s In the complex network construction algorithm, firstly, A s Initialized to a matrix of all zeros, indicating that all nodes are initially disconnected and each node forms a node group. Then the node groups are iteratively merged. When the number of node groups is greater than 1, the two most similar node groups are found based on the similarity between node groups. The similarity between node groups is defined as the maximum PCC similarity between each pair of nodes in the groups. The most similar k pairs of nodes are selected from the two node groups. If their PCC similarity is greater than the threshold λ, s , then A sSet the corresponding position in 1 to indicate that the two nodes are connected. Merge the two node groups with the highest similarity into one, and update the similarity between each node group. When the number of node groups is 1, stop the iterative merging operation. Finally, s The diagonal value of is set to 1, indicating that each node is connected to itself, and the final A is calculated. s , and get the edge connection relationship E s , which is the edge set.
[0052] Finally, a semantic type is assigned to each region according to the POI distribution in the region, and the node type set R is obtained. s For each region, we first obtain all POIs in the region, and then assign a semantic type to each region based on the POI category with the highest distribution frequency in the region, which is defined as follows:
[0053]
[0054] in and Respectively represent the number and distribution frequency of POI category j in region i. i Represents the semantic type of region i (node i). The resulting semantic graph G s It can not only reflect the similarity of usage patterns between regions, but also encode the semantic functional attributes of the regions.
[0055] Step 5: Construct a spatiotemporal network block. Based on the distance graph and semantic graph, combine the attribute features and the flow sub-tensors at three time granularities, and obtain the spatiotemporal representation at the time granularity through the spatiotemporal network block.
[0056] Construct a spatio-temporal network block (STN block), such as Figure 2 In the STN block, the graph convolutional neural network and the relationship graph convolutional neural network are first used to process the distance graph and the semantic graph respectively, and the two are fused through the fully connected layer to obtain the spatial representation at a certain time granularity.
[0057]
[0058] in Represents a flow sub-tensor ( or or ), f gcn and f rgcn They represent graph convolutional neural network and relational graph convolutional neural network respectively, and f c is a fully connected layer. Use f gcnTo effectively aggregate the information of adjacent nodes to obtain the geographical connection relationship between regions in the distance graph, in f gcn Residual connections are used to accelerate training convergence, using f rgcn To capture the complex semantic information contained in the semantic graph. gcn and f rgcn After processing, a spatial representation of the urban area network is obtained.
[0059] Then, the non-stationary Transformer (NST) algorithm is used to capture the temporal dependency and obtain the temporal representation at a certain time granularity, which is defined as:
[0060]
[0061] Among them, f NST and f c They represent the non-stationary Transformer layer and the fully connected layer respectively.
[0062] Finally, the date attribute feature Attr date 、Weather attribute characteristics Attr wea With spatial representation and time representation Splice and pass the combined data through the fully connected layer to obtain the spatiotemporal representation
[0063]
[0064] Step 6: Fuse the spatiotemporal representation of data at each time granularity to predict traffic, and perform reverse training to obtain the model.
[0065] First, three STN blocks are used to process the recent sub-tensors separately. Subtensors by daily period Periodic subtensors Obtaining spatiotemporal representation at each time granularity And merge them:
[0066]
[0067] where f c is a fully connected layer.
[0068] Then, the weather forecast information and the date attributes of the corresponding time point are input into the model as external factors to predict the regional flow at the Tth time step. The model output is expressed as:
[0069]
[0070] in is the urban area traffic flow predicted at the Tth time step, including the inflow and outflow, and are the weather attribute features and date attribute features at the Tth time step.
[0071] Finally, L2 loss is used as the loss function, which is defined as follows:
[0072]
[0073] Among them, Y T and They represent the real traffic matrix and predicted traffic matrix at the Tth time step, and θ is a learnable parameter in the network. The model calculates the loss and optimizes the parameters through back propagation. After the model is constructed, the prediction model is used to predict based on the test data to obtain the final regional traffic prediction result.
[0074] Example:
[0075] Regional traffic flow prediction is performed for New York shared bicycle data. The regional center is the location of the shared bicycle station, and the regional boundary is a circular area with a radius of 250 meters centered on the station. To prove the effectiveness of this method, comparative experiments are conducted with commonly used models in existing related technologies, including historical average model (HA), autoregressive integrated moving average model (ARIMA), LSTM, GRU, graph convolutional neural network (GCN), spatiotemporal lightweight graph GRU (STLGRU), attention-based spatiotemporal graph convolutional network (ASTGCN), spatiotemporal adaptive embedding transformer (STAEformer) and spatiotemporal graph neural controlled differential equation (STG-NCDE). The mean absolute error (MAE) and root mean square error (RMSE) are used as measurement indicators. The smaller the values, the better the prediction performance. The experimental results are shown in Table 1. The performance of the method of the present invention is greatly improved compared with other methods, indicating that the method of the present invention can effectively improve the accuracy of prediction by considering multiple time and space granularities.
[0076] Table 1 Performance comparison of different models
[0077]
Claims
1. A method for predicting urban area traffic flow considering multiple spatiotemporal granularities, characterized in that: The following steps are involved: Step 1: Obtain traffic flow dataset, regional dataset, weather dataset and point of interest (POI) dataset; Step 2: Preprocess the data in the traffic flow dataset and construct attribute features; Step 3: Based on the preprocessed traffic flow data, construct the traffic sub-tensors at three time granularities; Step 4: For each region, construct a region association graph, including a distance graph and a semantic graph; Step 5: Construct a spatiotemporal network block. Based on the distance graph and semantic graph, the attribute features and the flow sub-tensors at three time granularities are combined to obtain the spatiotemporal representation at the time granularity through the spatiotemporal network block. Step 6: Fuse the spatiotemporal representations at each time granularity to predict traffic and perform reverse training.
2. The method for predicting urban area traffic flow considering multiple spatiotemporal granularities according to claim 1 is characterized in that: The traffic flow dataset includes a taxi dataset and a shared bicycle dataset, and each record in the dataset includes an entry time, an entry area ID, an exit time, and an exit area ID; Each record in the regional data set includes the regional ID, the longitude and latitude of the regional center and the regional boundary information; The weather data set includes temperature, precipitation and weather conditions; The point of interest (POI) data set includes POI type tags related to locations, and each record includes the longitude and latitude of a location and a corresponding POI type tag.
3. The method for predicting urban area traffic flow considering multiple spatiotemporal granularities according to claim 1 is characterized in that: The specific implementation process of step 2 is as follows: Step 2.1: Summarize the records in the traffic flow dataset hourly according to the entry time to obtain the historical traffic sequence of each area in the city; assuming that the city contains N areas, use represents the regional flow tensor, where T represents the time step length in hours, and X t is the flow matrix of all areas in the city at time t, F represents the number of flow characteristics, including inflow and outflow; Step 2.2: Construct attribute features, including date attribute features Attr date and weather attribute feature Attr wea ; For a time step, Attr date Contains: whether it is a weekday, which hour of the day, which day of the week; Attr wea Includes: temperature, precipitation and weather conditions. Weather conditions are encoded in the form of composite hot coding.
4. The method for predicting urban area traffic flow considering multiple spatiotemporal granularities according to claim 3 is characterized in that: The specific process of constructing the flow sub-tensors at three time granularities is as follows: The temporal pattern of regional traffic flow is defined from three time granularities, including recent pattern, daily cycle pattern, and weekly cycle pattern; the original traffic tensor Organized into three sub-tensors, reflecting these three modes respectively; Assume that t0-1 represents the current time, t0 represents the predicted time point, and the recent sub-tensor Includes the region's traffic in the past few hours, defined as: Where N is the number of regions, F is the number of features, T r is the size of the historical window at adjacent time granularity; Subtensors by daily period It consists of the traffic at the same hour as the forecast time point in the past few days, defined as: Where T d is the size of the historical window at the daily cycle time granularity, that is, the number of past days considered, P d =24, indicating that a day contains 24 hours; Periodic subtensors It consists of traffic in the past few weeks with the same weekly attributes and time points as the prediction time point. Defined as: Where T w is the size of the historical window at the weekly time granularity, that is, the number of past weeks considered; P w =168, which represents the number of hours in a week.
5. The method for predicting urban area traffic flow considering multiple spatiotemporal granularities according to claim 4 is characterized in that: The specific implementation process of constructing the regional association graph is as follows: Step 4.1 Construct a distance map using the distance map G d =(V,E d ,A d ) encodes the geographic connections between regions, represents the set of regional center points and the set of edges (v i ,v j )∈E d Represents the geographical connection between regions, the adjacency matrix A d Each element A d (i,j) is defined as: where dis(i,j) represents the distance between region i and region j, λ d is a predefined distance threshold; norm() represents the normalization operation; if norm(dis(i,j))≤λ d , indicating that the two are geographically adjacent, A d (i,j)=1, that is, (v i ,v j )∈E d , otherwise A d (i,j)=0, that is Step 4.2: Construct a semantic graph using the semantic graph G s =(V,E s ,A s ,R s ) encodes the semantic relationship between regions, represents the set of regional center points, and the edge (v i ,v j )∈E s Represents the semantic connection relationship between regions, A s Represents the adjacency matrix of the semantic graph, R s Represents a collection of node types; First, the Pearson correlation coefficient PCC is used to calculate the similarity between nodes based on the historical traffic patterns of the region; the historical traffic of region i is expressed as Where T is the time step length, and represents the inflow and outflow of region i at time step t, node v i and v j Similarity PCC i,j Defined as: in, and is the average flow rate of area i and area j; Then, based on the regional center point set V and the PCC similarity between nodes, the complex network construction algorithm is used to construct the edge set E of the semantic graph. s ; Finally, a semantic type is assigned to each region according to the POI distribution in the region, and the node type set R is obtained. s ; For each region, first obtain all POIs in the region, and then assign a semantic type to each region based on the POI category with the highest distribution frequency in the region, which is defined as follows: in and Respectively represent the number and distribution frequency of POI category j in region i; R i Represents the semantic type of region i.
6. The method for predicting urban area traffic flow considering multiple spatiotemporal granularities according to claim 5 is characterized in that: The edge set E of the semantic graph constructed by using the complex network construction algorithm s The specific process is as follows: First, A s Initialized to a matrix of all zeros, indicating that all nodes are not connected at the beginning, and each node constitutes a node group; then the node groups are iteratively merged. When the number of node groups is greater than 1, the two most similar node groups are found based on the similarity between node groups. The similarity between node groups is defined as the maximum value of the PCC similarity between each pair of nodes in the groups. The most similar k pairs of nodes are selected from the two node groups if their PCC similarity is greater than the threshold λ. s , then A s The corresponding position in is set to 1, indicating that the two nodes are connected; the two node groups with the highest similarity found are merged into one, and the similarity between each node group is updated; when the number of node groups is 1, the iterative merging operation is stopped; finally, A s The diagonal value of is set to 1, indicating that each node is connected to itself, and the final A is calculated. s , and get the edge connection relationship E s , which is the edge set.
7. The method for predicting urban area traffic flow considering multiple spatiotemporal granularities according to claim 6 is characterized in that: The specific implementation process of step 5 is as follows: Construct a spatiotemporal network block STN block; in the STN block, firstly use the graph convolutional neural network and the relationship graph convolutional neural network to process the distance graph and the semantic graph respectively, and then fuse the two through the fully connected layer to obtain the spatial representation at a certain time granularity in Represents a flow subtensor: or or f gcn and f rgcn They represent graph convolutional neural network and relational graph convolutional neural network respectively, and f c is a fully connected layer; in f gcn Residual connections are used to accelerate training convergence and integrate f gcn and f rgcn After processing, a spatial representation of the urban area network is obtained; Then, the non-stationary Transformer algorithm NST is used to capture the temporal dependency and obtain the temporal representation at a certain time granularity, which is defined as: Among them, f NST and f c Represent the non-stationary Transformer layer and the fully connected layer respectively; Finally, the date attribute feature Attr date 、Weather attribute characteristics Attr wea With spatial representation and time representation Splice and pass the combined data through the fully connected layer to obtain the spatiotemporal representation 8. The method for predicting urban area traffic flow considering multiple spatiotemporal granularities according to claim 7 is characterized in that: The specific process of predicting traffic by fusing the spatiotemporal representation of data at each time granularity is as follows: First, use three STN blocks to process the recent sub-tensors separately Subtensors by daily period Periodic subtensors Obtaining spatiotemporal representation at each time granularity And merge: Then, the weather forecast information and the date attributes of the corresponding time point are input into the model as external factors to predict the regional flow at T time steps. The output is expressed as: in is the urban area traffic flow predicted at the Tth time step, including the inflow and outflow, and are the weather attribute features and date attribute features at the Tth time step.
