Subway passenger flow prediction method and device based on multi-scale spatiotemporal graph attention network
By constructing an OD-level urban rail transit knowledge graph and a multi-scale spatiotemporal graph attention network, the problem of predicting large-scale, high-dimensional, sparse OD-level passenger flow data was solved, achieving more accurate passenger flow prediction and improving subway operation efficiency and system efficiency.
Patent Information
- Application Number
- CN202411543931.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-10-31
AI Technical Summary
Existing subway passenger flow forecasting methods are unable to effectively handle large-scale, high-dimensional, sparse OD-level passenger flow data, and are unable to capture spatiotemporal dynamic changes, resulting in low forecast accuracy.
A subway passenger flow prediction method based on multi-scale spatiotemporal graph attention network is adopted. By constructing an OD-level urban rail transit knowledge graph, and combining graph filtering model, spatiotemporal graph attention mechanism and multi-scale LSTM model, historical passenger flow, land use information and OD accessibility data are integrated to capture the complex spatiotemporal relationship and dynamic changes between OD pairs.
It significantly improved the accuracy of OD-level passenger flow forecasting by approximately 4.34%, providing strong data support for the intelligent scheduling of the subway system, reducing energy consumption and operating costs, and promoting the green and intelligent development of urban transportation systems.
Smart Images

