A method and device for constructing a crowd flow prediction model and related equipment
By converting raw transaction data into a dynamic graph structure and utilizing complementary representation learning and parameter update methods, the problem of untapped intrinsic relationships among data features in existing models is addressed, thereby improving the accuracy and adaptability of population flow prediction.
Patent Information
- Application Number
- CN202510745053.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2026-02-17
- Estimated Expiration
- 2045-06-05
AI Technical Summary
Existing population flow prediction models fail to effectively utilize the inherent relationships between data features, resulting in poor prediction performance and difficulty in transferring valuable information across different prediction tasks.
The original transaction data is transformed into a dynamic graph structure over continuous time. The first prediction model captures the real-time features of the current time period, while the second prediction model integrates historical and future information from adjacent time periods. A loss function is designed for iterative training to generate complementary representation learning, and parameters are updated by combining exponential moving average.
It improves the accuracy and generalization ability of inflow, outflow and OD flow prediction, effectively captures the temporal dependence, periodicity and sudden changes of population flow, and enhances the adaptability and robustness of the model.
Smart Images

Figure CN120409830B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus and related equipment for constructing a crowd flow prediction model. Background Technology
[0002] Population flow prediction models can be used to mine spatiotemporal data for tasks such as inflow prediction, outflow prediction, and origin-destination (OD) flow prediction. However, existing population flow modeling methods typically treat each data feature as an independent feature. Although these features originate from the same raw data, they fail to effectively utilize the inherent relationships between them. This makes it difficult to transfer valuable information from one prediction task to other prediction tasks, limiting the overall effectiveness of the prediction model.
[0003] It is evident that existing population movement prediction models suffer from poor predictive performance. Summary of the Invention
[0004] This application provides a method, apparatus, and related equipment for constructing a crowd flow prediction model to solve the problem of poor prediction performance of existing crowd flow prediction models.
[0005] To solve the above-mentioned technical problems, this application is implemented as follows:
[0006] In a first aspect, embodiments of this application provide a method for constructing a population flow prediction model, the method comprising:
[0007] The acquired raw transaction data is converted into a dynamic graph structure over continuous time. The raw transaction data includes a transaction triple consisting of a starting node, a destination node, and a timestamp. The dynamic graph structure includes graph nodes and directed edges. The graph nodes are used to represent the starting node or the destination node. The directed edges are used to represent the personnel flow information between the starting node and the destination node. The directed edges carry the timestamp.
[0008] The dynamic graph structure is input into the first prediction model to obtain the first node representation corresponding to the dynamic graph structure. The first node representation is a vector representation determined based on the transaction triples in the first time period in the dynamic graph structure.
[0009] The dynamic graph structure is input into the second prediction model to obtain the second node representation corresponding to the dynamic graph structure. The second node representation is a vector representation determined by the transaction triples in the first time period, the transaction triples in the second time period, and the transaction triples in the third time period in the dynamic graph structure. The second time period is the adjacent time period before the first time period, and the third time period is the adjacent time period after the first time period.
[0010] Based on the loss value between the prediction result corresponding to the first node representation and the second node representation, the first prediction model and the second prediction model are iteratively trained until the loss value is less than or equal to a preset threshold. The first parameter of the first prediction model and the second parameter of the second prediction model after iterative training are determined as the target parameters of the crowd flow prediction model.
[0011] Optionally, the dynamic graph structure includes a graph node set and a directed edge set, wherein the graph node set includes graph nodes at multiple times within the time interval t, and the directed edge set includes directed edges at multiple times within the time interval t.
[0012] The first prediction model is implemented according to the following formula:
[0013]
[0014] Among them, g t =(V,{e k |t k <t}); f() represents the encoder in the first prediction model, g t Let V be the dynamic graph structure, and let e be the set of graph nodes. k For t k The directed edge of time, For t k The starting point of time. For t k The destination node at time Z t Let be the first node. Let Z be the representation vector of the i-th node in a graph with N nodes, and Z t ∈R N*d , d represents the dimension of the first node.
[0015] Optionally, the second prediction model is implemented according to the following formula:
[0016]
[0017] in, B t ={em |t - <t m ≤t}; For the second node, f ξ Let ξ and f be the encoder parameters in the second prediction model. θ This indicates that the encoder parameters in the first prediction model are θ and B. t The transaction triples within the first time period. To broaden the data, Including the transaction triples within the second time period and the transaction triples within the third time period, e m For t m The directed edge of time, For t m The starting point of time. For t m The destination node at time t - This refers to the last moment among multiple moments in the second time period. For the starting node at t - Memory state at any given moment The destination node is at t - The memory state at any given moment, M o,t M represents the memory state of the starting node at time t. d,t The memory state of the destination node at time t, and Let be the dimension represented by the second node.
[0018] Optionally, the loss value is calculated according to the following formula:
[0019]
[0020] Among them, H t =p θ (Z t L is the loss value, H t Let p represent the prediction result corresponding to the first node. θ Z is the predictor corresponding to the encoder in the first prediction model. t Let be the first node. Let be the representation vector of node i at time t in the second node representation. Let ||·|| be the prediction result corresponding to the representation vector of node i at time t in the prediction result of the first node representation, and ||·|| be the L2 norm of the vector.
[0021] Optionally, the second parameter is obtained according to the following formula:
[0022] ξ′=αξ+(1-α)θ;
[0023] Where θ is the first parameter, ξ′ is the updated second parameter, ξ is the original second parameter, and α is a hyperparameter.
[0024] Optionally, the step of converting the acquired raw transaction data into a continuous-time dynamic graph structure includes:
[0025] The acquired raw transaction data is converted into triples to obtain the initial triples;
[0026] Data cleaning is performed on the initial triplet to obtain the transaction triplet. The transaction triplet is a triplet data after removing abnormal data from the initial triplet. The abnormal data includes data that is missing any one of the origin node, destination node, and timestamp.
[0027] The transaction triples are converted into the dynamic graph structure.
[0028] Secondly, embodiments of this application provide a population flow prediction model construction apparatus, the apparatus comprising:
[0029] The conversion module is used to convert the acquired raw transaction data into a dynamic graph structure with continuous time. The raw transaction data includes a transaction triple consisting of a starting node, a destination node, and a timestamp. The dynamic graph structure includes graph nodes and directed edges. The graph nodes are used to represent the starting node or the destination node. The directed edges are used to represent personnel flow information between the starting node and the destination node. The directed edges carry the timestamp.
[0030] The first input module is used to input the dynamic graph structure into the first prediction model to obtain the first node representation corresponding to the dynamic graph structure. The first node representation is a vector representation determined based on the transaction triples in the first time period of the dynamic graph structure.
[0031] The second input module is used to input the dynamic graph structure into the second prediction model to obtain the second node representation corresponding to the dynamic graph structure. The second node representation is a vector representation determined based on the transaction triples in the first time period, the transaction triples in the second time period, and the transaction triples in the third time period in the dynamic graph structure. The second time period is the adjacent time period before the first time period, and the third time period is the adjacent time period after the first time period.
[0032] The training module is used to iteratively train the first prediction model and the second prediction model based on the loss value between the prediction result corresponding to the first node representation and the second node representation until the loss value is less than or equal to a preset threshold, and to determine the first parameter of the first prediction model and the second parameter of the second prediction model after iterative training as the target parameters of the crowd flow prediction model.
[0033] Thirdly, embodiments of this application provide an electronic device, including a transceiver and a processor.
[0034] The processor is used to convert the acquired raw transaction data into a dynamic graph structure over continuous time. The raw transaction data includes a transaction triple consisting of a starting node, a destination node, and a timestamp. The dynamic graph structure includes graph nodes and directed edges. The graph nodes are used to represent the starting node or the destination node. The directed edges are used to represent personnel flow information between the starting node and the destination node. The directed edges carry the timestamp.
[0035] The transceiver is used to input the dynamic graph structure into the first prediction model to obtain the first node representation corresponding to the dynamic graph structure. The first node representation is a vector representation determined based on the transaction triples in the first time period of the dynamic graph structure.
[0036] The transceiver is further configured to input the dynamic graph structure into the second prediction model to obtain the second node representation corresponding to the dynamic graph structure. The second node representation is a vector representation determined based on the transaction triples in the first time period, the transaction triples in the second time period, and the transaction triples in the third time period in the dynamic graph structure. The second time period is the adjacent time period before the first time period, and the third time period is the adjacent time period after the first time period.
[0037] The transceiver is further configured to iteratively train the first prediction model and the second prediction model based on the loss value between the prediction result corresponding to the first node representation and the second node representation, until the loss value is less than or equal to a preset threshold, and determine the first parameter of the first prediction model and the second parameter of the second prediction model after iterative training as the target parameters of the crowd flow prediction model.
[0038] Fourthly, embodiments of this application provide an electronic device, including: a processor, a memory, and a program stored in the memory and executable on the processor, wherein when the program is executed by the processor, it implements the steps of the crowd flow prediction model construction method as described in the first aspect.
[0039] Fifthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the crowd flow prediction model construction method as described in the first aspect.
[0040] In this embodiment, the original transactions are first converted into a dynamic graph structure with timestamps to provide structured input for time series analysis. Then, the first prediction model captures the immediate features of the current time period, while the second prediction model integrates historical and future information from adjacent time periods to construct long-term dependencies, thus forming complementary representation learning. A loss function is designed based on the differences between the two representations, and the first prediction model is forced to learn more robust features through iterative training. At the same time, the parameters of the second prediction model are slowly updated using exponential moving average calculation to provide stable supervision signals. The resulting node representation effectively captures the temporal dependencies, periodicity, and sudden changes in population flow. Combined with multi-task adaptability, it effectively improves the accuracy and generalization of inflow, outflow, and OD flow prediction. Attached Figure Description
[0041] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is one of the flowcharts of a method for constructing a population flow prediction model provided in the embodiments of this application;
[0043] Figure 2 This is the second flowchart of a method for constructing a population flow prediction model provided in the embodiments of this application;
[0044] Figure 3 This is a schematic diagram of the structure of a population flow prediction model construction device provided in an embodiment of this application;
[0045] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0046] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0047] See Figure 1 , Figure 1 This is a flowchart of a method for constructing a crowd flow prediction model provided in an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0048] Step 101: Convert the acquired raw transaction data into a continuous-time dynamic graph structure. The raw transaction data includes a transaction triple consisting of a starting node, a destination node, and a timestamp. The dynamic graph structure includes graph nodes and directed edges. The graph nodes are used to represent the starting node or the destination node. The directed edges are used to represent the personnel flow information between the starting node and the destination node. The directed edges carry the timestamp.
[0049] In this step, raw data can be collected from the transportation system. This raw transaction data includes each passenger's origin, destination, and travel time. This information can be converted into a transaction triple: (origin node, destination node, timestamp). For example, a transaction triple can be represented as... in, This represents the m-th starting node. Let t represent the m-th destination node. m Indicates the passenger at time t m from Travel to A continuous-time dynamic graph structure consists of graph nodes and directed edges. Each graph node can represent a transportation entity, such as a subway station. A finite set of N graph nodes can be represented as V = {v1, v2, ..., v...} N In a dynamic graph structure, the m-th directed edge can be represented as: The set of M transactions can be represented as E = {e1, e2, ..., e}. M The dynamic graph structure at time t can be denoted as g. t =(V,{e k |t k <t}),g t It contains all transactions that occurred before time t.
[0050] In this way, the acquired raw transaction data is transformed into a continuous-time dynamic graph structure. Graph nodes directly correspond to the start and destination nodes in the original data, and each directed edge represents a unidirectional flow event, with each edge carrying a timestamp to depict the temporal order of the events, thus giving the graph structure dynamism. Graphs at different time points contain different sets of edges (e.g., the graph at time t contains all edges at time t). k(Edges of t). Transforming unstructured flow data into a structured dynamic graph provides a basis for subsequent time-series graph analysis; the introduction of timestamps enables the model to capture the time dependencies of flow events (such as the periodicity of morning and evening rush hours, the immediate impact of突发事件).
[0051] Optionally, step 101, converting the obtained original transaction data into a dynamic graph structure of continuous time, includes:
[0052] Converting the obtained original transaction data into a triple form to obtain an initial triple;
[0053] Performing data cleaning on the initial triple to obtain the transaction triple, where the transaction triple is triple data obtained by removing abnormal data in the initial triple, and the abnormal data includes data with any one of the starting node, destination node, and timestamp missing;
[0054] Converting the transaction triple into the dynamic graph structure.
[0055] In this example, first, the original data is organized into an initial triple containing the starting node, destination node, and timestamp. Subsequently, abnormal data with any one (node or timestamp) missing is removed through data cleaning to obtain a transaction triple with a standardized format and complete information. Finally, these cleaned triples are converted into a continuous-time dynamic graph structure with graph nodes and timestamped directed edges as the core elements, providing high-quality input data for subsequent modeling.
[0056] Step 102, inputting the dynamic graph structure into a first prediction model to obtain a first node representation corresponding to the dynamic graph structure, where the first node representation is a vector representation determined according to the transaction triples within the first time period in the dynamic graph structure;
[0057] In this step, as Figure 2 shown, the first prediction model can be a branch in a self-supervised learning framework, namely the online branch. Through the online branch, real-time update of node information and maintenance of the first node representation of the nodes are achieved. Whenever new transaction data is obtained, the online encoder in the first prediction model updates the memory state of the relevant nodes and adjusts the first node representation of the nodes accordingly. This enables the output of the first prediction model to dynamically reflect the latest population flow situation. Specifically, the online encoder of the first prediction model can be denoted as f θ, where θ is the parameter of the online encoder. Inputting the dynamic graph structure into the first prediction model to obtain the first node representation corresponding to the dynamic graph structure, generating instant vector features by quickly responding to transaction triples within the first time period, providing timeliness support for real-time prediction; the first node representation can be directly applied to downstream prediction models (such as fully connected networks, graph neural networks) for real-time prediction of inflow, outflow, and origin-destination (OD) flows. Each dimension in the vector implicitly contains key features of the current time period (such as the activity level of the node as a starting point and the instant interaction intensity of adjacent nodes). By converting the complex temporal graph structure into a low-dimensional vector, while retaining key information, the computational complexity is reduced, supporting the efficient processing and pattern extraction of large-scale dynamic graphs.
[0058] Optionally, the dynamic graph structure includes a set of graph nodes and a set of directed edges. The set of graph nodes includes graph nodes at multiple moments within the t time period, and the set of directed edges includes directed edges at multiple moments within the t time period;
[0059] The first prediction model is implemented according to the following formula:
[0060]
[0061] where, g t =(V, {e k |t k <t}); f() represents the encoder in the first prediction model, g t is the dynamic graph structure, V is the set of graph nodes, e k is the directed edge at time t k , is the starting node at time t k , is the destination node at time t k , Z t is the first node representation, is the representation vector of the i-th node among N graph nodes, and Z t ∈R N*d , d is the dimension of the first node representation. The encoder in the first prediction model is used to convert the dynamic graph structure into a low-dimensional, dense node vector representation.
[0062] In this example, given the dynamic graph structure g t =(V, {e k |t k <t}) before time t, the goal is to train the online encoder f() in the first prediction model such that The dynamic graph g is generated using the online encoder f(). t Transform into a low-dimensional, dense node vector representation matrix Z t ∈R N*d The representation of each node i The algorithm compresses all interaction information of the node before time t (such as flow records as start / end points and time-dependent features). The core objective of the online encoder is to enable the generated first node representation to effectively capture the spatiotemporal dependencies of the dynamic graph (such as recent flow trends and node interaction patterns) through training, providing efficient feature inputs for downstream inflow, outflow, and OD flow prediction.
[0063] Specifically, three types of population flow tasks can be considered: inflow prediction, outflow prediction, and OD (Original Demand) flow prediction. Inflow prediction refers to predicting how many people enter a particular node within a certain period. The inflow to node i can be defined as X. I,t:t+τ Where τ is the preset time interval, X I,t:t+τ It can be represented as:
[0064]
[0065] Outflow prediction refers to predicting how many people will leave a node within a certain period of time. The outflow of a node i can be defined as follows: It can be represented as:
[0066]
[0067] OD flow prediction refers to predicting how people move between each pair of nodes, and can be represented as a matrix. The (i,j) entries represent how many people are from v. i to v j . It can be represented as:
[0068]
[0069] Thus, when performing inflow prediction based on the first prediction model, the corresponding output is... It can be represented as:
[0070]
[0071] When performing outflow prediction based on the first prediction model, the corresponding output is... It can be represented as:
[0072]
[0073] When performing OD flow prediction based on the first prediction model, the corresponding output is... It can be represented as:
[0074]
[0075] Among them, f I f O and f OD All of these are online encoders in the first prediction model.
[0076] Step 103: Input the dynamic graph structure into the second prediction model to obtain the second node representation corresponding to the dynamic graph structure. The second node representation is a vector representation determined based on the transaction triples in the first time period, the transaction triples in the second time period, and the transaction triples in the third time period in the dynamic graph structure. The second time period is the adjacent time period before the first time period, and the third time period is the adjacent time period after the first time period.
[0077] In this step, the second prediction model can be another branch in a self-supervised learning framework, namely the target branch. The target branch can have a structure similar to the online branch, using information from the online branch and combining context-aware data augmentation techniques to generate stable target node representations (i.e., second node representations). These second node representations are used to compare with the output of the online branch to optimize model parameters. The raw transaction data is compressed into meaningful representation vectors through a bootstrapping process, capturing key features of crowd flow. This process is achieved through the collaborative work of the online and target branches, where the online branch processes real-time data and the target branch provides stability and a benchmark. Furthermore, the target branch contains a target encoder with the same structure as the online encoder. Before being input to the target encoder, the data is first augmented by a context-aware data augmentation module. The target encoder generates second node representations in a similar manner using augmented batches. Specifically, the target encoder of the second prediction model can be denoted as f. ξ ξ represents the target encoder parameters. The dynamic graph structure is input into the second prediction model to obtain the corresponding second node representation. The transaction triples in the dynamic graph structure include three consecutive time periods (e.g., the previous hour, the current hour, and the next hour). The second prediction model processes data from these three time periods simultaneously, constructing a more complete temporal context. This allows the generated second node representation to not only include the immediate features of the current time period but also incorporate historical patterns (e.g., morning rush hour patterns) and potential future trends (e.g., afternoon mall customer flow growth), enabling the model to capture longer-term temporal dependencies. By integrating cross-time period information, the short-term fluctuation problem that may exist in the first prediction model (based only on the current time period) is alleviated, providing a more stable and comprehensive feature representation for crowd flow prediction, especially suitable for scenarios that need to capture periodic patterns or long-term effects.
[0078] Optionally, the second prediction model is implemented according to the following formula:
[0079]
[0080] in, B t ={e m |t - <t m ≤t}; For the second node, f ξ Let ξ and f be the encoder parameters in the second prediction model. θ This indicates that the encoder parameters in the first prediction model are θ and B. t The transaction triples within the first time period. To broaden the data, Including the transaction triples within the second time period and the transaction triples within the third time period, e m For t m The directed edge of time, For t m The starting point of time. For t m The destination node at time t - This refers to the last moment among multiple moments in the second time period. For the starting node at t - Memory state at any given moment The destination node is at t - The memory state at any given moment, M o,t M represents the memory state of the starting node at time t. d,t The memory state of the destination node at time t, and Let be the dimension represented by the second node.
[0081] In this example, the target encoder f of the second prediction model ξ Using the origin and destination nodes in t - Memory state at any given moment and Based on, combined with augmented data (including the previous period B) t The second node representation is generated from data of past time periods adjacent to the current time period and data of future time periods adjacent to the current time period. By fusing information from multiple time periods, the model is able to capture longer-term time dependencies and cross-time effects. Furthermore, the online encoder f of the first prediction model... θBased on the current time period B t Update memory status to M o,t and M d,t The second prediction model reuses old memory. and Ensure that the two models handle different temporal contexts.
[0082] The second parameter is obtained according to the following formula:
[0083] ξ′=αξ+(1-α)θ;
[0084] Where θ is the first parameter, ξ′ is the updated second parameter, ξ is the original second parameter, and α is a hyperparameter.
[0085] f ξ with f θ With the same structure but different parameters, ξ′ is slowly updated from θ via an exponential moving average (EMA), making... It becomes a more stable target representation, used to supervise the training of the first prediction model, and improves the ability to model time dependencies.
[0086] Specifically, the input to the online encoder is the current B. t It is from the present time t to the last update time t. - The transactions between them, B t It can be represented as:
[0087] B t ={e k ∈B|t - <t k ≤t}.
[0088] With B t The transaction triple B corresponding to the adjacent previous batch - It can be represented as:
[0089] B - ={e k ∈B|t - -τ <t k ≤t -};
[0090] With B t The transaction triple B corresponding to the adjacent subsequent batch + It can be represented as:
[0091] B + ={e k ∈B|t <t k ≤t+τ};
[0092] The transaction set consisting of the current batch and the edges of its adjacent batches can be denoted as ε, where ε can be expressed as:
[0093] ε={e k ∈B -}∪{e k ∈B t}∪{e k ∈B +}
[0094] It contains (1+r)*|B randomly sampled from ε t |A directed edge, where |B t |For B t The number of edges in the array, where r is the ratio controlling the augmented batch size. Then use B... - As input to the target encoder.
[0095] In this way, augmented data is generated by randomly sampling the edges of the current batch and its neighboring batches, and then fed into the target encoder. This augmentation strategy improves the model's adaptability to temporal changes, enabling it to better capture dynamic changes over time and thus achieve more accurate predictions in dynamic traffic environments. Through context-aware data augmentation, the model can better utilize temporal correlations, improving predictive performance.
[0096] Step 104: Based on the loss value between the prediction result corresponding to the first node representation and the second node representation, iteratively train the first prediction model and the second prediction model until the loss value is less than or equal to a preset threshold. Then, determine the first parameter of the first prediction model and the second parameter of the second prediction model after iterative training as the target parameters of the crowd flow prediction model.
[0097] The second parameter is calculated by exponential moving average based on the first parameter. The population flow prediction model includes the first prediction model and the second prediction model. The population flow prediction model is used to perform prediction tasks, including inflow prediction, outflow prediction, and origin-destination (OD) flow prediction.
[0098] This step employs a self-supervised contrastive learning framework, designing a pre-training phase: calculating the loss value (e.g., cosine similarity loss) between the prediction results of the first prediction model (based on the immediate first node representation of the current time period) and the second node representation output by the second prediction model (a stable representation incorporating multi-time period context), thus constructing a self-supervised learning objective. The parameters θ of the first prediction model are alternately updated (directly optimized via gradient descent) and the parameters ξ′ of the second prediction model (slowly synchronized from θ via exponential moving average), allowing the two models to focus on capturing immediate dynamics and long-term dependencies, respectively. When the loss value is less than a preset threshold, the model is considered converged, and the current parameters are saved as the final crowd flow prediction model. In this way, using a continuous-time dynamic encoder and contrastive learning to update the model eliminates the need for external labeled data, thereby optimizing the model parameters of the crowd flow prediction model. This reduces the dependence on large amounts of labeled data, improves the model's generalization ability, enables transfer learning between different tasks, and enhances the model's adaptability and robustness.
[0099] The loss value is calculated according to the following formula:
[0100]
[0101] Among them, H t =p θ (Z t L is the loss value, H t Let p represent the prediction result corresponding to the first node. θ Z is the predictor corresponding to the encoder in the first prediction model. t Let be the first node. Let be the representation vector of node i at time t in the second node representation. Let ||·|| be the prediction result corresponding to the representation vector of node i at time t in the prediction result of the first node representation, and ||·|| be the L2 norm of the vector.
[0102] In the first prediction model, the first parameter θ of the online encoder can be expressed as: θ←optimize(θ,lr,L).
[0103] Thus, in this embodiment, the original transactions are first converted into a dynamic graph structure with timestamps to provide structured input for time series analysis. Then, the first prediction model captures the immediate features of the current time period, while the second prediction model integrates historical and future information from adjacent time periods to construct long-term dependencies, forming complementary representation learning. A loss function is designed based on the differences between the two representations, and the first prediction model is forced to learn more robust features through iterative training. At the same time, the parameters of the second prediction model are slowly updated using exponential moving average calculation to provide stable supervision signals. The resulting node representation effectively captures the temporal dependencies, periodicity, and sudden changes in population flow. Combined with multi-task adaptability, it effectively improves the accuracy and generalization of inflow, outflow, and OD flow prediction.
[0104] In some optional embodiments, the acquired raw transaction data is converted into a continuous-time dynamic graph structure, and the dynamic graph structure is input into the first prediction model to obtain the first node representation corresponding to the dynamic graph structure, as detailed below:
[0105] For each traffic node v i The online encoder will maintain the memory of the source node from the last update. and target node memory in It was previously related to node v i The weighted sum of the interactive node states. It is a normalized weighted counter. It is node v i Last update time. Given a batch of data B t The online encoder first computes the message for each transaction, for a transaction triple (v i ,v j ,t k )∈B t The source and destination messages are calculated as follows:
[0106]
[0107] Where F∈R N*dF For node features, As the source message, This is the destination message. The node state will be in a stagnant state, and the portion from memory will be related to the transaction time t. k Multiply by the decay term between the last memory update time and the current memory update time.
[0108] Furthermore, considering computational efficiency, messages from a batch of different transactions are aggregated to update the corresponding memory of the interacting nodes. This is done using transaction triples (v... i ,v j ,t k )∈B tFor example, the interaction node is the starting node v. i and the destination node v j . For B t The last one in the middle with v i The timestamp of the transaction at the starting node. For B t The last one in the middle with v j The timestamp of the transaction for the destination node.
[0109]
[0110] Given B t Messages in interactive computing, node v i The original memory was updated as follows:
[0111]
[0112] in, For the updated initial memory, node v i The latest update time is by The last one in the middle with v i Update the timestamps of batch transactions for the original node.
[0113] Given B t Messages in interactive computing, node v j The original memory was updated as follows:
[0114]
[0115] in, For the updated initial memory, node v j The latest update time is by Decide.
[0116] After updating the source and target memory of the corresponding node, node v i The final node representation is calculated as follows:
[0117]
[0118] In this embodiment, by operating directly on a continuous-time dynamic graph, detailed temporal information is preserved, enabling the capture of more complex spatiotemporal patterns and dynamic changes in crowd flow. Specifically, this method combines timestamps and node interaction information to calculate the source and destination messages for each traffic node and updates the node's memory state through a message passing mechanism. Finally, by integrating the source and destination memory, the final representation of the node is generated. This method not only preserves temporal continuity but also considers the interaction relationships between nodes, thereby improving the model's representational power and prediction accuracy.
[0119] Furthermore, a general node representation can be learned during the pre-training phase, and then fine-tuned in downstream tasks, allowing the model to quickly adapt and improve performance on specific tasks. The specific steps include: learning a general node representation using a self-supervised contrastive learning framework during pre-training; and fine-tuning the model using the learned general representation in downstream tasks to optimize performance on specific tasks. This training strategy improves the model's training efficiency and prediction accuracy, enabling it to adapt to various crowd flow modeling tasks, such as inflow / outflow prediction and OD flow prediction, thus enhancing its generalization ability and practicality.
[0120] The crowd flow prediction model obtained by the crowd flow prediction model construction method provided in the embodiments of this application has effective technical advantages in crowd flow modeling, which are confirmed by the following quantitative results:
[0121] Compared to graph-based Evolving Memory Learning (GEML) methods, the crowd flow prediction model on the BJSubway dataset reduced the root mean squared error (RMSE) by approximately 10% (from 0.980 to 0.882), the mean absolute error (MAE) by approximately 8% (from 0.657 to 0.604), and the Pearson correlation coefficient (PCC) by approximately 3% (from 0.985 to 0.998). Similar performance was observed on the NYTaxi dataset.
[0122] In the OD prediction task, the crowd flow prediction model reduced RMSE by approximately 15% (from 0.850 to 0.723), MAE by approximately 12% (from 0.550 to 0.484), and PCC by approximately 2% (from 0.970 to 0.990) on the BJSubway dataset compared to the Temporal Graph Network (TGN) method.
[0123] For traffic flow prediction, the crowd flow prediction model on the BJSubway dataset reduced the RMSE by approximately 8% (from 0.900 to 0.828), the MAE by approximately 6% (from 0.600 to 0.564), and the PCC by approximately 1% (from 0.975 to 0.985) compared to the Multivariate Time Series Forecasting with Graph Neural Networks (MTGNN).
[0124] Compared to the Diffusion Convolutional Recurrent Neural Network (DCRNN), the crowd flow prediction model reduced the RMSE by approximately 12% (from 180 to 158), the MAE by approximately 10% (from 120 to 108), and the PCC by approximately 3% (from 0.80 to 0.83) on the BJSubway dataset. These quantitative results demonstrate that this invention not only exhibits theoretical innovation but also proves its technical advantages and practical value in real-world applications.
[0125] See Figure 3 , Figure 3 This is a schematic diagram of a population flow prediction model construction device provided in an embodiment of this application, as shown below. Figure 3 As shown, the crowd flow prediction model building device 300 includes:
[0126] The conversion module 301 is used to convert the acquired raw transaction data into a continuous time dynamic graph structure. The raw transaction data includes a transaction triple consisting of a starting node, a destination node, and a timestamp. The dynamic graph structure includes graph nodes and directed edges. The graph nodes are used to represent the starting node or the destination node. The directed edges are used to represent personnel flow information between the starting node and the destination node. The directed edges carry the timestamp.
[0127] The first input module 302 is used to input the dynamic graph structure into the first prediction model to obtain the first node representation corresponding to the dynamic graph structure. The first node representation is a vector representation determined based on the transaction triples in the first time period in the dynamic graph structure.
[0128] The second input module 303 is used to input the dynamic graph structure into the second prediction model to obtain the second node representation corresponding to the dynamic graph structure. The second node representation is a vector representation determined based on the transaction triples in the first time period, the transaction triples in the second time period, and the transaction triples in the third time period in the dynamic graph structure. The second time period is the adjacent time period before the first time period, and the third time period is the adjacent time period after the first time period.
[0129] The training module 304 is used to iteratively train the first prediction model and the second prediction model based on the loss value between the prediction result corresponding to the first node representation and the second node representation until the loss value is less than or equal to a preset threshold, and to determine the first parameter of the first prediction model and the second parameter of the second prediction model after iterative training as the target parameters of the crowd flow prediction model.
[0130] Optionally, the dynamic graph structure includes a graph node set and a directed edge set, wherein the graph node set includes graph nodes at multiple times within the time interval t, and the directed edge set includes directed edges at multiple times within the time interval t.
[0131] The first prediction model is implemented according to the following formula:
[0132]
[0133] Among them, g t =(V,{e k |t k <t}); f() represents the encoder in the first prediction model, g t Let V be the dynamic graph structure, and let e be the set of graph nodes. k For t k The directed edge of time, For t k The starting point of time. For t k The destination node at time Z t Let be the first node. Let Z be the representation vector of the i-th node in a graph with N nodes, and Z t ∈R N*d , d represents the dimension of the first node.
[0134] Optionally, the second prediction model is implemented according to the following formula:
[0135]
[0136] in, B t ={e m |t - <t m ≤t}; For the second node, f ξ Let ξ and f be the encoder parameters in the second prediction model. θ This indicates that the encoder parameters in the first prediction model are θ and B. t The transaction triples within the first time period. To broaden the data, Including the transaction triples within the second time period and the transaction triples within the third time period, e m For t m The directed edge of time, For t m The starting point of time. For t m The destination node at time t - This refers to the last moment among multiple moments in the second time period. For the starting node at t - Memory state at any given moment The destination node is at t - The memory state at any given moment, M o,t M represents the memory state of the starting node at time t. d,t The memory state of the destination node at time t, and Let be the dimension represented by the second node.
[0137] Optionally, the loss value is calculated according to the following formula:
[0138]
[0139] Among them, H t =p θ (Z t L is the loss value, H t Let p represent the prediction result corresponding to the first node. θ Z is the predictor corresponding to the encoder in the first prediction model. t Let be the first node. Let be the representation vector of node i at time t in the second node representation. Let ||·|| be the prediction result corresponding to the representation vector of node i at time t in the prediction result of the first node representation, and ||·|| be the L2 norm of the vector.
[0140] Optionally, the second parameter is obtained according to the following formula:
[0141] ξ′=αξ+(1-α)θ;
[0142] Where θ is the first parameter, ξ′ is the updated second parameter, ξ is the original second parameter, and α is a hyperparameter.
[0143] Optionally, the conversion module 301 is specifically used for:
[0144] The acquired raw transaction data is converted into triples to obtain the initial triples;
[0145] Data cleaning is performed on the initial triplet to obtain the transaction triplet. The transaction triplet is a triplet data after removing abnormal data from the initial triplet. The abnormal data includes data that is missing any one of the origin node, destination node, and timestamp.
[0146] The transaction triples are converted into the dynamic graph structure.
[0147] The crowd flow prediction model construction device 300 is capable of implementing each process of the above-described crowd flow prediction model construction method applied to the network operation and maintenance management platform. The technical features are one-to-one and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0148] This application also provides an electronic device, including: a processor, a memory, and a program stored in the memory and executable on the processor. When the program is executed by the processor, it implements the various processes of the above-described method for constructing a population flow prediction model and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0149] For details, see Figure 4 This application also provides an electronic device, including a bus 401, a transceiver 402, an antenna 403, a bus interface 404, a processor 405, and a memory 406.
[0150] The processor 405 is used to convert the acquired raw transaction data into a dynamic graph structure over continuous time. The raw transaction data includes a transaction triple consisting of a starting node, a destination node, and a timestamp. The dynamic graph structure includes graph nodes and directed edges. The graph nodes are used to represent the starting node or the destination node. The directed edges are used to represent personnel flow information between the starting node and the destination node. The directed edges carry the timestamp.
[0151] Transceiver 402 is used to input the dynamic graph structure into the first prediction model to obtain the first node representation corresponding to the dynamic graph structure. The first node representation is a vector representation determined based on the transaction triples in the first time period of the dynamic graph structure.
[0152] The transceiver 402 is also used to input the dynamic graph structure into the second prediction model to obtain the second node representation corresponding to the dynamic graph structure. The second node representation is a vector representation determined based on the transaction triples in the first time period, the transaction triples in the second time period, and the transaction triples in the third time period in the dynamic graph structure. The second time period is the adjacent time period before the first time period, and the third time period is the adjacent time period after the first time period.
[0153] The processor 405 is further configured to iteratively train the first prediction model and the second prediction model based on the loss value between the prediction result corresponding to the first node representation and the second node representation until the loss value is less than or equal to a preset threshold, and determine the first parameter of the first prediction model and the second parameter of the second prediction model after iterative training as the target parameters of the crowd flow prediction model.
[0154] Optionally, the dynamic graph structure includes a graph node set and a directed edge set, wherein the graph node set includes graph nodes at multiple times within the time interval t, and the directed edge set includes directed edges at multiple times within the time interval t.
[0155] The first prediction model is implemented according to the following formula:
[0156]
[0157] Among them, g t =(V,{e k |t k <t}); f() represents the encoder in the first prediction model, g t Let V be the dynamic graph structure, and let e be the set of graph nodes. k For t k The directed edge of time, For t k The starting point of time. For t k The destination node at time Z t Let be the first node. Let Z be the representation vector of the i-th node in a graph with N nodes, and Z t ∈R N*d , d represents the dimension of the first node.
[0158] Optionally, the second prediction model is implemented according to the following formula:
[0159]
[0160] in, B t ={e m |t - <t m ≤t}; For the second node, f ξ Let ξ and f be the encoder parameters in the second prediction model. θ This indicates that the encoder parameters in the first prediction model are θ and B. t The transaction triples within the first time period. To broaden the data, Including the transaction triples within the second time period and the transaction triples within the third time period, e m For t m The directed edge of time, For t m The starting point of time. For t m The destination node at time t - This refers to the last moment among multiple moments in the second time period. For the starting node at t - Memory state at any given moment The destination node is at t - The memory state at any given moment, M o,t M represents the memory state of the starting node at time t. d,t The memory state of the destination node at time t, and Let be the dimension represented by the second node.
[0161] Optionally, the loss value is calculated according to the following formula:
[0162]
[0163] Among them, H t =p θ (Z t L is the loss value, H t Let p represent the prediction result corresponding to the first node. θ Z is the predictor corresponding to the encoder in the first prediction model. t Let be the first node. Let be the representation vector of node i at time t in the second node representation. Let ||·|| be the prediction result corresponding to the representation vector of node i at time t in the prediction result of the first node representation, and ||·|| be the L2 norm of the vector.
[0164] Optionally, the second parameter is obtained according to the following formula:
[0165] ξ′=αξ+(1-α)θ;
[0166] Where θ is the first parameter, ξ′ is the updated second parameter, ξ is the original second parameter, and α is a hyperparameter.
[0167] Optionally, the step of converting the acquired raw transaction data into a continuous-time dynamic graph structure includes:
[0168] The acquired raw transaction data is converted into triples to obtain the initial triples;
[0169] Data cleaning is performed on the initial triplet to obtain the transaction triplet. The transaction triplet is a triplet data after removing abnormal data from the initial triplet. The abnormal data includes data that is missing any one of the origin node, destination node, and timestamp.
[0170] The transaction triples are converted into the dynamic graph structure.
[0171] exist Figure 4 In this document, a bus architecture (represented by bus 401) is used. Bus 401 may include any number of interconnected buses and bridges, linking various circuits including one or more processors represented by processor 405 and memory represented by memory 406. Bus 401 may also link various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and therefore will not be described further herein. Bus interface 404 provides an interface between bus 401 and transceiver 402. Transceiver 402 may be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by processor 405 is transmitted over a wireless medium via antenna 403, which further receives data and transmits data to processor 405.
[0172] Processor 405 is responsible for managing bus 401 and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. Memory 406 can be used to store data used by processor 405 during operation.
[0173] Optionally, the processor 405 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or a complex programmable logic device (CPLD).
[0174] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, this computer program implements the various processes of the above-described method for constructing a population flow prediction model, achieving the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0175] This application also provides a computer program product, including computer instructions. When the computer instructions are executed by a processor, they implement the various processes of the above-described method for constructing a population flow prediction model and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0176] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0177] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0178] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A method for constructing a crowd flow prediction model, characterized in that, The method comprises: Converting the obtained original transaction data into a dynamic graph structure of continuous time, the original transaction data comprising transaction triples composed of a starting location node, a destination node and a timestamp, the dynamic graph structure comprising graph nodes and directed edges, the graph nodes being used to represent the starting location node or the destination node, the directed edges being used to represent personnel flow information between the starting location node and the destination node, the directed edges carrying the timestamp; Inputting the dynamic graph structure into a first prediction model to obtain a first node representation corresponding to the dynamic graph structure, the first node representation being a vector representation determined according to transaction triples in a first time period in the dynamic graph structure; Inputting the dynamic graph structure into a second prediction model to obtain a second node representation corresponding to the dynamic graph structure, the second node representation being a vector representation determined according to transaction triples in the first time period, transaction triples in a second time period and transaction triples in a third time period in the dynamic graph structure, the second time period being an adjacent time period before the first time, and the third time period being an adjacent time period after the first time; Performing iterative training on the first prediction model and the second prediction model based on a loss value between a prediction result corresponding to the first node representation and the second node representation until the loss value is less than or equal to a preset threshold, and determining first parameters of the first prediction model and second parameters of the second prediction model after the iterative training as target parameters of a human flow prediction model; The loss value is calculated according to the following formula: ; wherein, ; L is the loss value, is the prediction result corresponding to the first node representation, is the predictor corresponding to the encoder in the first prediction model, is the first node representation, is the representation vector of node i at time t in the second node representation, is the prediction result corresponding to the representation vector of node i at time t in the prediction result corresponding to the first node representation, and ||·|| is the L2 norm of a vector.
2. The method of claim 1, wherein, The dynamic graph structure comprises a graph node set and a directed edge set, the graph node set comprising graph nodes at multiple time points in a t time period, and the directed edge set comprising directed edges at multiple time points in the t time period; The first prediction model is implemented according to the following formula: ; wherein, t represents a time period including a plurality of time instants; f() represents an encoder in the first prediction model, is the dynamic graph structure, V is the set of graph nodes, is a directed edge at a time instant, is a start location node at a time instant, is a destination node at a time instant, is the first node representation, is a representation vector of an i-th node among N graph nodes, and , d is a dimension of the first node representation.
3. The method of claim 2, wherein, The second prediction model is implemented according to the following formula: ; in, ( ); ; ; This is represented by the second node. This indicates that the encoder parameters in the second prediction model are , This indicates that the encoder parameters in the first prediction model are , The transaction triples within the first time period. To broaden the data, This includes transaction triples within the second time period and transaction triples within the third time period. for The directed edge of time, for The starting point of time. for The destination node at any given time. This refers to the last moment among multiple moments in the second time period. For the starting node in Memory state at any given moment For the destination node at Memory state at any given moment This represents the memory state of the starting node at time t. Let be the memory state of the destination node at time t, and , Let be the dimension represented by the second node.
4. The method according to any one of claims 1 to 3, characterized in that, The second parameters are obtained according to the following formula: ; wherein, is the first parameter, is the second parameter, is the second parameter, is a hyperparameter.
5. The method according to any one of claims 1 to 3, characterized in that, The converting of the obtained original transaction data into a dynamic graph structure of continuous time comprises: Converting the obtained original transaction data into an initial triple in a triple form to obtain the initial triple; Performing data cleaning on the initial triple to obtain the transaction triple, the transaction triple being triple data in which abnormal data in the initial triple is removed, the abnormal data including missing data in any one of the starting location node, the destination node and the timestamp; Converting the transaction triple into the dynamic graph structure. 6.A device for constructing a human flow prediction model, characterized in that, The device comprises: A conversion module configured to convert obtained original transaction data into a dynamic graph structure of continuous time, the original transaction data comprising transaction triples composed of a starting location node, a destination node and a timestamp, the dynamic graph structure comprising graph nodes and directed edges, the graph nodes being used to represent the starting location node or the destination node, the directed edges being used to represent personnel flow information between the starting location node and the destination node, the directed edges carrying the timestamp; The first input module is configured to input the dynamic graph structure into a first prediction model to obtain a first node representation corresponding to the dynamic graph structure, the first node representation being a vector representation determined according to transaction triplets in a first time period in the dynamic graph structure. The second input module is configured to input the dynamic graph structure into a second prediction model to obtain a second node representation corresponding to the dynamic graph structure, the second node representation being a vector representation determined according to transaction triplets in the first time period, transaction triplets in a second time period, and transaction triplets in a third time period in the dynamic graph structure, the second time period being a time period adjacent to the first time, and the third time period being a time period adjacent to the first time. The training module is configured to perform iterative training on the first prediction model and the second prediction model based on a loss value between a prediction result corresponding to the first node representation and the second node representation, until the loss value is less than or equal to a preset threshold, and determine first parameters of the first prediction model and second parameters of the second prediction model after the iterative training as target parameters of a population flow prediction model. The loss value is calculated according to the following formula: ; wherein, ; L is the loss value, is the prediction result corresponding to the first node representation, is the predictor corresponding to the encoder in the first prediction model, is the first node representation, is the representation vector of node i at time t in the second node representation, is the prediction result corresponding to the representation vector of node i at time t in the prediction result corresponding to the first node representation, and ||·|| is the L2 norm of a vector.
7. An electronic device, comprising: The transceiver and the processor are included, The processor is configured to convert acquired original transaction data into a dynamic graph structure of continuous time, the original transaction data including transaction triplets composed of a starting location node, a destination node, and a timestamp, and the dynamic graph structure including graph nodes and directed edges, the graph nodes being used to represent the starting location node or the destination node, and the directed edges being used to represent personnel flow information between the starting location node and the destination node, and the directed edges carrying the timestamp. The transceiver is configured to input the dynamic graph structure into a first prediction model to obtain a first node representation corresponding to the dynamic graph structure, the first node representation being a vector representation determined according to transaction triplets in a first time period in the dynamic graph structure. The transceiver is further configured to input the dynamic graph structure into a second prediction model to obtain a second node representation corresponding to the dynamic graph structure, the second node representation being a vector representation determined according to transaction triplets in the first time period, transaction triplets in a second time period, and transaction triplets in a third time period in the dynamic graph structure, the second time period being a time period adjacent to the first time, and the third time period being a time period adjacent to the first time. The transceiver is further configured to perform iterative training on the first prediction model and the second prediction model based on a loss value between a prediction result corresponding to the first node representation and the second node representation, until the loss value is less than or equal to a preset threshold, and determine first parameters of the first prediction model and second parameters of the second prediction model after the iterative training as target parameters of a population flow prediction model. The loss value is calculated according to the following formula: ; wherein, ; L is the loss value, is the prediction result corresponding to the first node representation, is the predictor corresponding to the encoder in the first prediction model, is the first node representation, is the representation vector of node i at time t in the second node representation, is the prediction result corresponding to the representation vector of node i at time t in the prediction result corresponding to the first node representation, and ||·|| is the L2 norm of a vector.
8. An electronic device, comprising: The transceiver and the processor are included, A processor, a memory, and a program stored on the memory and capable of running on the processor, the program being executed by the processor to implement the steps of the human flow prediction model construction method according to any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that, The computer program is stored on the computer readable storage medium and is executed by the processor to implement the steps of the human flow prediction model construction method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Traffic flow prediction model construction method and prediction method based on adaptive dynamic graph
CN116187555A
Multi-task learning urban crowd flow prediction method based on adaptive multi-graph fusion
CN117726070A