Long-term urban flow prediction method based on out-of-distribution data
Through causal inference and graph convolutional neural network technology, it solves the problem of distribution offset in long-term urban traffic prediction, achieves more accurate and robust prediction, can handle complex time dynamics and environmental changes, and improves the stability of prediction. and accuracy.
Patent Information
- Application Number
- CN202410871492.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-10-29
AI Technical Summary
Existing technologies are difficult to effectively deal with the distribution shift problem in long-term urban flow prediction, resulting in model performance degradation when dealing with temporal dynamics and environmental changes, especially when complex factors such as urban planning and socioeconomic changes are involved.
Adopt causal inference and causal intervention technology, combined with graph convolutional neural network, to mine the potential causal relationship between urban traffic and interest point distribution, eliminate the confusing influence of contextual factors and false interest points, and predict future traffic through causal adjustment and multi-layer perceptron .
It achieves more accurate and robust long-term urban traffic prediction under distribution offset scenarios, can fairly consider the influence of contextual factors, reduces the confusion of prediction by false interest points, and improves prediction accuracy by integrating long-term and short-term factors.
Smart Images

Figure CN118863136A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of pattern analysis, and in particular to a long-term urban flow prediction method based on out-of-distribution data. Background Art
[0002] With the continuous development of intelligent technology and big data analysis, urban flow prediction plays an increasingly important role in urban planning, traffic management, and commercial operations. Accurate urban flow prediction can not only optimize resource allocation, but also improve urban traffic conditions, improve commercial operation efficiency, and thus enhance the overall management level of the city. In recent years, research on urban flow prediction has achieved remarkable results. However, current prediction methods usually assume that training data and test data come from the same distribution, ignoring a widespread problem: pedestrian flow data is easily affected by temporal dynamics and presents diverse data distributions over time. This phenomenon is called distribution shift, and data with distribution shift is also called out-of-distribution data. The existence of distribution shift makes the performance of the model often significantly degrade when processing data with a long time span. Therefore, understanding and solving the distribution shift problem in pedestrian flow prediction has become the key to improving prediction accuracy and robustness. By deeply studying the influencing factors and mechanisms of distribution shift, developing a prediction model that can adapt to different temporal dynamics and environmental changes, it can more effectively cope with complex situations in practical applications. This is not only of great significance for academic research, but also provides a solid theoretical foundation and technical support for practical applications, which helps to achieve more efficient urban management and operation.
[0003] Some existing studies have also begun to focus on the distribution shift problem. For example, Xia and Deng et al. attributed the distribution shift to the temporal environment or contextual conditions (such as weather, events, etc.) and mitigated the impact of the distribution shift through causal analysis. These studies provide valuable insights and methods for solving the distribution shift problem of short-term traffic.
[0004] However, these studies mainly focus on the problem of distribution shift in the short term, and pay less attention to the distribution shift problem in long-term crowd flow prediction. Long-term prediction involves more complex temporal dynamics and wider environmental changes, and existing methods have significant limitations in dealing with these complexities. In long-term crowd flow prediction, distribution shift involves not only short-term factors such as weather and events, but also includes the influence of multiple factors such as changes in urban planning, infrastructure development, and the evolution of socioeconomic conditions. These factors will cause gradual changes in data distribution over time, challenging the accuracy and robustness of the model in long-term prediction. Summary of the invention
[0005] The purpose of the present invention is to address the problems existing in the above-mentioned prior art and provide a long-term urban traffic prediction method based on out-of-distribution data, which is applicable to out-of-distribution data, utilizes causal inference technology and causal intervention technology, combined with graph convolutional neural network, to explore the potential causal relationship between urban traffic and point of interest distribution, eliminate the confusing effects of contextual factors and false points of interest, and achieve accurate prediction in distribution deviation scenarios.
[0006] The technical solution to achieve the purpose of the present invention is: a long-term urban traffic prediction method based on out-of-distribution data, the method comprising the following steps:
[0007] Step 1, obtaining city data and preprocessing the data to eliminate noise data; the city data includes city traffic data and city point of interest data;
[0008] Step 2: Divide the city into grid areas of equal size and construct a geographic distance map A based on the distance between the areas. geo ;
[0009] Step 3, calculating the prior distribution and posterior distribution of the context factor based on causal inference;
[0010] Step 4: Use the STGCN-based context-specific encoder to learn spatiotemporal sequence representations of different contexts;
[0011] Step 5, based on backdoor adjustment, the confounding effect of contextual factors on the prediction is eliminated in the spatiotemporal series representation to obtain the seasonal partial representation;
[0012] Step 6, using an evolutionary learner based on gated recurrent units and graph neural networks to learn the evolutionary pattern of urban data distribution;
[0013] Step 7: Use a causal dependency learner based on a linear cross-attention mechanism to learn the potential causal influence of the evolution of urban data;
[0014] Step 8: Use causal adjustment to reduce the impact between false points of interest and traffic, and obtain partial representation of the trend;
[0015] Step 9: Combine the seasonal partial representation and the trend partial representation to predict future traffic using a multi-layer perceptron.
[0016] Furthermore, the geographic distance map A between the constructed areas in step 2 geo , the formula is:
[0017]
[0018] Where 1≤i,j≤N, N represents the number of grid areas, dis ijrepresents the geographic distance between grid area i and grid area j, σ is the variance of the static geographic distance map, and ε geo is the distance threshold, Represents the value of the i-th row and j-th column in the geographic distance map.
[0019] Furthermore, the prior distribution and posterior distribution of the context factor are calculated based on causal inference in step 3, and the calculation formula is:
[0020] sc=Softmax(x t W.C.
[0021] In the formula, Softmax represents the activation function, x t represents the city traffic at the tth time step, W is the projection matrix, and C represents the representation of the context factor, which is defined as a discrete variable F is the number of context factors, c F is the Fth discrete context factor, and D′ is the feature dimension.
[0022] If you enter x t When it is urban traffic data, the calculated sc is the posterior distribution of the context factor;
[0023] If you enter x t is a randomly generated pseudo sequence, and the calculated sc is the prior distribution of the context factor.
[0024] Furthermore, step 4 uses a context-specific encoder based on STGCN to learn spatiotemporal sequence representations of different contexts, which is specifically expressed as:
[0025]
[0026] In the formula, h t represents the hidden state of the sequence at the current timestamp, c is the context factor of the current timestamp, and h′ t represents the hidden state of the sequence at the next time stamp, Θ is the model parameter; encoder It is the classic spatiotemporal modeling model STGCN; STGCN is expressed as follows:
[0027]
[0028] In the formula, v l 、v l+1 are the inputs of block l and block l+1 respectively, represents the first temporal convolution in the lth spatiotemporal block, represents the second temporal convolution in the lth spatiotemporal block, both of which share the same structure, Θ *G represents spectral convolution, ReLU is the activation function;
[0029] Temporal Convolution is defined as follows:
[0030]
[0031] The input X is divided into two parts of equal size, P and Q, which are used as the input of the gated linear unit; ⊙ is the Hadamard product, σ(·) is the Sigmod function;
[0032] The spectral graph convolution Θ *G is defined as follows:
[0033]
[0034] In the formula, θ is a parameter, I is the identity matrix, W represents the geographic distance matrix; yes The node degree matrix is a diagonal matrix with the element values on the diagonal being express The value in the i-th row and j-th column of .
[0035] Furthermore, the backdoor adjustment described in step 5 eliminates the confusing effect of context factors on prediction in the spatiotemporal sequence representation, specifically:
[0036]
[0037] In the formula, sc i is the probability of the i-th context factor, h″ t It is the representation of the t-th timestamp after backdoor adjustment;
[0038] Connect the representations of T timestamps after backdoor adjustment to get the output representation of the season part h seasonal =[h" t-T ,..,h″ t-1 , h″ t ].
[0039] Furthermore, in step 6, learning the evolutionary pattern of urban data distribution using an evolutionary learner based on a gated recurrent unit and a graph neural network specifically includes:
[0040] The evolutionary learner GraphGRU is expressed as:
[0041] z t =σ(Θ z*G (x t ||h t-1 ))
[0042] r t=σ(Θ r*G (x t ||h t-1 ))
[0043] h′ t =tanh(Θ h*G (x t ||(r t ⊙h t-1 ))
[0044] h t =z t ⊙h t-1 +(1-z t )⊙h′ t
[0045] In the formula, x t represents the input at timestamp t, h t-1 represents the hidden state at the t-1 timestamp, ⊙ represents the Hadamard product, σ(·) represents the Sigmod activation function, Θ z*G , Θ r*G and θ h*G are learnable graph convolution parameters; *G represents the graph convolution operator, which is defined as follows:
[0046]
[0047] Where L1 is the number of layers of graph convolution, W k are model parameters, α0 and α1 are weights, represents the input of the kth layer at the tth timestamp, is the output of the t-th timestamp, represents a symmetric normalized matrix, which is defined as follows:
[0048]
[0049] Where L = A geo +I, where is the degree matrix of matrix L, I is the identity matrix;
[0050] The city traffic and POI distribution are input into the evolution learner respectively to obtain the corresponding traffic evolution representation h f and interest point evolution representation h p .
[0051] Furthermore, in step 7, the potential causal influence of the evolution of urban data is learned by using a causal dependency learner based on a linear cross attention mechanism. The specific process includes:
[0052] Step 7-1, characterize the flow evolution h f and interest point evolution representation hp Input into the causal dependency learner to learn causal dependency and obtain the causal dependency score Atten, which is defined as follows:
[0053]
[0054] Among them, W1 and W2 are learnable weights, σ is the activation function, and L2 represents the number of layers of MLP.
[0055] Step 7-2: Use the Softmax function to calculate the causal weight C of the interest point category on the regional flow of people type :
[0056] C type =Softmax(Atten)
[0057] Step 7-3, perform Avg_pool along the POI category dimension to obtain the causal weight C of the POI period on the regional flow of people period , expressed as:
[0058] C period =Softmax(Avg_pool(C type )).
[0059] Furthermore, in step 8, the influence between false points of interest and traffic is reduced by using causal adjustment to obtain an output representation of the trend part, which specifically includes:
[0060] Step 8-1, obtain the causal interest point representation h′ based on causal adjustment p :
[0061] h′ p =W3C type h p +W4C Period h p
[0062] Where W3 and W4 represent the transformation matrix respectively.
[0063] Step 8-2: Connect the causal interest point representation and the traffic evolution representation to obtain the trend part representation h trend :
[0064] h trend =h f +h′ p .
[0065] Furthermore, the step 9 combines the seasonal partial representation and the trend partial representation to predict future traffic using a multi-layer perceptron, specifically including:
[0066] Step 9-1, obtain the comprehensive representation H based on the seasonal partial representation and the trend partial representation:
[0067] H=h trend +h seasonal
[0068] Step 9-2, use the multilayer perceptron as a predictor to get the prediction result
[0069]
[0070] Where Predictor is a multilayer perceptron and θ is the parameter of the predictor.
[0071] Compared with the prior art, the present invention has the following significant advantages:
[0072] 1) The impact of contextual factors and POI evolution on long-term urban traffic prediction is explored from a causal perspective, resulting in more precise prediction accuracy and stronger robustness when facing out-of-distribution data.
[0073] 2) In response to the confounding effects caused by contextual factors, it is proposed to use causal inference to learn its prior and posterior distributions, and use backdoor adjustment to eliminate the confounding effects caused by contextual factors, so that the model can fairly consider the impact of each contextual factor and better cope with contextual factors with extreme distributions.
[0074] 3) A causal dependency learner based on a linear cross-attention mechanism is used to learn the potential causal influence of urban traffic and POI distribution. The impact of confusing POI on prediction is reduced through causal adjustment, so that the model can eliminate statistical confusion and accurately understand the impact of changes in POI distribution on urban traffic.
[0075] 4) Combining two causally adjusted trend representations and seasonal representations to predict future urban traffic, integrating long-term and short-term factors to better cope with changes and fluctuations.
[0076] The present invention is further described in detail below in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] Figure 1 This is a flow chart of the long-term urban traffic prediction method based on out-of-distribution data of the present invention.
[0078] Figure 2 This is a schematic diagram of traffic distribution in some areas of the city 1 dataset.
[0079] Figure 3 This is a schematic diagram of traffic distribution in some areas of the City 2 dataset. DETAILED DESCRIPTION
[0080] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0081] It should be noted that if there are descriptions involving "first", "second", etc. in the embodiments of the present invention, the descriptions of "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0082] In one embodiment, in combination Figure 1 , provides a long-term urban traffic prediction method based on out-of-distribution data, the method comprising the following steps:
[0083] Step 1, obtaining city data and preprocessing the data to eliminate noise data; the city data includes city traffic data and city point of interest data;
[0084] The urban traffic data includes the number of nodes, traffic observation values and traffic observation time;
[0085] The city POI data includes POI name, POI category, POI quantity and POI time;
[0086] Step 2: Divide the city into grid areas of equal size and construct a geographic distance map A based on the distance between the areas. geo ;
[0087] Step 3, calculating the prior distribution and posterior distribution of the context factor based on causal inference;
[0088] Step 4: Use the STGCN-based context-specific encoder to learn spatiotemporal sequence representations of different contexts;
[0089] Step 5, based on backdoor adjustment, the confounding effect of contextual factors on the prediction is eliminated in the spatiotemporal series representation to obtain the seasonal partial representation;
[0090] Step 6, using an evolutionary learner based on gated recurrent units and graph neural networks to learn the evolutionary pattern of urban data distribution;
[0091] Step 7: Use a causal dependency learner based on a linear cross-attention mechanism to learn the potential causal influence of the evolution of urban data;
[0092] Step 8: Use causal adjustment to reduce the impact between false points of interest and traffic, and obtain partial representation of the trend;
[0093] Step 9: Combine the seasonal partial representation and the trend partial representation to predict future traffic using a multi-layer perceptron.
[0094] Furthermore, in one embodiment, the data is preprocessed in step 1 to eliminate noise data, and the specific process includes:
[0095] Step 1-1, if a feature in a data record has a null value, delete the data;
[0096] Step 1-2, perform dimensionality reduction on the remaining data;
[0097] Steps 1-3, normalize the remaining data.
[0098] Furthermore, in one embodiment, the step 2 of constructing the geographic distance map A between the regions geo , the formula is:
[0099]
[0100] Where 1≤i, j≤N, N represents the number of grid areas, dis ij represents the geographic distance between grid area i and grid area j, σ is the variance of the static geographic distance map, and ε geo is the distance threshold, Represents the value of the i-th row and j-th column in the geographic distance map.
[0101] Furthermore, in one embodiment, the prior distribution and posterior distribution of the context factor are calculated based on causal inference in step 3, and the calculation formula is:
[0102] sc=Softmax(x t W.C.
[0103] In the formula, Softmax represents the activation function, x t represents the city traffic at the tth time step, W is the projection matrix, and C represents the representation of the context factor, which is defined as a discrete variable F is the number of context factors, c F is the Fth discrete context factor, and D′ is the feature dimension.
[0104] If you enter x tWhen it is urban traffic data, the calculated sc is the posterior distribution of the context factor;
[0105] If you enter x t is a randomly generated pseudo sequence, and the calculated sc is the prior distribution of the context factor.
[0106] Further, in one of the embodiments, step 4 uses a context-specific encoder based on STGCN to learn spatiotemporal sequence representations of different contexts, which is specifically expressed as:
[0107]
[0108] In the formula, h t represents the hidden state of the sequence at the current timestamp, c is the context factor of the current timestamp, and h′ t represents the hidden state of the sequence at the next time stamp, Θ is the model parameter; encoder It is the classic spatiotemporal modeling model STGCN; STGCN is expressed as follows:
[0109]
[0110] In the formula, v l 、v l+1 are the inputs of block l and block l+1 respectively, represents the first temporal convolution in the lth spatiotemporal block, represents the second temporal convolution in the lth spatiotemporal block, both of which share the same structure, Θ *G represents spectral convolution, ReLU is the activation function;
[0111] Temporal Convolution is defined as follows:
[0112]
[0113] The input X is divided into two parts of equal size, P and Q, which are used as the input of the gated linear unit; ⊙ is the Hadamard product, σ(·) is the Sigmod function;
[0114] The spectral graph convolution Θ *G is defined as follows:
[0115]
[0116] In the formula, θ is a parameter, I is the identity matrix, W represents the geographic distance matrix; yes The node degree matrix is a diagonal matrix with the element values on the diagonal being express The value in the i-th row and j-th column of .
[0117] Further, in one embodiment, the backdoor adjustment in step 5 is based on eliminating the confusing effect of context factors on prediction in the spatiotemporal sequence representation, specifically:
[0118]
[0119] In the formula, sc i is the probability of the i-th context factor, h″ t It is the representation of the t-th timestamp after backdoor adjustment;
[0120] Connect the representations of T timestamps after backdoor adjustment to get the output representation of the season part h seasonal =[h" t-T ,..,h″ t-1 , h″ t ].
[0121] Furthermore, in one embodiment, the step 6 of learning the evolutionary pattern of urban data distribution using an evolutionary learner based on a gated recurrent unit and a graph neural network specifically includes:
[0122] The Graph Gate Recurrent Unit (GraphGRU) is represented as:
[0123] z t =σ(Θ z*G (x t ||h t-1 ))
[0124] r t =σ(Θ r*G (x t ||h t-1 ))
[0125] h′ t =tanh(Θ h*G (x t ||(r t ⊙h t-1 ))
[0126] h t =z t ⊙h t-1 +(1-z t )⊙h′ t
[0127] In the formula, x t represents the input at timestamp t, h t-1represents the hidden state at the t-1 timestamp, ⊙ represents the Hadamard product, σ(·) represents the Sigmod activation function, Θ z*G , Θ r*G and θ h*G are learnable graph convolution parameters; *G represents the graph convolution operator, which is defined as follows:
[0128]
[0129] Where L1 is the number of layers of graph convolution, W k are model parameters, α0 and α1 are weights, represents the input of the kth layer at the tth timestamp, is the output of the t-th timestamp, represents a symmetric normalized matrix, which is defined as follows:
[0130]
[0131] Where L = A geo +I, where is the degree matrix of matrix L, I is the identity matrix;
[0132] The city traffic and POI distribution are input into the evolution learner respectively to obtain the corresponding traffic evolution representation h f and interest point evolution representation h p .
[0133] Further, in one embodiment, the step 7 uses a causal dependency learner based on a linear cross attention mechanism to learn the potential causal influence of the evolution of urban data, and the specific process includes:
[0134] Step 7-1, characterize the flow evolution h f and interest point evolution representation h p Input into the causal dependency learner to learn causal dependency and obtain the causal dependency score Atten, which is defined as follows:
[0135]
[0136] Among them, W1 and W2 are learnable weights, σ is the activation function, and L2 represents the number of layers of MLP.
[0137] Step 7-2: Use the Softmax function to calculate the causal weight C of the interest point category on the regional flow of people type :
[0138] C type =Softmax(Atten)
[0139] Step 7-3, perform Avg_pool along the POI category dimension to obtain the causal weight C of the POI period on the regional flow of people period , expressed as:
[0140] C period =Softmax(Avg_pool(C type )).
[0141] Further, in one embodiment, the step 8 uses causal adjustment to reduce the influence between false points of interest and traffic to obtain an output representation of the trend part, specifically including:
[0142] Step 8-1, obtain the causal interest point representation h′ based on causal adjustment p :
[0143] h′ p =W3C type h p +W4C Period h p
[0144] Where W3 and W4 represent the transformation matrix respectively.
[0145] Step 8-2: Connect the causal interest point representation and the traffic evolution representation to obtain the trend part representation h trend :
[0146] h trend =h f +h′ p .
[0147] Further, in one embodiment, the step 9 combines the seasonal partial representation and the trend partial representation to predict future traffic using a multi-layer perceptron, specifically including:
[0148] Step 9-1, obtain the comprehensive representation H based on the seasonal partial representation and the trend partial representation:
[0149] H=h trend +h seasonal
[0150] Step 9-2, use the multilayer perceptron as a predictor to get the prediction result
[0151]
[0152] Where Predictor is a multilayer perceptron and θ is the parameter of the predictor.
[0153] In one embodiment, a long-term urban traffic prediction system based on out-of-distribution data is provided, the system comprising:
[0154] The first module is used to obtain urban data and pre-process the data to eliminate noise data; the urban data includes urban traffic data and urban point of interest data;
[0155] The second module is used to divide the city into grid areas of equal size and construct a geographic distance map Ageo based on the distance between the areas;
[0156] The third module is used to calculate the prior distribution and posterior distribution of context factors based on causal inference;
[0157] The fourth module is used to learn spatiotemporal sequence representations of different contexts using a context-specific encoder based on STGCN;
[0158] The fifth module is used to eliminate the confounding effect of contextual factors on prediction in the spatiotemporal series representation based on backdoor adjustment to obtain seasonal partial representation;
[0159] The sixth module is used to learn the evolutionary pattern of urban data distribution using an evolutionary learner based on gated recurrent units and graph neural networks;
[0160] The seventh module is used to learn the potential causal influence of urban data evolution using a causal dependency learner based on a linear cross-attention mechanism;
[0161] The eighth module is used to reduce the influence between false points of interest and traffic by using causal adjustment to obtain partial representation of the trend;
[0162] The ninth module is used to combine the seasonal partial representation and the trend partial representation to predict future traffic using a multi-layer perceptron.
[0163] For the specific limitations of the long-term urban traffic prediction system based on out-of-distribution data, please refer to the limitations of the long-term urban traffic prediction method based on out-of-distribution data mentioned above, which will not be repeated here. Each module in the above-mentioned long-term urban traffic prediction system based on out-of-distribution data can be implemented in whole or in part through software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0164] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following is achieved:
[0165] Step 1, obtaining city data and preprocessing the data to eliminate noise data; the city data includes city traffic data and city point of interest data;
[0166] Step 2: Divide the city into grid areas of equal size and construct a geographic distance map A based on the distance between the areas. geo ;
[0167] Step 3, calculating the prior distribution and posterior distribution of the context factor based on causal inference;
[0168] Step 4: Use the STGCN-based context-specific encoder to learn spatiotemporal sequence representations of different contexts;
[0169] Step 5, based on backdoor adjustment, the confounding effect of contextual factors on the prediction is eliminated in the spatiotemporal series representation to obtain the seasonal partial representation;
[0170] Step 6, using an evolutionary learner based on gated recurrent units and graph neural networks to learn the evolutionary pattern of urban data distribution;
[0171] Step 7: Use a causal dependency learner based on a linear cross-attention mechanism to learn the potential causal influence of the evolution of urban data;
[0172] Step 8: Use causal adjustment to reduce the impact between false points of interest and traffic, and obtain partial representation of the trend;
[0173] Step 9: Combine the seasonal partial representation and the trend partial representation to predict future traffic using a multi-layer perceptron.
[0174] For the specific limitations of each step, please refer to the limitations of the long-term urban traffic prediction method based on out-of-distribution data mentioned above, which will not be repeated here.
[0175] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the computer program implements:
[0176] Step 1, obtaining city data and preprocessing the data to eliminate noise data; the city data includes city traffic data and city point of interest data;
[0177] Step 2: Divide the city into grid areas of equal size and construct a geographic distance map A based on the distance between the areas. geo ;
[0178] Step 3, calculating the prior distribution and posterior distribution of the context factor based on causal inference;
[0179] Step 4: Use the STGCN-based context-specific encoder to learn spatiotemporal sequence representations of different contexts;
[0180] Step 5, based on backdoor adjustment, the confounding effect of contextual factors on the prediction is eliminated in the spatiotemporal series representation to obtain the seasonal partial representation;
[0181] Step 6, using an evolutionary learner based on gated recurrent units and graph neural networks to learn the evolutionary pattern of urban data distribution;
[0182] Step 7: Use a causal dependency learner based on a linear cross-attention mechanism to learn the potential causal influence of the evolution of urban data;
[0183] Step 8: Use causal adjustment to reduce the impact between false points of interest and traffic, and obtain partial representation of the trend;
[0184] Step 9: Combine the seasonal partial representation and the trend partial representation to predict future traffic using a multi-layer perceptron.
[0185] For the specific limitations of each step, please refer to the limitations of the long-term urban traffic prediction method based on out-of-distribution data mentioned above, which will not be repeated here.
[0186] As a specific example, in one of the embodiments, the present invention is further verified and explained.
[0187] In this embodiment, the city 2 map query trajectory dataset and the city 1 taxi dataset and their corresponding point of interest datasets are selected to test the model of the present invention. The city 2 map query trajectory dataset contains 35,280 records, a total of 160 observation nodes, from June 2012 to October 2016, each record includes the flow record value of each observation node, and its corresponding point of interest dataset includes 60 records from October 2011 to October 2016, with a total of 5 types of points of interest. The city 1 taxi dataset includes 10,241 records, a total of 185 observation nodes, from July 2018 to October 2019, each record includes the flow record value of each observation node, and its corresponding point of interest dataset includes 25 records from October 2017 to October 2019, with a total of 7 types of points of interest. The dataset is divided by time, and the ratio of training set, test set and validation set is 7:2:1. In the model, the potential representation dimension of urban traffic and points of interest is set to 64, the number of context factors is set to 7 on the city 2 dataset, and the number of context factors is set to 5 on the city 1 dataset. In this embodiment, the traffic data of the past 14 days is used to predict the traffic of the next 7 days and 14 days. The mean absolute error (MAE), root mean square error (RMSE) and mean absolute percentage error (MAPE) are used to evaluate the performance of the model.
[0188] Figure 2 and Figure 3The data distribution of the two datasets is shown, and the existence of the distribution shift problem can be clearly seen.
[0189] This embodiment selects different popular traffic prediction methods as comparison methods to conduct comparative experiments: historical average HA, spatiotemporal graph convolution network STGCN, GWNT based on adaptive dependency matrix, STSGCN based on spatiotemporal synchronization mechanism, AGCRN based on graph convolution and gated recurrent unit, MTGNN, a general neural network for multivariate time series, STGODE based on tensor ordinary differential equations, and CauSTG based on spatiotemporal causal learning framework. The method of the present invention is denoted as DeCau.
[0190] Tables 1 and 2 show the experimental results of different methods for urban traffic prediction on the City 1 dataset and City 2 dataset.
[0191] Table 1 Performance comparison of different methods on the city 1 dataset
[0192]
[0193] Table 2 Performance comparison of different methods on the city 2 dataset
[0194]
[0195]
[0196] It can be seen from Table 1 and Table 2 that the performance of the present invention on the city 1 and city 2 data sets is substantially better than that of other models, which demonstrates the advancement of the model proposed in the present invention. From the table, we can see that: (1) HA has the worst performance because it uses the average of historical data as the prediction result and cannot capture the complex dynamic changes and correlations in the data; (2) STGNN-based methods, such as STGCN and STSGCN, show good results in experimental results because they capture the temporal and spatial dependencies in the data; (3) STGNN with adaptive adjacency matrix, such as GWNT and AGCRN, achieves better performance than STGNN with predefined graph structure because the adaptive adjacency matrix can capture the hidden dependencies between nodes; (4) On the city 1 dataset, among all the baselines, MTGNN achieves the best results in MAE and RMSE indicators, which may be due to its spatiotemporal feature extraction capability and dynamic graph modeling mechanism based on the hybrid jump propagation layer and the temporal convolution module; however, on the MAPE (mean absolute percentage error) indicator, MTGNN performs worse than the CauSTG model, which may be because the CauSTG model learns the invariance of ST observations, so that when the data is offset, such as the minimum value, the model can also guarantee good performance. (5) On the city 2 dataset, CauSTG achieves the best results among the baselines. This is because the distribution shift of the City 2 dataset is larger than that of the City 1 dataset and the traffic fluctuation is large, so the CauSTG model can achieve good results on the City 2 dataset.
[0197] The long-term urban traffic prediction method based on out-of-distribution data proposed by the method of the present invention can alleviate the confusion caused by the highly dynamic contextual factors and slowly changing distribution of points of interest that affect long-term urban traffic through a causal perspective. By using causal intervention and causal adjustment to adjust the seasonal part and the trend part respectively, the model can learn a more fair and non-confused representation. Finally, prediction is made by training the representation of the two parts. By comparing with other related algorithms, it is further verified that the method of the present invention can more robustly predict long-term urban traffic based on out-of-distribution data.
[0198] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, and these changes and improvements all fall within the scope of the present invention to be protected.
Claims
1. A long-term urban traffic prediction method based on out-of-distribution data, characterized in that: The method comprises the following steps: Step 1, obtaining city data and preprocessing the data to eliminate noise data; the city data includes city traffic data and city point of interest data; Step 2: Divide the city into grid areas of equal size and construct a geographic distance map A based on the distance between the areas. geo ; Step 3, calculating the prior distribution and posterior distribution of the context factor based on causal inference; Step 4: Use the STGCN-based context-specific encoder to learn spatiotemporal sequence representations of different contexts; Step 5, based on backdoor adjustment, the confounding effect of contextual factors on the prediction is eliminated in the spatiotemporal series representation to obtain the seasonal partial representation; Step 6, using an evolutionary learner based on gated recurrent units and graph neural networks to learn the evolutionary pattern of urban data distribution; Step 7: Use a causal dependency learner based on a linear cross-attention mechanism to learn the potential causal influence of the evolution of urban data; Step 8: Use causal adjustment to reduce the impact between false points of interest and traffic, and obtain partial representation of the trend; Step 9: Combine the seasonal partial representation and the trend partial representation to predict future traffic using a multi-layer perceptron.
2. The long-term urban traffic prediction method based on out-of-distribution data according to claim 1 is characterized in that: In step 1: The urban traffic data includes the number of nodes, traffic observation values and traffic observation time; The city POI data includes POI name, POI category, POI quantity and POI time; In step 1, the data is preprocessed to eliminate noise data. The specific process includes: Step 1-1, if a feature in a data record has a null value, delete the data; Step 1-2, perform dimensionality reduction on the remaining data; Steps 1-3, normalize the remaining data.
3. The long-term urban traffic prediction method based on out-of-distribution data according to claim 1 is characterized in that: The geographic distance map A between the regions constructed in step 2 geo , the formula is: Where 1≤i,j≤N, N represents the number of grid areas, dis ij represents the geographic distance between grid area i and grid area j, v is the variance of the static geographic distance map, ε geo is the distance threshold, Represents the value of the i-th row and j-th column in the geographic distance map.
4. The long-term urban traffic prediction method based on out-of-distribution data according to claim 1 is characterized in that: The prior distribution and posterior distribution of the context factor are calculated based on causal inference in step 3, and the calculation formula is: sc=Softmax(x t W·C) In the formula, Softmax represents the activation function, x t represents the city traffic at the tth time step, W is the projection matrix, and C represents the representation of the context factor, which is defined as a discrete variable F is the number of context factors, C F is the Fth discrete context factor, and D' is the feature dimension. If you enter x t When it is urban traffic data, the calculated sc is the posterior distribution of the context factor; If you enter x t is a randomly generated pseudo sequence, and the calculated sc is the prior distribution of the context factor.
5. The long-term urban traffic prediction method based on out-of-distribution data according to claim 1 is characterized in that: Step 4 uses the STGCN-based context-specific encoder to learn the spatiotemporal sequence representation of different contexts, which is specifically expressed as: In the formula, h t represents the hidden state of the sequence at the current timestamp, c is the context factor of the current timestamp, and h' t represents the hidden state of the sequence at the next time stamp, Θ is the model parameter; encoder It is the classic spatiotemporal modeling model STGCN; STGCN is expressed as follows: In the formula, v l 、v l+1 are the inputs of block l and block l+1 respectively, represents the first temporal convolution in the lth spatiotemporal block, represents the second temporal convolution in the lth spatiotemporal block, both of which share the same structure. represents spectral convolution, ReLU is the activation function; Temporal Convolution is defined as follows: The input X is divided into two parts of equal size, P and Q, which are used as the input of the gated linear unit; ⊙ is the Hadamard product, and v(·) is the Sigmod function; The spectral convolution Θ* G is defined as follows: In the formula, θ is a parameter, I is the identity matrix, W represents the geographic distance matrix; yes The node degree matrix is a diagonal matrix with the element values on the diagonal being express The value in the i-th row and j-th column of .
6. The long-term urban traffic prediction method based on out-of-distribution data according to claim 5 is characterized in that: The backdoor adjustment described in step 5 eliminates the confusing effects of context factors on prediction in the spatiotemporal sequence representation, specifically: In the formula, sc i is the probability of the i-th context factor, h' t ' is the representation of the tth timestamp after backdoor adjustment; Connect the representations of T timestamps after backdoor adjustment to get the output representation of the season part h seasonal =[h” t-T+1 ,..,h” t-1 ,h” t ].
7. The long-term urban traffic prediction method based on out-of-distribution data according to claim 6 is characterized in that: Step 6 uses an evolutionary learner based on a gated recurrent unit and a graph neural network to learn the evolutionary pattern of urban data distribution, specifically including: The evolutionary learner GraphGRU is expressed as: z t =σ(Θ z*G (x t ||h t-1 )) r t =σ(Θ r*G (x t ||h t-1 )) h’ t =tanh(Θ h*G (x t ||(r t ⊙h t-1 )) h t =z t ⊙h t-1 +(1-z t )⊙h’ t In the formula, x t represents the input at timestamp t, h t-1 represents the hidden state at the t-1 timestamp, ⊙ represents the Hadamard product, σ(·) represents the Sigmod activation function, Θ z*G , Θ r*G and θ h*G are learnable graph convolution parameters; *G represents the graph convolution operator, which is defined as follows: Where L1 is the number of layers of graph convolution, W k are model parameters, α0 and α1 are weights, represents the input of the kth layer at the tth timestamp, is the output of the t-th timestamp, represents a symmetric normalized matrix, which is defined as follows: Where L = A geo +I, where is the degree matrix of matrix L, I is the identity matrix; The city traffic and POI distribution are input into the evolution learner respectively to obtain the corresponding traffic evolution representation h f and interest point evolution representation h p .
8. The long-term urban traffic prediction method based on out-of-distribution data according to claim 7 is characterized in that: Step 7 uses a causal dependency learner based on a linear cross-attention mechanism to learn the potential causal impact of urban data evolution. The specific process includes: Step 7-1, characterize the flow evolution h f and interest point evolution representation h p Input into the causal dependency learner to learn causal dependency and obtain the causal dependency score Atten, which is defined as follows: Among them, W1 and W2 are learnable weights, σ is the activation function, and L2 represents the number of layers of MLP. Step 7-2: Use the Softmax function to calculate the causal weight C of the interest point category on the regional flow of people type : C type =Softmax(Atten) Step 7-3, perform Avg_pool along the POI category dimension to obtain the causal weight C of the POI period on the regional flow of people period , expressed as: C period =Softmax(Avg_pool(C type ))。 9. The long-term urban traffic prediction method based on out-of-distribution data according to claim 8 is characterized in that: In step 8, causal adjustment is used to reduce the impact between false points of interest and traffic, and the output representation of the trend part is obtained, which specifically includes: Step 8-1, obtain the causal interest point representation h' based on causal adjustment p : h’ p =W3C type h p +W4C Period h p Where W3 and W4 represent the transformation matrices respectively. Step 8-2: Connect the causal interest point representation and the traffic evolution representation to obtain the trend part representation h trend : h trend =h f +h′ p 。 10. The long-term urban traffic prediction method based on out-of-distribution data according to claim 9 is characterized in that: Step 9 combines the seasonal partial representation and the trend partial representation to predict future traffic using a multi-layer perceptron, specifically including: Step 9-1, obtain the comprehensive representation H based on the seasonal partial representation and the trend partial representation: H=h trend +h seasonal Step 9-2, use the multilayer perceptron as a predictor to get the prediction result Where Predictor is a multilayer perceptron and θ is the parameter of the predictor.
Citation Information
Cited By
Urban traffic data prediction method based on causal classification depolarization
CN119783921A
