Knowledge-driven traffic prediction method based on knowledge representation model and graph neural network
By constructing a traffic network topology map and using a knowledge representation model and graph neural network to dynamically integrate external factors and traffic characteristics, the problem of low accuracy in existing traffic flow prediction methods is solved, achieving higher prediction accuracy and spatiotemporal feature capture capabilities.
Patent Information
- Application Number
- CN202311088919.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-28
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2043-08-28
AI Technical Summary
Existing traffic flow prediction methods are unable to effectively capture external factors and traffic characteristics, resulting in low accuracy.
We employ a knowledge representation model and graph neural network-based approach. By constructing a traffic network topology map, we use a knowledge embedding model to convert entities and relationships in the traffic knowledge graph into low-dimensional vectors. Combined with a gating feature fusion module and a spatiotemporal joint capture module, we dynamically fuse external factors and traffic features. We also use graph convolutional neural networks (GCN) and dilated causal convolution to capture spatiotemporal features.
It improves the accuracy of traffic prediction models, enables better understanding and utilization of the spatiotemporal correlations in the data, enhances the consideration of the influence of external factors, and improves prediction accuracy.
Smart Images

Figure CN117116048B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of traffic prediction, and in particular to a knowledge-driven traffic prediction method based on a knowledge representation model and a graph neural network. Background Technology
[0002] In today's era of simultaneous urbanization and motorization, alleviating traffic congestion has become a top priority for urban traffic management. Road traffic forecasting, addressing this issue, has significant theoretical and practical value for urban traffic control and management systems. Furthermore, accurate traffic forecasting can strengthen the relationships between vehicles, roads, management departments, and travelers, thereby improving transportation efficiency.
[0003] With the rapid development of intelligent transportation systems, advanced data communication, information, and control technologies are being applied to ground traffic management systems, expanding their scope and improving their real-time performance, accuracy, and efficiency. This allows for the analysis and study of vast amounts of data generated to improve urban traffic conditions. Currently, vehicle-mounted GPS, road sensors, and intelligent traffic cameras are increasingly prevalent on urban roads. These intelligent devices collect data and provide assistance to traffic management systems. Furthermore, many location service websites provide relevant interfaces for researchers to obtain information in the transportation field, such as geographic data, points of interest, road networks, and traffic conditions. Additionally, technologies such as web scraping or NLP (Natural Language Processing) can be used to obtain information on factors closely related to traffic conditions, such as weather data.
[0004] Faced with the increasing informatization and intelligent development of urban transportation, a comprehensive understanding of urban transportation and its role as a prerequisite and core key to problem-solving has become crucial. While intelligent transportation systems are often achieved through data-driven methods, multi-source data fusion remains a pressing challenge. Simply employing data-driven analysis methods ignores prior knowledge and limits the accuracy of results. Therefore, to effectively predict traffic conditions, integrating multi-source data and effectively applying external knowledge is essential. Exploring how to effectively represent urban transportation knowledge and create digital twins of urban transportation to help the public gain a deeper understanding of urban transportation has become an urgent problem to be solved in the development of smart transportation and smart cities. This requires improving the understanding of urban transportation, combining domain knowledge with real-world contexts to enhance the scientific rigor and accuracy of traffic decisions, and utilizing technologies such as digital twins to simulate and model urban transportation to better understand the complexity and influencing factors of the transportation system, providing data support and guidance for decision-makers. Therefore, integrating multi-source data and utilizing external knowledge to promote a comprehensive understanding of urban transportation is key to driving the sustainable development of smart transportation and smart cities.
[0005] The invention patent application with application number 202111465207.2 discloses a traffic prediction method for reconstructing a multi-layer spatiotemporal traffic knowledge graph. The method constructs a traffic knowledge graph road network layer based on traffic road network data of the region to be predicted, and calculates traffic flow prediction values based on real-time traffic data of the region to be predicted, the traffic road network data, and a trained ST-GCN model. The traffic knowledge graph road network layer is reconstructed based on the traffic flow prediction values to obtain a traffic knowledge graph flow layer. The flow data of the traffic knowledge graph flow layer is clustered using the Mean-Shift algorithm to obtain clustered data, and the traffic knowledge graph flow layer is reconstructed based on the clustered data to obtain a traffic knowledge graph function layer. The region to be predicted is functionally divided based on the traffic knowledge graph function layer, and traffic in the region to be predicted is predicted based on the results of the functional division. The aforementioned invention constructs a multi-layered traffic knowledge graph by fusing traffic road network data and real-time traffic data of the area to be predicted. This graph is divided into a road network layer, a flow layer, and a functional layer. The traffic knowledge graph supplements this by sensing information from other nodes, enabling more accurate predictions of short-term traffic flow. However, this invention considers the impact of external factors on traffic conditions by constructing an attribute matrix. Simply relying on the acquired features of external factors and then concatenating them with traffic features cannot fully integrate the relationships between the two. Complex nonlinear relationships may exist between different features, and simple concatenation operations cannot effectively capture these relationships, resulting in a loss of comprehensiveness and effectiveness in the fusion result. Summary of the Invention
[0006] To address the technical problem that existing traffic flow prediction methods cannot effectively capture external factors and traffic characteristics, resulting in low accuracy, this invention proposes a knowledge-driven traffic prediction method based on knowledge representation models and graph neural networks. This method achieves joint capture of temporal and spatial features, thereby improving the accuracy of traffic prediction models.
[0007] To achieve the above objectives, the technical solution of this invention is implemented as follows: a knowledge-driven traffic prediction method based on a knowledge representation model and a graph neural network, comprising the following steps:
[0008] S1: Preprocess the traffic data collected by sensors within a certain time period to obtain traffic features, construct a traffic network topology map based on the location information of sensor nodes, and obtain the dataset.
[0009] S2: Divide the dataset into a training set and a test set;
[0010] S3: View the traffic prediction problem as a learning function based on a deep learning model using a traffic network topology map to calculate the traffic flow characteristics over a future period of time;
[0011] S4: The knowledge embedding model is used to convert entities and relationships in the knowledge graph of the traffic network topology into low-dimensional vectors. The gated feature fusion module of the traffic prediction model adaptively and dynamically fuses and updates external factors with traffic features according to the importance of external factors.
[0012] S5: Input the updated traffic features and the adjacency matrix of the traffic network topology into the graph convolution GCN to obtain the representation vector of the road segment; use the dilated causal convolution of the spatiotemporal joint capture module of the traffic prediction model to jointly capture traffic features at the time and spatial levels and generate the predicted speed.
[0013] S6: Input the training set into the traffic prediction model, train the traffic prediction model according to the loss function, test the traffic prediction model on the test set, and obtain the predicted traffic speed.
[0014] Preferably, traffic data is collected and recorded by sensors in the traffic network at 15-minute intervals. After data cleaning, noise reduction, or missing value supplementation, the traffic data features are extracted as traffic characteristics. The methods for extracting traffic data features are statistical methods, spatiotemporal analysis methods, or machine learning methods.
[0015] The method for constructing a traffic network topology map is as follows: assign a unique number to each sensor node, calculate the distance between adjacent sensor nodes based on the location information of the sensor nodes, and construct the topology of the traffic network based on the distance;
[0016] The dataset is compiled using vehicle speed information captured by sensors and an adjacency matrix constructed by calculating the distances and connections between adjacent sensor nodes in the road network.
[0017] Preferably, the traffic flow characteristic is: y = f(X,A,G); where (X,A,G) is a traffic network topology. The traffic feature matrix of the city contains the feature attributes of traffic information, A represents the adjacency matrix of the traffic network topology, G represents the traffic knowledge graph, and f is the learning function.
[0018] Adjacency Matrix Element A in nm The nth row and mth column of the adjacency matrix A represent the elements in the adjacency matrix A. If there is an adjacency relationship between sensor node n and sensor node m, the (n, m)th and (m, n)th elements of the adjacency matrix A are 1, otherwise they are 0; H represents the number of node attribute features, and N is the number of roads.
[0019] Preferably, the knowledge embedding model TransR pre-trains the constructed traffic knowledge graph as follows:
[0020] X embedding=TransR{(h,r,t)∪(h,att,att_val)};
[0021] Among them, X embedding The semantic representation of the road segment is used to update traffic features and then input into the spatiotemporal joint capture module; (h,r,t) represents the entity-relationship triple, (h,att,att_val) represents the entity-attribute triple, h represents the head entity, t represents the tail entity, r represents the relationship between the head entity and the tail entity, att represents the attribute, and att_val represents the attribute value.
[0022] Preferably, the gated feature fusion module extracts features from dynamic and static factors through one-dimensional dilated convolution and activation functions, and selects features based on the importance of traffic conditions; the spatiotemporal joint capture module combines a gated recurrent network (GRU) and dilated causal convolution to jointly capture spatiotemporal features, using dilated causal convolution to replace the fully connected layer in the GRU to capture feature dependencies in the spatiotemporal dimension; it obtains a larger receptive field through dilated causal convolution to capture long-range dependencies in time-series data; and it captures feature evolution and correlations simultaneously in the temporal and spatial dimensions.
[0023] Preferably, based on the diversity of external factors, external factors are divided into static factors and dynamic factors. Dynamic factors include weather conditions, while static factors include points of interest and road segment relationships. The knowledge embedding model TransR is used to embed the triples of static factors to obtain a static embedding vector X. sev The knowledge embedding model TransR is used to embed the triples of dynamic factors to obtain the dynamic embedding vector X. dev One-dimensional dilated convolution is used to extract traffic features, resulting in updated traffic features: X st =* dc (X sev X t )tanh,X dt =* dc (X dev X t )tanh; where, * dc X represents a one-dimensional dilated convolution operation. t Let X represent the original road segment features, and tanh represent the activation function; then the embedding vector X... sev With X dev Weight information is obtained by selecting features based on the importance of each factor to traffic conditions using an activation function: X s =σX sev X d =σX dev σ is the sigmoid activation function; then the updated traffic features are output.
[0024] Preferably, the graph convolutional network (GCN) captures the topological relationships and features of the traffic network topology graph to construct the graph structure of the traffic network, assigns initial feature representations to nodes and edges, uses graph convolution operations to propagate and aggregate features between nodes, and gradually expands the receptive field of node features through multi-layer stacking.
[0025] The representation vectors of each road segment are obtained through graph convolution GCN: in Let I be an adjacency matrix containing self-connections. N It is the identity matrix. Adjacency matrix The degree matrix, W l Θ represents the trainable weight matrix parameters of the l-th convolutional layer; Θ represents the ReLU function, h′ l+1 h′ represents the node feature matrix of the (l+1)th layer. l This represents the feature matrix of the nodes in the l-th layer, with each row corresponding to the feature vector of a node; in the first layer of the convolution, h′ l Traffic features after passing through the gating feature fusion module
[0026] Preferably, the spatiotemporal joint capture module processes the following steps: It replaces the fully connected layers in a traditional gated recurrent network (GRU) with dilated causal convolution operations to obtain the encoder's hidden state h at the current time. (t) The obtained hidden state h (t) The output is fed into a fully connected layer, which learns the weights and biases to generate prediction speed.
[0027] Preferably, the hidden state h (t) The calculation method is as follows:
[0028]
[0029]
[0030]
[0031] h (t) =u (t) ⊙h (t-1) +(1-u (t) )⊙c (t)
[0032] in,* dc for The dilated causal convolution is defined in [the original text], where ⊙ represents the Hadamard product, and r (t) with u (t)These are the reset and update gates of the GRU, used for selecting or forgetting memories. σ(·) and tanh(·) are both activation functions. X1 (t) with h (t) These are the current traffic status information and output information, h. (t-1) c represents the hidden state information output at time t-1. (t) It is the traffic information stored in the memory unit at the current moment, W u W r W c and b u b r b c These represent the weights and biases of the update gate, reset gate, and memory unit in the GRU during the training process, respectively.
[0033] Preferably, the dilated causal convolution operation is as follows: Where n is the dilation factor used to control the jump distance, k is the convolution kernel size, g(m) represents the filter, x(tn×m) represents the one-dimensional sequence input, and dcc(x,g) represents the result of the dilated causal convolution of the input and the filter at time t;
[0034] The loss function is used to train the model: in, Y represents the predicted velocity. T L represents the actual traffic speed value obtained through road sensors, λ is the regularization hyperparameter, and L... reg This represents the L2 regularization term, which reduces the risk of overfitting and improves generalization ability.
[0035] Compared to traditional traffic flow prediction methods, this invention offers the following advantages: It is applicable to traffic flow prediction tasks in urban transportation, enabling the rational allocation of urban traffic resources and improving urban traffic efficiency. Firstly, this invention employs the TranR knowledge embedding model, a knowledge representation learning method, which learns multiple relation matrices to represent different types of relationships, thus better capturing the complex relationships in traffic data. Secondly, by projecting entities and relationships into different vector spaces, this invention ensures that the representations of different relationships are independent, providing higher interpretability and allowing for a better understanding of the impact of different relationships on traffic prediction. Thirdly, a gated feature fusion module (GFFM) is designed, which adaptively and dynamically updates and fuses external factors with traffic features based on the importance of each part of the external factors. The gating weights explicitly represent the contribution of each feature to the final fusion result, giving the module good interpretability. Compared to traditional traffic flow prediction methods, this invention simultaneously considers the impact of external factors on traffic characteristics and employs a knowledge representation learning method to obtain representation vectors of external factors influencing traffic conditions, thus fully considering the degree of influence of external factors on traffic characteristics. It dynamically fuses and updates traffic characteristics based on the importance of external factors. This invention adaptively fuses and dynamically updates traffic characteristics according to the importance of external factors, thereby better reflecting changes in traffic characteristics and improving the accuracy of the prediction model. Furthermore, this invention uses dilated causal convolutions instead of fully connected layers within gated recurrent units to achieve joint capture of temporal and spatial features, enabling a better understanding and utilization of spatiotemporal correlations in the data, thereby improving the accuracy of the traffic prediction model. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0037] Figure 1 This is a flowchart of the present invention.
[0038] Figure 2 This is a schematic diagram of the model structure of the present invention.
[0039] Figure 3 This is a schematic diagram of the gating feature fusion structure of the present invention.
[0040] Figure 4 This is a schematic diagram of the spatiotemporal feature joint capture structure of the present invention. Detailed Implementation
[0041] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0042] like Figure 1 As shown, a knowledge-driven traffic prediction method based on a knowledge representation model and graph neural network comprises the following steps:
[0043] S1: Preprocess the traffic data collected by sensors within a certain time period to obtain the required features, construct a traffic network topology map based on the location information of sensor nodes, and obtain the dataset.
[0044] The preprocessing process involves collecting and recording traffic data at 15-minute intervals using sensors within the road network, and extracting features from the traffic data samples. First, the raw traffic data is cleaned and processed, including data cleaning, noise reduction, and missing value imputation. Then, desired features, such as average vehicle speed and traffic flow, are extracted using statistical methods, spatiotemporal analysis methods, or machine learning methods. Next, each sensor node is assigned a unique number to ensure each node has a unique identifier for subsequent processing and analysis. Based on the location information of the sensor nodes, the distances between adjacent sensor nodes are calculated. Calculating these distances allows for the construction of the road network topology, revealing the connectivity between roads and traffic flow. Finally, the vehicle speed information captured by the sensors, along with the adjacency matrix constructed by calculating the distances and connectivity between adjacent nodes in the road network, is compiled into a dataset for subsequent modeling.
[0045] S2: Divide the preprocessed dataset into a training set and a test set, which are used to train the model and test the trained model, respectively.
[0046] The training set comprises 80% of the total data in the dataset, while the test set comprises 20%.
[0047] S3: The traffic prediction problem is viewed as a learning function f based on a deep learning model of the traffic network topology to calculate the traffic flow characteristics over a future period: y = f(X, A, G); where X represents the urban traffic feature matrix, containing the feature attributes of traffic information, A represents the adjacency matrix of the traffic network topology, and G represents the traffic knowledge graph. The knowledge graph is represented in the form of relation triples and attribute triples: {head entity, relation, tail entity}, {head entity, attribute, attribute value}. For example, {90217, adjacency, 90218}, {90217, catering services, 9}, and {2015 / 1 / 25 / 10:00, weather, heavy rain} respectively represent that the connection relationship between road segment with road ID 90217 and road segment with road ID 90218 is an adjacency relationship, there are 9 catering service points of interest near road segment with road ID 90217, and the weather condition at 10:00 on January 5, 2015 is heavy rain. Using triples as units, a complete knowledge network is ultimately formed.
[0048] Adjacency matrix in step S3 Where A nm This represents the element in the nth row and mth column of the adjacency matrix A. If sensor node n and sensor node m are adjacent, the (n, m)th and (mn)th elements in the matrix are 1; otherwise, they are 0. This is from the road network topology diagram (X, A, G). Let H be the number of node attribute features and N be the number of roads. Node attributes are the speed information captured for each road segment at 15-minute intervals. The number of node attribute features H and the number of roads N together construct the urban traffic feature matrix.
[0049] S4: The gated feature fusion module adaptively and dynamically combines external factors with traffic feature X based on the importance of the external factors. t The features are then fused and updated. The gating feature fusion module extracts features from dynamic and static factors through one-dimensional dilated convolution and activation functions, and selects features based on the importance of traffic conditions.
[0050] The TransR knowledge embedding model is used to convert entities and relations in the traffic knowledge graph into low-dimensional vectors, and then the semantic relations between entities are measured by the distance between vectors in the vector space.
[0051] The formula for pre-training the constructed traffic knowledge graph using the knowledge embedding model TransR is as follows:
[0052] X embedding =TransR{(h,r,t)∪(h,att,att_val)};
[0053] Among them, X embedding The semantic representation of the road segment is used to subsequently update traffic features and input them into the spatiotemporal network prediction model. (h,r,t) and (h,att,att_val) represent two types of triple representations: entity-relationship and entity-attribute. Here, h represents the head entity, t represents the tail entity, r represents the relationship between the head and tail entities, att represents the attribute of att, and att_val represents the attribute value. The TransR algorithm treats the relationship vector between entities as a vector translation operation from the head entity to the tail entity. For each triple (t1,r,t2), the head and tail entities located in the entity space... The relation is projected into the relation space using a projection matrix. Specifically, for each relation r, a projection matrix is set... To achieve the projection transformation of entities from entity space to relation space: t 1r =t1N r , t 2r =t2N r The corresponding scoring function used to measure the distance between two projection vectors is defined as follows: Here, |·| represents the L2 norm used to calculate vector distance. Specifically, it measures the strength or similarity of the relationship between entities or relations by calculating a score; generally, a higher score indicates a stronger relevance between the entities and relations. Furthermore, constraints need to be imposed on the norms of embeddings t1, r, and t2: ||t1||2≤1, ||r||2≤1, ||t2||2≤1, ||t1N r ||2≤1,||t2N r ||2≤1.
[0054] This invention collected a total of 464,956 triples containing point-of-interest (POI) information, weather information, and road segment relationship information. The TransR algorithm was used to map the entities and relations in the triples to low-dimensional vectors in a vector space to capture the semantic relationships between entities and relations. These vectors were then input into a subsequent gated feature fusion module for prediction. Specifically, these methods typically learn vector representations by optimizing the loss function, making related entities and relations closer in the vector space during training. Through the learned vector representations, the semantic relationships between entities and relations can be reflected in the vector space. Measuring the semantic relationships between entities by the distance between vectors in the vector space can achieve the function of similarity measurement; closer vector representations are semantically more similar and can be used to quickly discover entities similar to a given entity.
[0055] Based on the diversity of external factors, they are categorized into static factors (points of interest, road segment relationships) and dynamic factors (weather conditions). The TransR knowledge embedding model maps the entity and relational semantic information of static and dynamic factors to a vector space. Specifically, the TransR algorithm is used to embed the captured static factor-related triples, such as {90217, catering services, 9}, and road segment relationship-related triples, such as {90217, adjacency, 90218}, into static embedding vectors, denoted as X. sev Similarly, by capturing dynamic factor-related triples, such as {2015 / 1 / 14_13:00, weather, fog}, the TransR algorithm is used for embedding representation to obtain a dynamic embedding vector, and the corresponding embedding vector is represented as X. dev The knowledge embedding of static factors and dynamic factors respectively employs one-dimensional dilated convolution to extract traffic flow features. Due to the multi-scale receptive field of one-dimensional dilated convolution, temporal information across different time spans can be captured using different kernel sizes, effectively extracting the temporal features of traffic flow. Furthermore, one-dimensional dilated convolution features parameter sharing. By sharing kernel weights, the number of parameters that need to be learned can be reduced, thereby decreasing model complexity and accelerating computation. This is crucial when dealing with traffic flow data with large spatial dimensions, improving model efficiency. Subsequently, the sigmoid activation function is used to select features based on the importance of each factor to the traffic situation to obtain weight information. Finally, the module outputs the updated traffic features. By incorporating external factors into traffic features, more accurate information capture is achieved, improving the modeling capability and prediction accuracy of traffic features.
[0056] The knowledge embeddings of static and dynamic factors are respectively represented by embedding vectors X. sev X dev One-dimensional dilated convolution is used to extract features from traffic flow characteristics: X st =* dc (X sev X t )tanh,X dt =* dc (X dev X t )tanh. Among them, * dc X represents a one-dimensional dilated convolution operation. t Let X represent the original road segment features, and tanh represent the activation function. The updated traffic features X are obtained through the above operations. st X dt The embedding vector X sev With X devThe activation function is used to select features based on the importance of each factor to the traffic situation, thereby obtaining weight information: X s =σX sev X d =σX dev σ is the sigmoid activation function. The final output traffic feature is X1. (t) =[X st X s ,X dt X d ].
[0057] like Figure 2 The diagram shows the traffic prediction model structure of the present invention. The overall model framework includes a gating feature fusion module and a spatiotemporal feature joint capture module. First, traffic segment features are fused and updated based on external knowledge. This external knowledge is first represented through knowledge graph triples, and then the embedded representation vector is obtained using the TransR knowledge representation learning algorithm. The knowledge representation method involved is the TransR method in step S4.1, and its pre-training formula for constructing the traffic knowledge graph is: X embedding =TransR{(h,r,t)∪(h,att,att_val)}, where X embedding The semantic representation of a road segment is given by (h,r,t), which represents an entity-relationship triple, and (h,att,att_val) which represents an entity-attribute triple.
[0058] like Figure 3 The diagram shows the structure of the gated feature fusion module of this invention, which includes dilated convolution and feature selection operations. The former can effectively capture local correlation information of the input sequence and improve the model's ability to model time-series data. The latter selects features based on the importance of external factors and can adaptively adjust the weights of different external factors to achieve more accurate feature fusion and traffic feature updates. The knowledge embedding of static and dynamic factors in step S4.2 is represented by X, respectively. sev X dev One-dimensional dilated convolutions are used to extract features from traffic flow characteristics. By expanding the receptive field of the convolution kernel, longer-range contextual information is captured, enabling the model to analyze the input feature sequence more comprehensively. The calculation process is as follows: X st =* dc (X sev X t )tanh,X dt =* dc (X dev X ttanh. The fully connected layer performs linear transformations and dimensionality mapping on the input features, adjusting the dimensions of the input data to a form suitable for subsequent processing, facilitating feature extraction and fusion. The embedding vector X... sev With X dev Feature selection is performed based on the importance of various factors to traffic conditions using the sigmoid function: X s =σX sev X d =σX dev The final output traffic characteristics are:
[0059] S4.3: Use updated traffic features The adjacency matrix A is used as the input to the Graph Convolutional Network (GCN). GCN can capture the topological relationships and features of traffic networks. By constructing a graph structure of the traffic network, initial feature representations are assigned to nodes and edges. Graph convolution operations are used to propagate and aggregate features between nodes. Through multi-layer stacking, the receptive field of node features is gradually expanded, thereby achieving the learning and application of the topological relationships and features of the traffic network. The representation vectors of each road segment can be obtained through GCN: in Let I be an adjacency matrix containing self-connections. N It is the identity matrix. Adjacency matrix The degree matrix, W l Let represent the trainable weight matrix parameters of the l-th convolutional layer. Θ represents the ReLU function, h′ l+1 h′ represents the feature matrix of the nodes in the (l+1)th layer, i.e., the new features after one graph convolution operation. l Let h′ represent the feature matrix of the nodes in the l-th layer, with each row corresponding to the feature vector of a single node. In the first layer of the convolution, h′ l Traffic features after passing through the gating feature fusion module Right now
[0060] S5: Achieve joint capture of traffic features at both the temporal and spatial levels through the spatiotemporal joint capture module.
[0061] S5.1: Updated Traffic Features The adjacency matrix A is first used in step S4.3 to capture the topological relationships and features of the traffic network through graph convolution (GCN) to obtain the representation vectors of each road segment. Then, dilated causal convolution operations are used to replace the fully connected layers in the traditional gated recurrent network (GRU) to obtain the encoder's hidden state h at the current time step. (t) .
[0062] like Figure 4The diagram illustrates the spatiotemporal feature joint capture structure of this invention. This module combines GRU and dilated causal convolution operations to jointly capture spatiotemporal features. Dilated causal convolution replaces the fully connected layers in GRU to capture feature dependencies in the spatiotemporal dimension. Through dilated causal convolution, the module can obtain a larger receptive field, capturing long-range dependencies in time-series data. This module simultaneously captures feature evolution and correlations in both temporal and spatial dimensions.
[0063] The formula for the dilated causal convolution operation used is as follows: Where n is the dilation factor used to control the jump distance, and k is the kernel size. g(m) represents the filter, x(tn×m) represents the one-dimensional sequence input, and dcc(x,g) represents the result of the dilated causal convolution of the input and the filter at time t. The calculation process involves sampling the input at time t and before at intervals of size n-1, then multiplying it with the convolution kernel g(m) to calculate the inner product, thus ensuring that the output is determined by the current input and all previous inputs. The specific calculation process of using dilated causal convolution to replace the fully connected layer in GRU is as follows:
[0064]
[0065]
[0066]
[0067] h (t) =u (t) ⊙h (t-1) +(1-u (t) )⊙c (t)
[0068] in,* dc for The dilated causal convolution is defined in [the original text], where ⊙ represents the Hadamard product, and r (t) with u (t) These are the reset and update gates of the GRU, used for selecting or forgetting memories. σ(·) and tanh(·) are both activation functions. X1 (t) with h (t) These are the current traffic status information and output information, h. (t-1) c represents the hidden state information output at time t-1. (t) It is the traffic information stored in the memory unit at the current moment, W u W r W c and b u b r b cThese represent the weights and biases of the update gate, reset gate, and memory unit in the GRU during the training process, respectively.
[0069] S5.2: The hidden state h obtained through the spatiotemporal feature joint capture module (t) The output is fed to a fully connected layer to generate the predicted velocity. Fully connected layers can learn appropriate weights and biases to transform the high-level feature maps extracted by the preceding neural network layers into the final prediction result. This establishes an effective connection between the abstracted features from the preceding layers and the output target.
[0070] This invention combines Graph Convolutional Networks (GCN), Dilated Causal Convolution, and Gated Recurrent Units (GRUs) to jointly capture spatiotemporal features, enabling more effective processing of graph-structured data and capturing relationships and local structural information between road network nodes. By using a GCN model, the road network is represented as a graph structure to capture relationships and local structural information between nodes. Then, by replacing traditional fully connected layers with Dilated Causal Convolution, joint capture of spatiotemporal features is achieved. Furthermore, the receptive field of the model can be expanded, and contextual information at greater distances can be considered while maintaining causal relationships. By applying Dilated Causal Convolution to spatiotemporal features in graph-structured data, the correlations between road network nodes and local structural information can be better captured, thereby improving the model's ability to model spatiotemporal dynamic changes. This method provides a more effective way to jointly capture spatiotemporal features, thus improving the performance of traffic prediction models.
[0071] S6: Input the training set into the traffic prediction model and train the model according to the loss function: in, Y represents the predicted velocity. T L represents the actual traffic speed value obtained through road sensors, λ is the regularization hyperparameter, and L... reg This represents the L2 regularization term, which reduces the risk of overfitting and improves generalization ability. The model is then tested on the test set.
[0072] During the training phase, the model is trained based on the loss function by obtaining the model's predicted output and the real data samples collected by the sensors.
[0073] This invention provides a knowledge-driven traffic prediction method based on a knowledge representation model and graph neural networks, applicable to traffic flow prediction tasks in the urban traffic field. It can rationally allocate urban traffic resources, improve urban traffic efficiency, and, compared to traditional traffic flow prediction methods, simultaneously consider external factors that significantly influence traffic characteristics. By using a knowledge representation learning method to obtain representation vectors of external factors affecting traffic conditions, it fully considers the degree of influence of external factors on traffic characteristics. Furthermore, this invention adaptively fuses and dynamically updates traffic features based on the importance of external factors, thereby better reflecting changes in traffic characteristics and improving the accuracy of the prediction model. By replacing the fully connected layers within the gated recurrent unit with dilated causal convolution, it achieves joint capture of temporal and spatial features, enabling a better understanding and utilization of the spatiotemporal correlation in the data, thus improving the accuracy of the traffic prediction model.
[0074] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A knowledge-driven traffic prediction method based on a knowledge representation model and a graph neural network, characterized in that, The steps are as follows: S1: preprocessing the traffic data collected by the sensor in a certain period of time to obtain traffic characteristics, constructing a traffic road network topology graph according to the position information of the sensor node, and obtaining a data set; S2: dividing the data set into a training set and a test set; S3: regarding the traffic prediction problem as a learning function based on a deep learning model according to the traffic road network topology graph, and calculating the traffic characteristics in the future period of time; S4: using a knowledge embedding model to convert entities and relationships in the knowledge graph in the traffic road network topology graph into low-dimensional vectors, and through the gating feature fusion module of the traffic prediction model, the external factors and the traffic characteristics are adaptively and dynamically fused and updated according to the importance of the external factors; S5: inputting the updated traffic characteristics and the adjacency matrix of the traffic road network topology graph into the graph convolution GCN to obtain the representation vector of the road section; through the expansion causal convolution of the spatio-temporal joint capture module of the traffic prediction model, the traffic characteristics on the time level and the space level are jointly captured to generate the predicted speed; S6: inputting the training set into the traffic prediction model, training the traffic prediction model according to the loss function, testing the traffic prediction model in the test set, and obtaining the predicted traffic speed.
2. The knowledge representation model and graph neural network based knowledge-driven traffic prediction method according to claim 1, characterized in that, The traffic data is collected and recorded by the sensors in the traffic road network at intervals of 15 minutes, and after data cleaning, denoising or supplementing missing values, the characteristics of the traffic data are extracted as traffic characteristics; The method for extracting the characteristics of the traffic data is: statistical method, spatio-temporal analysis method or machine learning method; The method for constructing the traffic road network topology graph is: assigning a unique number to each sensor node, calculating the distance between adjacent sensor nodes according to the position information of the sensor nodes, and constructing the topology structure of the traffic road network according to the distance; The speed information captured by the sensor and the adjacency matrix constructed by calculating the distance and connection relationship between adjacent sensor nodes in the road network are arranged into a data set.
3. The knowledge representation model and graph neural network based knowledge-driven traffic prediction method according to claim 2, characterized in that, The traffic feature is y=f(X, A, G); wherein (X, A, G) is a traffic network topology graph, The traffic feature matrix representing a city contains characteristic attributes of traffic information, A represents an adjacency matrix of a traffic network topology graph, G represents a traffic knowledge graph, and f is a learning function. adjacency matrix element A in the adjacency matrix nm denotes the element in the nth row and mth column of the adjacency matrix A, the (n, m) and (m, n) elements in the adjacency matrix A are 1 if there is an adjacency relationship between sensor node n and sensor node m, otherwise 0; H represents the number of node attribute features, and N is the number of roads.
4. The knowledge representation model and graph neural network based knowledge-driven traffic prediction method according to claim 3, characterized in that, The knowledge embedding model TransR pre-trains the constructed traffic knowledge graph as follows: X embedding = TransR{(h,r,t)∪(h,att,att_val)}; wherein X embedding represents a semantic representation of a road segment, used to update traffic features and then input into a spatio-temporal joint capturing module; (h, r, t) represents an entity-relation class triple, (h, att, att_val) represents an entity-attribute class triple, h represents a head entity, t represents a tail entity, r represents a relation between the head entity and the tail entity, att represents an attribute, and att_val represents an attribute value.
5. The knowledge representation model and graph neural network based knowledge-driven traffic prediction method according to any one of claims 1-4, characterized in that, The gating feature fusion module extracts features of dynamic and static factors through one-dimensional expansion convolution and activation function, and selects features according to the importance of traffic situation; the spatio-temporal joint capture module combines the gating recurrent network GRU and the expansion causal convolution operation to jointly capture the spatio-temporal features, uses the expansion causal convolution to replace the fully connected layer in the gating recurrent network GRU, and captures the feature dependency relationship in the time and space dimensions; through the expansion causal convolution operation, a larger receptive field is obtained to capture the long-range dependency relationship in the time series data; the feature evolution and correlation are captured in the time and space dimensions.
6. The knowledge representation model and graph neural network based knowledge-driven traffic prediction method according to claim 5, characterized in that, According to the diversity of external factors, the external factors are divided into static factors and dynamic factors, the dynamic factors include weather states, and the static factors include interest points and road segment relationships; a knowledge embedding model TransR is used for embedding representation of the triples of the static factors to obtain static embedding vectors X sev ; a knowledge embedding model TransR is used for embedding representation of the triples of the dynamic factors to obtain dynamic embedding vectors X dev ; one-dimensional expansion convolution is used for feature extraction of the traffic features respectively to obtain updated traffic features: X st = dc (X sev X t )tanh, X dt = dc (X dev X t )tanh; wherein, dc represents a one-dimensional dilated convolution operation, X t represents the original road segment feature, tanh represents an activation function; the embedding vector X sev is input into the embedding layer to obtain the embedding vector X dev The weight information is obtained by an activation function according to the importance of each factor to the traffic situation: X s = σX sev , X d = σX dev ; σ is a sigmoid activation function; then the updated traffic feature X 7. The knowledge representation model and graph neural network based knowledge-driven traffic prediction method according to claim 6, characterized in that, The graph convolution GCN captures the topological relationship of the traffic road network topology graph and constructs the graph structure of the traffic network, assigns initial feature representations to nodes and edges, propagates and aggregates features between nodes through graph convolution operation, and gradually expands the receptive field of node features through multi-layer stacking; The representation vector of each road segment is obtained by graph convolution GCN: wherein is an adjacency matrix containing self-connection, I N is a unit matrix, is a degree matrix of the adjacency matrix W is a degree matrix of the adjacency matrix W l represents the trainable weight matrix parameter of the lth layer convolution; Θ represents a ReLU function, h' l+1 represents the node feature matrix of the l+1th layer. h' l denotes the node feature matrix of the l-th layer, each row corresponds to a node's feature vector; in the first layer of convolution, h' l is the traffic feature after passing through the gating feature fusion module 8. The knowledge representation model and graph neural network based knowledge-driven traffic prediction method according to any one of claims 1-4, 6, 7, characterized in that, The processing procedure of the space-time joint capturing module is as follows: an extended causal convolution operation is used to replace a full connection layer in a traditional gated recurrent unit (GRU) to obtain a hidden state h of an encoder at a current time (t) ; the obtained hidden state h (t) is output to a full connection layer, and the full connection layer generates a predicted speed 9. The knowledge representation model and graph neural network based knowledge-driven traffic prediction method according to claim 8, characterized in that, The hidden state h (t) The calculation method is: h (t) = u (t) ⊙ h (t-1) + (1 - u (t) ) ⊙ c (t) where, ★ dc For The dilated causal convolution defined in the middle, ⊙ represents the Hadamard product, r (t) And u (t) Respectively, the reset gate and the update gate of GRU, used to select or forget the memory, σ(·) and tanh(·) are activation functions, And h (t) Respectively, the traffic state information and the output information at the current time, h (t-1) Indicates the hidden state information output at t-1, c (t) Is the traffic information stored in the memory unit at the current time, W u , W r , W c And b u , b r , b c Respectively, the weights and biases of the update gate, the reset gate and the memory unit in GRU during the training process.
10. The knowledge representation model and graph neural network based knowledge-driven traffic prediction method according to claim 9, characterized in that, The dilated causal convolution operation is: wherein n is a dilation factor for controlling a hop distance, k is a convolution kernel size, g(m) represents a filter, x(t-nxm) represents a one-dimensional sequence input, and dcc(x,g) represents an operation result of the dilated causal convolution of the input and the filter at a time t. The loss function trains the model: where, represents the predicted speed, Y T represents the real traffic speed value obtained by the road sensor, λ is a regularization hyperparameter, L reg represents an L2 regularization term that reduces the risk of overfitting and improves the generalization ability.
Citation Information
Patent Citations
Traffic prediction method and system for multilayer space-time traffic knowledge graph reconstruction
CN114360239A
Metropolitan area traffic flow prediction method based on knowledge graph and depth space-time convolution
CN112687102A
Traffic speed prediction method based on traffic flow data fusion and system
CN113808396A