Figure CN119494442B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of urban subway passenger flow prediction and management, and particularly relates to a subway passenger flow prediction method and device based on a multi-scale spatio-temporal graph attention network. BACKGROUND
[0002] With the rapid advancement of urbanization, subway systems have become an indispensable mode of public transportation in modern cities. In terms of alleviating urban traffic congestion, improving travel efficiency, and reducing carbon emissions, subway systems have played a key role. However, subway systems face a series of complex challenges in operational management, especially in the context of significant passenger flow growth. How to accurately predict subway passenger flow, optimize resource scheduling, and improve passenger experience has become a difficult problem to be solved. Currently, the passenger flow prediction method of subway systems mainly relies on traditional time series models (such as autoregressive integrated moving average model ARIMA) and regression analysis models. These models are based on historical passenger flow data and can capture short-term fluctuations and trends in passenger flow. However, the main limitation of these traditional models is that they are difficult to handle the inherent nonlinearity and complex spatio-temporal dependence of subway passenger flow data. Passenger flow has significant spatial correlation between different subway stations, and is influenced by many external factors such as weather, holidays, and unexpected events, which makes the prediction of subway passenger flow a highly dynamic and complex problem. In particular, the accuracy of the prediction of OD (Origin-Destination) data between stations is crucial for the scheduling optimization of subway systems.
[0003] With the development of deep learning technology, especially the application of graph neural networks (GNN), researchers have gradually introduced these technologies into the field of subway passenger flow prediction. Deep learning models such as long short-term memory networks (LSTM) and graph convolutional networks (GCN) have shown strong capabilities in modeling complex spatio-temporal dependencies. Graph neural networks can effectively capture the spatial correlation between different stations in the subway network, while recurrent neural networks such as LSTM can better handle long-term dependencies in time series data. Although these models have achieved good results in station-level passenger flow prediction, most existing researches focus on station-level flow prediction, ignoring the fine-grained analysis of OD pairs. In contrast, OD-level prediction not only provides more detailed travel pattern analysis, but also more accurately identifies passenger travel routes, flow trends between stations, and thus provides more targeted scheduling optimization solutions for operators.
[0004] However, OD level passenger flow prediction faces more complex challenges. First, the number of OD pairs increases exponentially with the number of subway stations, resulting in a large amount of data and a significant increase in computational complexity. Second, the passenger flow data of OD pairs is highly sparse, with many OD pairs having almost no passenger flow during off-peak hours, making it difficult for the model to effectively learn the flow patterns under sparse data. In addition, the time volatility of OD passenger flow data is extremely strong, especially between weekdays and weekends, holidays, and different time periods. The dynamic and unpredictable fluctuations increase the requirements for passenger flow prediction models. To address these issues, existing traditional methods such as multiple regression models or simple time series models have been unable to cope with the complexity of subway passenger flow. Therefore, there is an urgent need for a new method that can handle large-scale, high-dimensional sparse data and effectively capture spatio-temporal dynamic changes to improve the accuracy of subway passenger flow prediction and optimize subway operation scheduling.
[0005] After searching, Chinese invention patent publication number CN117592602A discloses a subway passenger flow prediction method and system based on spatio-temporal graph ordinary differential equation, the method comprising the following steps: collecting and processing original subway AFC historical data, using geographic topological information and original historical passenger flow data to construct a set of subway network spatio-temporal relationship graphs; using the processed historical passenger flow and graph set as model input; establishing a new subway passenger flow prediction network, in each spatio-temporal layer, using two time series self-attention modules and time series convolution modules to obtain dynamic multi-scale time dependence between nodes, using tensor-based ordinary differential equations to capture spatial dependence, and feeding the hidden state obtained by each spatio-temporal layer to the output layer through a jump connection to predict future subway passenger flow. The existing patent has the problem of insufficient prediction accuracy.
[0006] How to improve the accuracy of subway passenger flow prediction by fusing knowledge graph and multi-scale spatio-temporal graph attention network model has become a technical problem to be solved. SUMMARY
[0007] The purpose of the present application is to overcome the defects of the prior art and provide a subway passenger flow prediction method and device based on a multi-scale spatio-temporal graph attention network.
[0008] The purpose of the present application can be achieved by the following technical solutions:
[0009] According to one aspect of the present application, a subway passenger flow prediction method based on a multi-scale spatio-temporal graph attention network is provided, the method comprising the following steps:
[0010] Step S1, collecting subway OD pair passenger flow data, subway line network structure data, and land use type data;
[0011] Step S2, constructing an OD-level urban rail transit knowledge graph based on the data of step S1, and calculating node features of the knowledge graph, including calculating historical passenger flow features, calculating land use information, calculating OD pair accessibility, and calculating OD pair correlation;
[0012] Step S3, inputting the node features of the knowledge graph in step S2 into a multi-scale spatio-temporal graph attention network, first filtering the node features, and then updating the node features of the knowledge graph in combination with the output results of the spatio-temporal graph attention mechanism model, wherein the network includes a graph filtering model, a spatio-temporal graph attention mechanism model and a multi-scale LSTM model connected in turn;
[0013] Step S4, inputting the updated node features into the multi-scale LSTM model to output a multi-scale prediction result of the subway passenger flow.
[0014] Preferably, the calculation of the historical passenger flow features includes calculation of historical statistical indicators of each OD pair, and the historical statistical indicators include passenger flow mean and standard deviation in a specific time period, and passenger flow in peak and non-peak periods, wherein the specific time period includes weekday peak, weekday non-peak, weekend peak and weekend non-peak;
[0015] The calculation of the land use information is to calculate the proportion of different types of interest points around the origin station and the terminal station of each OD pair;
[0016] The calculation of the OD pair accessibility includes calculation of the shortest path distance and the number of feasible paths of each OD pair;
[0017] The calculation of the OD pair correlation includes: calculating the nonlinear correlation of the historical passenger flow sequence by kernel canonical correlation analysis method, and constructing the relationship edge of the OD pair based on the correlation threshold, and then constructing the edge features of the knowledge graph.
[0018] Preferably, the graph filtering model is used to extract the features of the knowledge graph, and the spatio-temporal graph attention mechanism model is used to capture the passenger flow correlation between OD pairs and model long-term and short-term passenger flow states.
[0019] Preferably, the process of graph filtering includes:
[0020] First, the degree matrix D is calculated t is the sum of the weights of the edges connected to the node, and the calculation method is as follows:
[0021]
[0022] wherein the degree matrix D t is a diagonal matrix, and each diagonal element D t(p, p) represents the degree of the OD pair node p and neighbor node q, A t (p, q) is the corresponding adjacency matrix, the graph Laplacian L at time point t t is defined as:
[0023]
[0024] The graph filtering process is represented by the following formula:
[0025]
[0026] where W L is the trainable parameter matrix in the graph filtering model, σ represents the activation function, γ is a hyperparameter, x p,t is the feature vector of node p at time t, x' p,t is the result of graph filtering, N is the node set, and T is the timestamp set.
[0027] Preferably, the spatio-temporal graph attention mechanism model learns the node features through spatial attention, temporal attention, and spatio-temporal attention respectively, and then combines the learning results of the three attention mechanisms to obtain the final node feature representation of each node at timestamp t, specifically as follows:
[0028]
[0029] where σ is an activation function, N is a node set, T is a timestamp set, and are the node features of node p at timestamp t learned through spatial attention, temporal attention, and spatio-temporal attention, respectively.
[0030] More preferably, the learning process of the spatial attention on the node features includes: for node p and its neighbor node q, calculating a spatial attention coefficient; normalizing the spatial attention coefficient to obtain the weight of the timestamp, and weighting the node features according to the neighborhood information and the spatial attention coefficient;
[0031] The learning process of the temporal attention on the node features includes: for node p and its neighbor node q, calculating a temporal attention coefficient; normalizing the temporal attention coefficient to obtain the weight of the timestamp, and weighting the node features according to the neighborhood information and the temporal attention coefficient;
[0032] The learning process of the spatio-temporal attention on the node features includes: for node p and its neighbor node q, calculating a spatio-temporal attention coefficient at different times; normalizing the spatio-temporal attention coefficient to obtain the weight of the timestamp, and weighting the node features according to the neighborhood information and the spatio-temporal attention coefficient.
[0033] Preferably, the multi-scale LSTM model comprises a day-level LSTM model and a minute-level LSTM model, respectively used for capturing long-term passenger flow model and short-term passenger flow trend;
[0034] The input of the day-level LSTM model is a day-level spatio-temporal attention weighted feature vector, and the output is a long-term hidden state;
[0035] The input of the minute LSTM model is a minute-level spatio-temporal attention weighted feature vector, and the output is a short-term hidden state.
[0036] More preferably, the multi-scale prediction result of the subway passenger flow output in the step S4 is specifically: predicting the subway passenger flow according to the output results of the minute-level and day-level LSTM, and the formula is:
[0037]
[0038] Wherein, z M and z D are nonlinear functions for mapping the hidden state to the OD passenger flow, and are long-term hidden state and short-term hidden state respectively, and are the subway passenger flow prediction values of day-level and minute-level respectively.
[0039] Preferably, the training of the multi-scale LSTM model uses a joint loss function considering the minute-level and day-level prediction loss, and the formula is:
[0040]
[0041] Wherein, λ M and λ D are the weights of the minute-level prediction loss and the day-level prediction loss , and are the corresponding true value passenger flow of day-level and minute-level respectively, T D and T M are the time set of day-level and minute-level respectively.
[0042] According to another aspect of the present application, an electronic device is provided, comprising a memory and a processor, the memory has a computer program stored thereon, and the processor implements the method when executing the program.
[0043] Compared with the prior art, the present application has the following beneficial effects:
[0044] 1) The application integrates historical passenger flow, land use information and OD accessibility and other multi-source heterogeneous data, introduces knowledge graph to construct node features, effectively enhances the adaptability of the model to sparse data, and enriches the feature representation of OD level; and through the multi-scale spatiotemporal graph attention network, the complex spatiotemporal correlation between OD pairs is accurately captured, and the multi-scale LSTM model can model long-term trends and short-term fluctuations at the same time, solving the problems of data sparsity and strong spatiotemporal dynamics, so that the predicted subway passenger flow is more accurate.
[0045] 2) The application combines three attention mechanisms to learn node features, improves the prediction ability of the model at different time scales, and has higher adaptability and flexibility compared with other algorithms, which can adjust the model according to different spatiotemporal features, and is suitable for all-weather operation demand in complex subway operation environment.
[0046] 3) The method of the application models the long-term and short-term passenger flow dynamics, outputs accurate passenger flow prediction at the day level and minute level, provides strong data support for intelligent scheduling of the subway system, helps the operator to better develop resource allocation and emergency management scheme, and improves the overall operation efficiency of the system.
[0047] 4) The application outputs accurate passenger flow prediction, which helps to reduce the energy consumption and operation cost of the subway system in intelligent scheduling, and promotes the green, intelligent and sustainable development of urban transportation system. BRIEF DESCRIPTION OF DRAWINGS
[0048] Figure 1 The flowchart of the subway passenger flow prediction method in the application is shown;
[0049] Figure 2 The schematic diagram of using knowledge graph to identify the correlation between OD pairs in the application is shown;
[0050] Figure 3 The structure diagram of the multi-scale spatiotemporal graph attention network in the application is shown;
[0051] Figure 4 The comparison diagram of the calculation effect MAPE of the method in the application and other deep learning model methods is shown;
[0052] Figure 5 The comparison diagram of the calculation effect MAPE of the method in the application and other deep learning model methods with time is shown. DETAILED DESCRIPTION
[0053] With reference to the accompanying drawings, the technical solutions in the embodiments of the present application will be clearly and completely described below. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts should fall within the protection scope of the present application.
[0054] To solve the above challenges, the present application proposes a subway passenger flow prediction method based on a multi-scale spatio-temporal graph attention network that integrates a knowledge graph and a MSP-GATNet (multi-scale spatio-temporal graph attention network) deep learning model. The method first constructs an OD pair-based knowledge graph, integrating historical passenger flow patterns, land use information around stations, and OD pair accessibility into a unified graph structure. The introduction of the knowledge graph not only enriches the representation ability of sparse data but also enhances the modeling of spatial dependency, enabling the model to learn effective features from similar OD pairs and alleviating the problem of data sparsity. On this basis, the present application designs a multi-scale spatio-temporal graph attention network (MSP-GATNet), which includes the following core modules: a graph filtering module, a graph attention module, and a multi-scale LSTM model. The graph filtering module is used to extract key features of the OD-level knowledge graph, the graph attention module dynamically adjusts the information propagation between OD pairs to capture the passenger flow correlation between stations, and the multi-scale LSTM model models both long-term and short-term passenger flow dynamics. This model not only effectively handles large-scale OD pair data but also captures the changing patterns of subway passenger flow at different time periods and different spatial scales. Experimental results show that this method significantly outperforms existing benchmark models in OD-level passenger flow prediction accuracy, improving prediction accuracy by about 4.34%. This innovative method not only improves the efficiency of the subway system but also lays a solid foundation for the construction of future intelligent urban transportation systems.
[0055] Embodiment 1
[0056] This embodiment relates to a subway passenger flow prediction method based on a multi-scale spatio-temporal graph attention network, as shown in Figure 1 The method comprises the following steps:
[0057] Step 1: Collecting passenger flow data of subway OD pairs, subway line network structure data, and land use type data (i.e., POI data) within a certain period of time.
[0058] Step 2: Constructing an OD-level urban rail transit knowledge graph that integrates historical passenger flow patterns, land use information, and OD pair accessibility, and constructing node features of the knowledge graph to address the problems of large OD data volume, high sparsity, and strong time variation dynamics.
[0059] Step 3, a multi-scale spatio-temporal graph attention network (MSP-GATNet) is proposed, which includes a graph filtering model and a spatio-temporal graph attention mechanism model, respectively used to extract knowledge graph features and capture passenger flow correlation between OD pairs, and model long-term and short-term passenger flow dynamics.
[0060] Step 4, a multi-scale spatio-temporal graph attention network will be built and used to predict subway passenger flow.
[0061] The process of step 2 includes:
[0062] 1) Calculate historical passenger flow features: based on historical passenger flow data of OD pairs, extract the average and standard deviation of passenger flow, as well as passenger flow statistics of weekdays and weekends, morning and evening peak and non-peak periods, to capture long-term passenger flow patterns and short-term fluctuation trends between OD pairs. In addition, the historical passenger flow data of each timestamp within the previous time window is recorded, which records the actual passenger flow at a specific time interval within a defined historical time period, providing short-term time trends of recent passenger flow dynamics.
[0063] Calculate the historical statistical indicators of each OD pair, which include the passenger flow mean and standard deviation within a specific time period (such as weekday peak, weekday non-peak, weekend peak, weekend non-peak), as well as the passenger flow during peak and non-peak periods. The historical passenger flow mean is represented by , which represents the average number of passengers between OD pairs within a specific time period (such as weekday peak, weekday non-peak, weekend peak, weekend non-peak), and its calculation rule is:
[0064]
[0065] where T t represents the set of all time intervals belonging to a specific time period type t, and |T t | is the number of time intervals in this set. The passenger flow standard deviation is represented by , which measures the volatility and dispersion of passenger flow around the mean within the specified time period type t.
[0066] Passenger flow standard deviation reveals the fluctuation of passenger travel demand in the subway network, and the calculation formula is:
[0067]
[0068] Calculate the historical passenger flow data of each timestamp within the previous time window length: to capture the short-term patterns of OD-level subway passenger flow, the historical passenger flow data of each timestamp within the previous time window length w is defined as:
[0069]
[0070] where, is the historical passenger flow data corresponding to the timestamp i.
[0071] In this way, the historical data not only captures long-term statistical patterns, but also reflects short-term dynamic trends, providing multi-level information for OD-level passenger flow prediction.
[0072] 2) Calculate land use information, by combining the land use type data (including work, residence, education, medical care, business, etc.) within 1 km range of the OD origin and destination stations, add social and economic attributes to the node characteristics of the OD pair, and enrich the information expression of spatial dimension.
[0073] Based on the land use information of the subway OD pair, the proportion of different types of POI (Point of Interest) around the origin and destination stations of each OD pair is considered, and the calculation is as follows:
[0074]
[0075] where, POI l is the set of POIs belonging to land use type l, d(s, poi) represents the distance between station s and POI point poi i s o and s d are the origin and destination stations of the OD pair, respectively.
[0076] 3) Calculate the accessibility of OD pairs, based on the accessibility of subway lines between OD pairs, calculate the shortest path distance and the number of feasible paths, and combine the connectivity between subway stations to represent the spatial accessibility and accessibility of different OD pairs, to strengthen the modeling of the spatio-temporal correlation between OD pairs.
[0077] The travel distance of each OD pair is defined as the sum of the distances between stations along the shortest path in the subway network, calculated using Dijkstra's algorithm, represented as:
[0078]
[0079] where, d(s i ,s j ) is the distance between adjacent stations s i and s j on the shortest path of the OD pair, SP(od) represents the set of adjacent stations on the shortest path of the OD pair.
[0080] Accessibility is defined as the number of feasible paths for each OD pair, provided that the total number of stations on these paths does not exceed the length of the shortest path plus a threshold, represented as
[0081]
[0082] where P(od) is the set of feasible paths for OD pair o d, L(p) is the length of path p, L sp (od) is the shortest path length for OD pair o d, ΔL is the reachability threshold, is a satisfaction function.
[0083] where the specific steps of Dijkstra algorithm are as follows:
[0084] Step a: initialization. For the starting node s, set its distance to itself as 0, i.e. d(s) = 0, indicating that the distance from the starting point to the starting point is 0. For all other nodes v, set their initial distance as infinite d(v) = ∞, indicating that the distance from the starting point to these nodes has not been determined. Use a priority queue to store nodes and their current shortest distances, and initially add the starting point s to the priority queue, which is sorted according to the shortest distance of nodes.
[0085] Step b: select the node with the smallest distance. Take out the node u closest to the starting point from the priority queue (i.e. the node with the smallest distance in the queue), because the shortest path of this node has been determined, and the paths of other nodes will not be updated. If the current minimum distance is infinite, it indicates that the remaining nodes are not reachable, and the algorithm terminates.
[0086] Step c: relaxation operation. For all neighbor nodes v of the current node u, check whether the path through u to v is shorter than the currently known path. If so, update the distance of v:
[0087] d(v) = min(d(v), d(u) + w(u, v))
[0088] where w(u, v) represents the edge weight between nodes u and v. If the distance of v is updated, reinsert v and its new distance into the priority queue.
[0089] Step d: repeat steps b and c. Keep taking out the node with the smallest distance from the priority queue and performing relaxation operation until all nodes are processed or the queue is empty.
[0090] Step e: end. When all nodes have been processed, the shortest paths from the starting point to all other nodes have been found, and the algorithm terminates.
[0091] 4) Calculate OD pair correlation: calculate the nonlinear correlation of historical passenger flow sequence by kernel canonical correlation analysis (KCCA) method, and construct the relationship edge of OD pair based on the correlation threshold, which is used to represent the node association in the knowledge graph. Based on the correlation of OD pair, the edge features of the knowledge graph are constructed.
[0092] The key to identifying the correlation between different OD pairs to build an accurate OD knowledge graph is to use Kernel Canonical Correlation Analysis (KCCA) to explore the correlation between the historical passenger flow sequences of two OD pairs in a high-dimensional feature space. KCCA maps the original input to a high-dimensional feature space to capture more complex nonlinear relationships.
[0093] Let the historical passenger flow sequences of two OD pairs be defined as and where t represents the time step.
[0094] First, use the kernel function φ to map the two sequences to a high-dimensional feature space, obtaining and where φ is the mapping function. Common kernel functions include Gaussian kernel and polynomial kernel, which ensure that sufficient nonlinear features are captured in the high-dimensional space.
[0095] Next, KCCA aims to find a linear combination of these mapping vectors to maximize their correlation in the high-dimensional feature space. Its mathematical expression is:
[0096]
[0097] where K 11 and K 12 are the self-kernel matrices of the two OD pairs, is the kernel matrix between the two OD pairs, and w1 and w2 are the corresponding learnable parameter matrices. By maximizing ρ, the correlation of the two OD pairs in the high-dimensional space can be quantified.
[0098] If the calculated correlation exceeds the preset threshold, it indicates that there is a significant association between the two OD pairs. When constructing the adjacency matrix of the OD knowledge graph, this association determines whether to establish an edge between the two OD pairs. Specifically, if ρ>δ (where v is the correlation threshold), the corresponding element in the adjacency matrix A is set to 1, indicating that there is a direct relationship between the two OD pairs in the knowledge graph, as shown in the process Figure 2 .
[0099] In step 3, a multi-scale spatio-temporal graph attention network (MSP-GATNet) is constructed, which includes a graph filtering model, a spatio-temporal graph attention mechanism model, and a multi-scale LSTM model.
[0100] Step 3-1, construct a graph filtering model, i.e., perform graph filtering operations on the graph features x p,t , the process includes:
[0101] First, calculate the degree matrix Dt which is the sum of the weights of the edges connected to the node, and is calculated as follows:
[0102]
[0103] where D t is a diagonal matrix, and each diagonal element D t (p,p) represents the degree of node p with node q, based on which A t (p,q) is the corresponding adjacency matrix, and the graph Laplacian L t at time point t is defined as:
[0104]
[0105] The graph Laplacian is a key part of the graph filtering process, which is used to aggregate the features of neighboring nodes.
[0106] The graph filtering process can be represented by the following formula:
[0107]
[0108] where W L is the trainable parameter matrix in the graph filtering model, σ represents the activation function, γ is a hyperparameter, x p,t is the feature vector of node p at time t, and x' p,t is the result of graph filtering.
[0109] Step 3-2, construct the spatio-temporal graph attention mechanism model of the multi-scale spatio-temporal graph attention network (MSP-GATNet) model. Assign weights to neighbor features to capture the collaborative or competitive relationship between OD pairs.
[0110] For node p and its neighbor node q, the spatial attention coefficient can be calculated using the following formula:
[0111]
[0112] where is a learnable vector for spatial attention, and tr represents the matrix transpose operation; W S is a learnable parameter matrix to transform the features, and || represents the vector concatenation operation, x p,t and x q,t are the feature vectors of nodes p and q at time t, respectively.
[0113] Then, the spatial attention coefficient is normalized by the SoftMax function to obtain the weight at time stamp t:
[0114]
[0115] where, represents the set of OD pairs composed of the neighbor nodes of the target OD node p at the time stamp t. Then, the graph features are weighted according to the neighborhood information and the spatial attention coefficient, which can be calculated as follows:
[0116]
[0117] For the OD node p at different time stamps t and t', based on the feature vector x p,t and x m,t′ , the time attention coefficient is calculated as follows:
[0118]
[0119] where, is a learnable vector of time attention, and W T is a learnable time parameter matrix to transform the features, and || represents the vector concatenation operation.
[0120] Then, the time attention coefficient is normalized by the SoftMax function to obtain the weight of the time stamp t:
[0121]
[0122] The node feature is learned by the historical node feature and the time attention coefficient, and its calculation formula is as follows:
[0123]
[0124] In order to further incorporate historical neighborhood knowledge, the spatio-temporal attention coefficient of each node p and its historical neighborhood node q at different times is calculated:
[0125]
[0126] Then, the spatio-temporal attention coefficient is standardized according to the following formula:
[0127]
[0128] The node feature is dependent on the historical neighborhood feature and the spatio-temporal attention coefficient, and its mathematical expression is:
[0129]
[0130] Finally, combined with the results of the spatial, temporal and spatio-temporal attention mechanisms, we obtain the final node feature representation of each node at the time stamp t:
[0131]
[0132] where σ is an activation function, N is a set of nodes, and T is a set of timestamps.
[0133] Step S4, a multi-scale LSTM model of the multi-scale space-time graph attention network (MSP-GATNet) model is constructed, and a long short-term memory (LSTM) network is applied to process complex continuous prediction, and an underground passenger flow prediction value is output.
[0134] The LSTM model can manage long-term dependencies by using a gating mechanism (input gate, forget gate, and output gate). The LSTM model uses a cell state C t to store important information, which is passed across time steps and updated at each step according to new input data. The forget gate is the first mechanism that decides whether to retain the information of the previous cell state. Its calculation expression is:
[0135] f t =σ(W f ·[h t-1 ,x t ]+b f )
[0136] where W f is a learnable weight matrix of the forget gate; b f is a bias term; σ is an activation function; h t-1 is a previous hidden state, and x t is an input feature of the current timestamp.
[0137] The input gate decides which new information to integrate into the cell state. Through this step, the model can adjust its prediction results by combining the influence of real-time data. The calculation formula of the input gate is:
[0138] i t =σ(W i ·[h t-1 ,x t ]+b i )
[0139] The state of the candidate cell can be calculated as follows:
[0140]
[0141] where W i and W C are learnable parameter weight matrices, and b i and b C are bias vectors, respectively; x t is a feature vector at time t.
[0142] The new cell state C tThe update can be made according to the following formula:
[0143]
[0144] Through this process, the LSTM can dynamically adjust its memory to reflect the new trend of passenger flow. The output gate determines the hidden state h t of the current time step, which depends on the current cell state C t and the output gate. The calculation formula of the output gate is:
[0145] o t = σ(W o · [h t-1 , x t ] + b o )
[0146] where W o is a learnable parameter weight matrix, and b o is a bias vector;
[0147] The hidden state h t of the current time step can be calculated based on this:
[0148] h t = o t ⊙ tanh(C t )
[0149] In the task of subway OD passenger flow prediction, the hidden state h t can be used to comprehensively utilize the information of the current time point to predict the passenger flow of the next time step.
[0150] Specifically, in order to effectively capture the long-term passenger flow pattern (day level) and short-term subway passenger flow trend (minute level) in the subway OD data, a multi-scale LSTM model is constructed. The input of the day-level LSTM is the spatio-temporal attention weighted feature vector of day d The output is the long-term hidden state which is calculated as follows:
[0151]
[0152] where T D represents the set of days. Similarly, the input of the minute-level LSTM is the spatio-temporal attention weighted feature vector of each minute m The output is the short-term hidden state which is calculated as follows:
[0153]
[0154] where T M represents the set of minutes.
[0155] To update the minute-level hidden state At the beginning state of each day d, the day-level hidden state of the previous day is used to initialize the minute-level hidden state It is calculated as follows:
[0156]
[0157] where T D represents the first minute set of the day d.
[0158] The constructed multi-scale spatio-temporal graph attention network is used to predict the subway passenger flow.
[0159] The prediction is made based on the output results of the minute-level and day-level LSTM:
[0160]
[0161] where z M and z D are nonlinear functions that map the hidden state to the OD passenger flow.
[0162] To ensure that both models are optimized during training, a joint loss function is constructed that considers both minute-level and day-level prediction losses. The function can be represented as follows:
[0163]
[0164] where λ M and λ D are the weights of the minute-level prediction loss and the day-level prediction loss , respectively, and are the true passenger flow values corresponding to the day d and minute m level, respectively, T D and T M are the time sets for the day level and minute level, respectively.
[0165] The proposed evaluation index system is used to evaluate the designed subway passenger flow prediction model that integrates knowledge graph and MSP-GATNet deep learning model.
[0166] The mean absolute error (MAE), root mean square error (RMSE), and mean absolute percentage error (MAPE) are calculated. The MAE is used to measure the average size of the error between the predicted value and the actual value, providing an intuitive explanation of the prediction accuracy. Its mathematical expression is:
[0167]
[0168] where z p,t is the true passenger flow value of OD node p at timestamp t; is the predicted value; N is the total number of samples of OD pairs; T start and T end are the start and end timestamps.
[0169] The RMSE is calculated as follows:
[0170]
[0171] The MAPE is calculated as follows:
[0172]
[0173] Example 2
[0174] This embodiment also relates to a verification test of a subway passenger flow prediction method based on a multi-scale spatio-temporal graph attention network. In this embodiment, OD-level passenger flow data from a certain subway system is used, covering a period of three weeks from September 1, 2023 to September 21, 2023, excluding holidays and other special dates. The study period covers the standard subway operating hours, i.e., 6:00 to 22:00 every day, with a time granularity of 10-minute intervals. In this study, a total of 409 stations of a certain subway system were selected as the research object, and the OD-level passenger flow patterns of the subway were analyzed. The entire study period was divided into 14 days of training data and 7 days of verification and test data.
[0175] The OD passenger flow intensity on weekdays is generally higher than on weekends, and shows obvious directional characteristics at different times of the day. During the morning hours of 6:00 to 10:00, passenger flow mainly flows from the suburbs to the city center; between 10:00 and 17:00, the inflow and outflow of the city center is relatively balanced; between 18:00 and 22:00, passenger flow begins to flow outward from the city center. The morning and evening peak hours on weekdays occur between 8:00 and 9:00 and 18:00 and 19:00, respectively, while the morning peak on weekends is delayed to 9:00 to 10:00 and the evening peak is delayed to 19:00 to 20:00. POI data is divided into five types: work area, residential area, education area, medical area, and commercial area. In order to quantify the number of POIs within a 1-kilometer range around each subway station, a 1-kilometer distance threshold is set. In this POI analysis, the number of commercial POIs is the largest, accounting for 64.70%, followed by work areas, accounting for 18.91%; while the number of POIs in residential, educational, and medical areas is relatively small, accounting for 8.34%, 5.17%, and 2.89%, respectively.
[0176] In this study, we used several baseline models, including Historical Average (HA), Support Vector Regression (SVR), Long Short-Term Memory Network (LSTM), and Temporal Convolutional Network (TCN), to predict metro OD-level passenger flow. The results are shown in Table 1. Taking the 10-minute prediction MAPE as an example, the performance of the HA model was significantly worse than that of SVR, and the performance of SVR was worse than that of the deep learning method LSTM. Specifically, the MAPE of the HA model was 64.765%, which was significantly higher than the 60.307% of SVR. These results indicate that although statistical regression and machine learning methods perform well in capturing simple historical trends, they have limited ability to model spatiotemporal dynamics in OD passenger flow prediction. In contrast, deep learning methods significantly improve prediction accuracy because of their strong ability to learn from time-series data. The MAPE of LSTM was 52.244%, which was significantly better than that of HA and SVR. The MAPE of TCN was 55.818%, which was worse than that of LSTM. This indicates that in OD passenger flow prediction, step-by-step learning is more effective than learning the entire sequence at once. Although TCN can capture long-term dependencies through convolution operations, its prediction ability is not as good as that of LSTM.
[0177] Table 1
[0178] Evaluation index Time interval HA SVR LSTM TCN MAE 10min 2.885 2.693 2.31 2.49 20min 5.425 5.097 4.346 4.743 30min 8.001 7.468 6.423 6.97 60min 15.465 14.402 12.399 13.44 MAPE 10min 64.765 60.307 52.244 55.818 20min 69.357 64.553 55.389 60.416 30min 73.976 68.958 60.242 64.65 60min 77.81 74.226 62.228 66.587 RMSE 10min 3.615 3.376 2.898 3.12 20min 6.799 6.382 5.445 5.951 30min 10.032 9.344 8.051 8.718 60min 19.446 18.108 15.586 16.886
[0179] In addition, we used deep learning hybrid models for comparison. PSAM-CNN (Position-Sensitive Attention Mechanism with Convolutional Neural Network) is a model that combines a position-sensitive attention mechanism with a convolutional neural network (CNN). ST-VGCN (Spatiotemporal Virtual Graph Convolutional Network) is a spatiotemporal virtual graph convolutional network model. AFFN (Adaptive Fusion Factor Network) is an adaptive fusion factor network. Table 2 shows the hybrid models (PSAM-CNN, ST-VGCN, AFFN, MSP-GATNet (network structure as shown in Figure 2), and their prediction results. Figure 3The four hybrid models all have significant improvements in accuracy compared with the baseline models. Taking the MAPE of 10-minute prediction as an example, the MAPE of PSAM-CNN is 47.342%, ST-VGCN is 43.083%, and AFFN is 38.791%, all of which are better than the best performance of the aforementioned baseline models. The MAPE of MSP-GATNet is 34.449%, which is the best, demonstrating its effectiveness in integrating spatial, temporal, and external factors.
[0180] Table 2
[0181] Evaluation index Time interval PSAM-CNN ST-VGCN AFFN MSP-GATNet MAE 10min 2.113 1.917 1.729 1.539 20min 3.999 3.628 3.252 2.904 30min 5.875 5.342 4.77 4.254 60min 11.304 10.326 9.312 8.243 MAPE 10min 47.342 43.083 38.791 34.449 20min 51.184 46.301 41.569 36.775 30min 53.358 49.096 43.879 38.442 60min 57.26 51.802 46.45 41.192 RMSE 10min 2.645 2.403 2.169 1.926 20min 5.009 4.55 4.081 3.636 30min 7.361 6.692 5.971 5.328 60min 14.185 12.931 11.675 10.321
[0182] By analyzing the spatial and temporal dimensions, we further explore the performance of PSAM-CNN, ST-VGCN, AFFN, and MSP-GATNet at different time periods and different days (see Appendix Figure 4 ). The MAPE analysis from Monday to Sunday shows that MSP-GATNet outperforms the other three hybrid models on all days of the week. The prediction error on weekdays is generally lower than on weekends, especially on the transition days (Saturday and Monday), where the prediction error significantly increases, mainly due to the shift in travel patterns from commuting to recreational, increasing data complexity. In addition, Appendix Figure 5 shows the MAPE changes within different time periods (6:00 to 22:00), and the results show that the error of all models significantly increases during peak hours, while MSP-GATNet exhibits the best performance in each time period.
[0183] To verify the effectiveness of each component in MSP-GATNet, we conduct an ablation experiment, and the results are shown in Table 3. The experiment designs four groups, combining historical passenger flow information (K1), land use information (K2), OD distance and accessibility information (K3). Taking the MAPE of 10-minute prediction as an example, when only using historical passenger flow information, the MAPE is 64.946%; after adding land use information, the MAPE significantly decreases to 41.506%; while adding OD distance and accessibility information, the MAPE increases to 57.394%. When all knowledge is combined, the model performs best, with a MAPE of 34.449%.
[0184] Table 3
[0185]
[0186] Finally, Table 4 shows the impact of different attention mechanism combinations on prediction accuracy. A0 represents no attention, As represents spatial attention, Ap represents temporal attention, and Asp represents MSP-GATNet. The results show that when no attention mechanism is used, the MAPE for 10-minute prediction is 58.247%; when only spatial attention is used, the error decreases to 42.112%; when only temporal attention is used, the error is 54.148%; and when the MSP-GATNet model combines spatial and temporal attention, the MAPE is 34.449%, verifying the effectiveness of the spatio-temporal attention mechanism in improving OD passenger flow prediction accuracy.
[0187] Table 4
[0188]
[0189] From the results, it can be seen that the method of the present application not only accurately predicts the passenger flow of the subway OD level, significantly improving the accuracy of the prediction, but also solves the problems of data sparsity and strong spatio-temporal dynamics by fusing the knowledge graph and the multi-scale spatio-temporal graph attention network. The method also has high adaptability and flexibility, and can adjust the model according to different spatio-temporal characteristics, suitable for complex subway operation environment, and further optimize the scheduling and resource allocation of the subway system.
[0190] Example 3
[0191] The electronic device of the present application includes a central processing unit (CPU) that can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) or loaded into a random access memory (RAM) from a storage unit. In the RAM, various programs and data required for device operation can also be stored. The CPU, ROM, and RAM are connected to each other through a bus. An input / output (I / O) interface is also connected to the bus.
[0192] A plurality of components in the device are connected to the I / O interface, including: an input unit such as a keyboard, a mouse, etc.; an output unit such as various types of displays, speakers, etc.; a storage unit such as a magnetic disk, an optical disk, etc.; and a communication unit such as a network card, a modem, a wireless communication transceiver, etc. The communication unit allows the device to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunications networks.
[0193] The processing units perform the various methods and processes described above, such as methods S1-S4. For example, in some embodiments, methods S1-S4 can be implemented as a computer software program tangibly embodied in a machine readable medium, such as a storage unit. In some embodiments, portions or all of the computer program can be loaded and / or installed onto the device via the ROM and / or the communication unit. When the computer program is loaded onto the RAM and executed by the CPU, one or more of the steps of methods S1-S4 described above can be performed. Alternatively, in other embodiments, the CPU can be configured to perform methods S1-S4 by any other suitable means, such as by way of firmware.
[0194] The functionality described above in this document can be performed, at least in part, by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Application-specific Integrated Circuits (ASICs), Application-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.
[0195] Program code for carrying out the methods of the present application can be written in any combination of one or more programming languages. This program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, causes the machine to perform the functions / acts specified in the flowcharts and / or block diagrams. The program code can be embodied in whole or in part within a machine readable medium, which can be any medium for storing or transmitting the program code. The program code can be transmitted in the form of signals over a transmission medium via a data signal or carrier wave, or it can be provided on a machine readable medium.
[0196] In the context of the present application, a machine-readable medium can be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of a computer program code, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0197] The above merely illustrates the specific embodiments of the present application, but the protection scope of the present application is not limited thereto, and any skilled person in the art can easily think of various equivalent modifications or replacements within the technical range disclosed by the present application, and these modifications or replacements shall be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network, characterized in that, The method includes the following steps: Step S1: Collect passenger flow data, metro network structure data, and land use type data for metro OD pairs; Step S2: Construct an OD-level urban rail transit knowledge graph based on the data from Step S1, and calculate the node features of the knowledge graph, including calculating historical passenger flow features, calculating land use information, calculating the accessibility of OD pairs, and calculating the relevance of OD pairs. Step S3: Input the node features of the knowledge graph from step S2 into the multi-scale spatiotemporal graph attention network. First, perform graph filtering on the node features, and then update the node features of the knowledge graph by combining the output of the spatiotemporal graph attention mechanism model. The network includes a graph filtering model, a spatiotemporal graph attention mechanism model and a multi-scale LSTM model connected in sequence. Step S4: Input the updated node features into the multi-scale LSTM model and output the multi-scale prediction results of subway passenger flow. The graph filtering process includes: First, calculate the degree matrix. The degree matrix is the sum of the weights of the edges connected to a node, and it is calculated as follows: Wherein, degree matrix It is a diagonal matrix, each diagonal element This indicates that OD pairs node p and its neighboring nodes The degree, For the corresponding adjacency matrix, time point The Graph Laplace operator at the location Defined as: The graph filtering process is represented by the following formula: in, It is the trainable parameter matrix in the graph filtering model. This represents the activation function. For hyperparameters, For nodes p The eigenvector at time t, The result after image filtering. N For a set of nodes, T A set of timestamps; The spatiotemporal graph attention mechanism model learns node features through spatial attention, temporal attention, and spatiotemporal attention, respectively. Then, by combining the learning results of these three attention mechanisms, it obtains the timestamp of each node. t The final node feature representation at that time is as follows: in, For activation function, N For a set of nodes, T A set of timestamps , and They are nodes p In timestamp t The node features are learned through spatial attention, temporal attention, and spatiotemporal attention.
2. The subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network according to claim 1, characterized in that, The calculation of historical passenger flow characteristics includes calculating historical statistical indicators for each OD pair. The historical statistical indicators include the mean and standard deviation of passenger flow within a specific time period, as well as passenger flow during peak and off-peak hours. The specific time period includes weekday peak, weekday off-peak, weekend peak, and weekend off-peak. The calculation of land use information involves calculating the proportion of each OD (Original Location) to different types of points of interest around the origin and destination stations; The calculation of the reachability of OD pairs includes: calculating the shortest path distance and the number of feasible paths for each OD pair; The calculation of OD pair correlation includes: calculating the nonlinear correlation of historical passenger flow sequences using the kernel canonical correlation analysis method, constructing relational edges of OD pairs based on correlation thresholds, and then constructing edge features of the knowledge graph.
3. The subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network according to claim 1, characterized in that, The graph filtering model is used to extract knowledge graph features, and the spatiotemporal graph attention mechanism model is used to capture the passenger flow correlation between OD pairs and model long-term and short-term passenger flow dynamics.
4. The subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network according to claim 1, characterized in that, The spatial attention learning process for node features includes: for nodes and its neighboring nodes Calculate the spatial attention coefficient; normalize the spatial attention coefficient to obtain the timestamp weight; and weight the node features based on the neighborhood information and the spatial attention coefficient. The learning process of node features by the temporal attention includes: for nodes and its neighboring nodes Calculate the temporal attention coefficient; normalize the temporal attention coefficient to obtain the timestamp weight; and weight the node features based on neighborhood information and the temporal attention coefficient. The learning process of spatiotemporal attention for node features includes: calculating the spatiotemporal attention coefficients at different times for node p and its neighboring nodes q; standardizing the spatiotemporal attention coefficients to obtain the timestamp weights; and weighting the node features based on neighborhood information and the spatiotemporal attention coefficients.
5. The subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network according to claim 1, characterized in that, The multi-scale LSTM model includes a day-level LSTM model and a minute-level LSTM model, which are used to capture long-term passenger flow models and short-term passenger flow trends, respectively. The input of the day-level LSTM model is a day-level spatiotemporal attention-weighted feature vector, and the output is the long-term hidden state; The input to the minute-level LSTM model is a minute-level spatiotemporal attention-weighted feature vector, and the output is the short-term hidden state.
6. The subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network according to claim 5, characterized in that, The multi-scale prediction result of subway passenger flow output in step S4 is specifically as follows: Subway passenger flow is predicted based on the output results of minute-level and day-level LSTMs, using the following formula: in, and It is a non-linear function that maps hidden states to OD (Original Demand) passenger flow. and These are long-term hidden states and short-term hidden states, respectively. and These are the subway passenger flow forecasts for both daily and minute-level measurements.
7. The subway passenger flow prediction method based on a multi-scale spatiotemporal graph attention network according to claim 6, characterized in that, The multi-scale LSTM model is trained using a joint loss function that considers both minute-level and day-level prediction losses.
8. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Subway passenger flow volume prediction method and system based on space-time diagram ordinary differential equation
CN117592602A
Passenger flow prediction method based on LSTM
CN113221472A
Urban rail passenger flow prediction method based on dynamic multi-graph and multi-dimensional attention space-time neural network
CN117454119A