A crowd activity prediction method based on dynamic graph assisted neural differential model
By using a dynamic graph-assisted neural differential model to predict crowd activity, this approach addresses the shortcomings of existing models in predicting complex scenarios, achieving flexible and robust prediction results and adapting to non-periodic events such as epidemic outbreaks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2023-03-10
- Publication Date
- 2026-06-16
AI Technical Summary
Existing crowd activity prediction models struggle to cope with complex and ever-changing scenarios, such as non-cyclical events like pandemic outbreaks and major holidays, resulting in poor prediction performance.
A neural differential model based on dynamic graphs is adopted, which performs continuous modeling through neural differential equations and combines dynamic graph mechanisms to improve the model's ability to perceive events. A dynamic graph structure is constructed to adapt to complex and ever-changing application scenarios.
It achieves flexible crowd activity prediction in complex and ever-changing scenarios, with strong robustness and prediction accuracy. It can effectively capture the fluctuations brought about by events and adapt to the impact of major events.
Smart Images

Figure CN116467635B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of trajectory prediction technology, specifically relating to a method for predicting crowd activity based on a dynamic graph-assisted neural differential model. Background Technology
[0002] Accurate prediction and modeling of population activities is of great significance in urban planning, traffic control, and many other areas. Particularly for epidemic control, predictive models can detect potential risk areas, allowing relevant departments to intervene promptly, manage crowds, and significantly reduce the likelihood of large-scale outbreaks. Existing population activity prediction models are mainly divided into traditional statistical models and deep learning models. The former completes the prediction task by fitting a probability distribution model with unknown parameters but a known form, or by specifically analyzing and modeling the destinations of different population activities. The latter utilizes deep neural networks to learn the general regularity, i.e., periodic characteristics, of human activity patterns in the latent space. However, large-scale epidemics and other emergencies make it difficult for the above-mentioned predictive modeling methods to achieve satisfactory prediction results. This is because these events not only greatly disrupt the regularity of population activities but also make their patterns complex and variable rather than simple.
[0003] Therefore, it is necessary to improve the model's ability to perceive events that can have a significant impact on crowd activity models, so as to adapt it to complex and ever-changing application scenarios.
[0004] The purpose of this invention is to improve existing research and technologies to make them applicable to new scenarios, and to propose a dynamic graph-assisted neural differential model for crowd activity prediction. This method utilizes the continuous modeling characteristics of neural differential equations to perform temporal modeling of crowd activity patterns in the latent space, a scheme that better reflects actual development processes compared to previous deep models. Furthermore, by introducing a dynamic graph mechanism, the model's ability to perceive non-periodic events such as epidemic outbreaks and major holidays is enhanced, thus adapting to real-world application scenarios. Summary of the Invention
[0005] The purpose of this invention is to provide a crowd activity prediction method based on a dynamic graph-assisted neural differential model, to solve the technical problem that existing models cannot cope with complex and ever-changing scenarios. Specifically, the technical solution of this invention is as follows:
[0006] A method for predicting crowd activity based on a dynamic graph-assisted neural differential model, the method comprising:
[0007] Read historical data on population activity during the cleanup and collect and organize relevant event metrics.
[0008] Historical population activity data and corresponding event indicator data are normalized to obtain a standard dataset, which is then divided into a training set and a validation set for model training and parameter selection, respectively.
[0009] The model is trained based on the training set to obtain an initial prediction model;
[0010] The initial prediction model is tuned based on the validation set. The network weight parameters of the model are determined through multiple validations. The model that performs best on the validation set is selected as the final prediction model.
[0011] The final prediction model outputs the future movement trajectory of the population.
[0012] Furthermore, the historical population activity data and corresponding event indicator data are aggregated at different temporal and spatial granularities according to the prediction accuracy requirements to obtain historical training data, which includes T time periods and N regions. The data for the i-th time period is denoted as {X}. t Its dimensions are Where t = 1, 2, 3, ..., T, d m This represents the total number of features for both crowd movement and event metrics.
[0013] Furthermore, the data in the training and validation sets are further divided into training samples of equal time length. Including historical observations and remaining observations Among them historical observation Used for model input, remaining observations As the true value, l is used to calculate the model prediction error. c l represents the historical observation length of the sample. p The sample true value length is used; the model parameters are randomly initialized in preparation for subsequent model training.
[0014] Furthermore, based on the given length l r Dynamic window, l r To determine the recent historical observation length of the sample, the model input is divided into two parts: the earlier observations... The state initialization module input to the model generates the state variables H0 of the neural differential equation module, the adjacency matrix A0 of the dynamic graph, and the state variables Z0 of the control module; recent observations are then used. Each input is fed into the control module. For each input, the control module integrates the current input X. t (t=l c -l r +1, l c -l r +2, ..., l c The state variable Z at the previous time step t-1 And the predicted quantity Ht Generate the current state variable Z of the control module. t And thus generate the dynamic graph adjacency matrix A. t The latter is used to drive the neural differential equation module to generate the state variable X. t+1 Where i = 1, 2, 3, ... l c The control module and the neural differential equation module alternate, iterating until all observations are updated; afterwards, the neural differential equation is applied to the adjacency matrix. forward inference under control p Step to obtain the predicted quantity Predicted quantities and control module state quantities Together, they are fed into the output module to obtain the final prediction. Specifically, the state initialization module obtains the prediction through early observations. Estimating the state quantities of the initial neural differential equation module Control module status variables and dynamic graph adjacency matrix The specific calculation formula is as follows:
[0015]
[0016]
[0017]
[0018]
[0019] Where d h With d z These represent the feature dimensions of the state variables of the neural differential equation module and the control module, respectively, d. f It represents the dimension of the latent space features, and φ(·) is the tanh activation function. These are trainable parameters. l = 0, 1, 2, ..., L represents the features extracted after the l-th layer, Φ (p,s,s) (·) is a 3D convolution operation with a kernel size of (p, s, s), [,] splits the vector into two vectors from the feature dimension, MaxPool is the pooling layer applied to the time dimension, and Corr calculates the correlation matrix; by splitting the features after the pooling layer, Z0 and H0 can be obtained; by calculating the correlation between regional features, A0 can be obtained.
[0020] Specifically, the control module determines its state based on the previous state value. Current input and forecast Output the current state of itself. Adjacency Matrix The specific calculation formula is as follows:
[0021] F t =φ(X t W f +b f )
[0022]
[0023]
[0024]
[0025]
[0026]
[0027] Where [||] concatenates the vectors according to their feature dimensions. These are the training parameters, and K is the number of parallel gated computation units. These are the merged features, where i represents the gating computation unit number, j represents the gate, ⊙ represents Hamiltonian multiplication, C is the weight matrix, and M... s , It represents the static features of the learnable region, where ψ represents the sigmoid activation function. The formula is as follows:
[0028] Specifically, the neural differential equation module is based on control A t and the current state quantity H t Derivation of the state quantity H at future time moments t+1 The specific calculation formula is as follows:
[0029]
[0030]
[0031] Where τ is the integral variable with a range of values in the range [t, t+1]. The learnable parameter f(·) is a second-order approximation of the differential equation, and its original form is:
[0032] f(H τ A t H t )=ln(A t +I)H τ +(A t -ln(A t +I))H t .
[0033] Furthermore, the historical population activity data has object, location, and time attributes, including information reflecting population activity patterns; event indicators include information reflecting event characteristics and trends.
[0034] Furthermore, the validation set training is performed at most a given number of times, with each training session based on the model obtained from the previous training session. The new model obtained after each training session is then validated on the next validation set, and the model that performs best on the validation set is selected as the final prediction model.
[0035] Compared with the prior art, the present invention has the following advantages:
[0036] 1) Using discrete observation data, it is possible to continuously model crowd activities and provide predictions of crowd activity indicators at different scales, which has strong flexibility.
[0037] 2) It can capture the fluctuations in population activity caused by learning events, and performs well in scenarios without regular periodicity, such as the outbreak of an epidemic;
[0038] 3) This method generates a dynamic graph structure through a control module, thereby introducing the disturbance of events on crowd activities into the model, making the model more robust and still having good predictive performance in scenarios with the impact of major events. Attached Figure Description
[0039] Figure 1 This is a flowchart of the population activity index prediction method of the present invention;
[0040] Figure 2 This is a graph showing the change in verification error of the model in the embodiment of the present invention with the number of training iterations. Detailed Implementation
[0041] The following description, in conjunction with the accompanying drawings, further illustrates the present invention's method for predicting crowd activity based on a dynamic graph-assisted neural differential model.
[0042] like Figure 1 As shown, a method for predicting crowd activity based on a dynamic graph-assisted neural differential model is described, the method comprising:
[0043] Step 1: Read and clean historical population activity data, and collect and organize the corresponding event indicator data. Aggregate the above historical population activity data and corresponding event indicator data at different time and spatial granularities according to the prediction accuracy requirements to obtain historical training data, containing T time periods and N regions. The data for the i-th time period is denoted as {X}. t Its dimensions are Where t = 1, 2, 3, ..., T, d mThis refers to the total number of features for both population movement metrics and event metrics. Specifically, historical population activity data must have attributes such as object, location, and timestamp, including but not limited to user access records for different POIs, their own geographical location reported when using mobile applications, and activity records recorded by service providers when making calls or sending text messages, all of which reflect population activity patterns. Event metrics include but are not limited to information that reflects the characteristics and trends of events, such as the number of people infected with infectious diseases, holiday arrangements, and cold wave levels.
[0044] Step 2: After normalizing the data from Step 1, divide it into training and validation sets according to a reasonable ratio for model training and parameter selection. The data in both sets are further split into training samples of equal time length. Among them historical observation Used for model input, remaining observations The true value is used to calculate the model prediction error, where l c l represents the historical observation length of the sample. p This is the length of the true sample value. Randomly initialize the model parameters in preparation for subsequent model training.
[0045] Step 3: Train the model using the training set to obtain the initial prediction model. Each model prediction follows this process: based on a given length l r Dynamic window, l r To determine the recent historical observation length of the sample, the model input is divided into two parts: the earlier observations... The state initialization module input to the model generates the state variables H0 of the neural differential equation module, the adjacency matrix A0 of the dynamic graph, and the state variables Z0 of the control module; recent observations are then used. Each input is fed into the control module. For each input, the control module integrates the current input X. t (t=l c -l r +1, l c -l r +2, ..., l c The state variable Z at the previous time step t-1 And the predicted quantity H t Generate the current state variable Z of the control module. t And thus generate the dynamic graph adjacency matrix A. t The latter is used to drive the neural differential equation module to generate the state variable X. t+1 Where i = 1, 2, 3, ... l c The control module and the neural differential equation module alternate, iterating until all observations are updated; afterwards, the neural differential equation is applied to the adjacency matrix. forward inference under control p Step to obtain the predicted quantity Predicted quantities and control module state quantities They are then fed into the output module to obtain the final initial prediction model.
[0046] Step 4: Tune the initial prediction model using the validation set and select the final prediction model. Through Step 3, a model prediction can be obtained for each training sample. The error between the model's predicted output and the true value for all samples in the training set is calculated, and gradient backpropagation is performed to update the model parameters, constituting one training iteration. This process is repeated a maximum of a given number of times, such as 300 training iterations. Each training iteration builds upon the model obtained from the previous iteration, and the new model obtained after each training iteration is validated on the validation set. The model that performs best on the validation set is selected as the final prediction model.
[0047] Step 5: Output the future population activity trajectory through the final prediction model.
[0048] Specifically, the various model modules are as follows:
[0049] State initialization module: This module enables early observation... Estimating the state quantities of the initial neural differential equation module Control module status variables and dynamic graph adjacency matrix The specific calculation formula is as follows:
[0050]
[0051]
[0052]
[0053]
[0054] Where d h With d z These represent the feature dimensions of the state variables of the neural differential equation module and the control module, respectively, d. f It represents the dimension of the latent space features, and φ(·) is the tanh activation function. These are trainable parameters. l = 0, 1, 2, ..., L represents the features extracted after the l-th layer, Φ (p,s,s) (·) is a 3D convolution operation with a kernel size of (p, s, s). [,] splits the vector into two vectors from the feature dimension. MaxPool is a pooling layer applied to the time dimension. Corr calculates the correlation matrix. By splitting the features after the pooling layer, Z0 and H0 can be obtained; by calculating the correlation between regional features, A0 can be obtained.
[0055] Control module: This module can determine its own state based on the previous moment's data. Current input and forecast Output the current state of itself. Adjacency Matrix The specific calculation formula is as follows:
[0056] F t =φ(X t W f +b f )
[0057]
[0058]
[0059]
[0060]
[0061]
[0062] Where [||] concatenates the vectors according to their feature dimensions.
[0063]
[0064] These are the training parameters, and K is the number of parallel gated computation units. These are the merged features, where i represents the gating computation unit number, j represents the gate, ⊙ represents Hamiltonian multiplication, C is the weight matrix, and M... s , It represents the static features of the learnable region, where ψ represents the sigmoid activation function. The formula is as follows:
[0065] Neural Differential Equation Module: This module allows you to control A... t Current state variable H t Derivation of the state quantity H at future time moments t+1 The specific calculation formula is as follows:
[0066]
[0067]
[0068] Where τ is the integral variable with a range of values in the range [t, t+1]. The learnable parameter f(·) is a second-order approximation of the differential equation, and its original form is:
[0069] f(Hτ A t H t )=ln(A t +I)H τ +(A t -ln(A t +I))H t .
[0070] The following are specific embodiments of the prediction method of the present invention:
[0071] This embodiment processes user trajectory data collected from January 1, 2020 to March 31, 2022, and the number of confirmed cases of a certain respiratory infectious disease during this period, obtained from a certain location. The specific variables and related data information included in the dataset are shown in Table 1 and Table 2.
[0072] Table 1: Partial User Trajectory Data for a Certain Location
[0073]
[0074]
[0075] Table 2. Cumulative number of users diagnosed with a certain respiratory infectious disease in a certain area from January 1, 2020 to May 31, 2020:
[0076] date Total number of confirmed cases 20200101 0 20200102 0 … … 20200629 68135 20200630 68135 … …
[0077] In this embodiment, the dataset used for predicting crowd activity is the trajectory data of users in a certain location, and the method result is the future crowd activity-related index. The detailed implementation steps are as follows:
[0078] Step 1: Read and clean historical population activity data, and collect and organize the corresponding event indicator data. Based on the required prediction accuracy, aggregate the above data by day and seven-bit geohash geographic units (approximately 0.94 × 0.61 km²) to obtain training data, containing T time periods and N regions. The data for time period t is denoted as {X... i Its dimensions are Where i = 1, 2, 3, ..., T, d m This represents the total number of features for both crowd movement and event metrics; the data provided in Tables 1 and 2 includes all the necessary information required in this step.
[0079] Step 2: After normalizing the data from Step 1, divide the data into training and validation sets in a 7:3 ratio (or 8:2, these are the system defaults) for model training and parameter selection. The data in both sets are further split into training samples of equal time length. Among them historical observation Used for model input, remaining observations The true values are used to calculate the model prediction error. Model parameters are randomly initialized in preparation for subsequent model training. The selection of experimental parameters is shown in Table 3.
[0080] Table 3 Parameter Selection for Examples:
[0081] Example parameters Value <![CDATA[Sample historical observation length l c > 14 <![CDATA[True length l of the sample p > 1 <![CDATA[Length l of recent historical observations of the sample r > 7
[0082] Each sample shown in the table above includes lc, lp, and lr. For example, the length is 21. The target scenario is that the model inputs 14 days of historical observations and then outputs the prediction results 7 days later. The 14 is further divided into the earlier 10 days and the 4 days closest to the required prediction number, which are input into the two modules of the model respectively, i.e., lc=14, lp=7, lr=4.
[0083] Step 3: Each model prediction follows this process. Based on the given dynamic window length l r The model input is divided into two parts: early observations. The state initialization module input to the model generates the state variables H0 of the neural differential equation module, the adjacency matrix A0 of the dynamic graph, and the state variables Z0 of the control module; recent observations are then used. Each input is fed into the control module. For each input, the control module integrates the current input X. t (t=l c -l r +1, l c -l r +2, ..., l c The state variable Z at the previous time step t-1 And the predicted quantity H t Generate the current state variable Z of the control module. t And thus generate the dynamic graph adjacency matrix A. t The latter is used to drive the neural differential equation module to generate the state variable X. t+1 Where i = 1, 2, 3, ... l c The control module and the neural differential equation module alternate, iterating until all observations are updated; afterwards, the neural differential equation is applied to the adjacency matrix. forward inference under control p Step to obtain the predicted quantity Predicted quantities and control module state quantities The data are fed into the output module to obtain the final prediction. The range of model parameters is determined based on the size of the dataset, and the data in Table 4 below are selected based on the experimental results.
[0084] Table 4 Model Hyperparameter Selection:
[0085]
[0086] Step 4: Train and select the model. Following Step 3, each training sample yields a model prediction. The root mean square error (RMSE) of the model's predicted outputs for all samples in the training set is calculated and compared to the true values. Gradient backpropagation is then performed to update the model parameters, constituting one training iteration. A maximum of 300 training iterations are conducted. Each training iteration builds upon the model obtained from the previous iteration, and the new model is validated on a validation set. The model that performs best on the validation set is selected as the final prediction model. The validation error of all models is as follows: Figure 2 As shown, the model trained 219 times was selected as the final model. The root mean square error (RMSE) compared to the true value was 792, the mean absolute error (MAO) was 427, and the relative error was 5.12%, achieving good prediction results. According to... Figure 2 By analyzing the model performance under different training iterations, model selection can be performed to avoid overfitting.
[0087] This invention is a crowd activity prediction method based on a dynamic graph-assisted neural differential model. It constructs neural differential equations to model crowd activity patterns and uses a control module to generate a dynamic graph structure to introduce the perturbation of crowd activity by events into the model, thereby obtaining robust crowd activity prediction results.
Claims
1. A crowd activity prediction method based on dynamic graph assisted neural differential model, characterized in that, The method includes: Read historical data on population activity during the cleanup and collect and organize relevant event metrics. Historical population activity data and corresponding event indicator data are normalized to obtain a standard dataset, which is then divided into a training set and a validation set for model training and parameter selection, respectively. The model is trained based on the training set to obtain an initial prediction model; The initial prediction model is tuned based on the validation set. The network weight parameters of the model are determined through multiple validations. The model that performs best on the validation set is selected as the final prediction model. The final prediction model outputs the future movement trajectory of the population. Based on the given length Dynamic window, To determine the recent historical observation length of the sample, the model input is divided into two parts: the earlier observations... The state initialization module input to the model generates the state variables of the neural differential equation module. Adjacency matrix of dynamic graph and control module status variables Recent observations Each input is fed into the control module, and for each input, the control module integrates the current input. ( The state quantity at the previous time step and forecast Generate the current state of the control module. This generates a dynamic graph adjacency matrix. The latter is used to drive the neural differential equation module to generate state variables. ,in The control module and the neural differential equation module alternate, iterating until all observations are updated; afterwards, the neural differential equation is applied to the adjacency matrix. forward inference under control Step to obtain the predicted quantity Predicted quantities and control module state quantities They are then fed into the output module to obtain the final prediction.
2. The method for predicting crowd activity based on a dynamic graph-assisted neural differential model according to claim 1, characterized in that, The historical population activity data and corresponding event indicator data are aggregated at different temporal and spatial granularities according to the prediction accuracy requirements to obtain historical training data, including... Each period, The region, the first The data for the time period is denoted as Its dimensions are ,in This represents the total number of features for both crowd movement and event metrics.
3. The method for predicting crowd activity based on a dynamic graph-assisted neural differential model according to claim 2, characterized in that, The data in the training and validation sets are further divided into training samples of equal time length. Including historical observations and remaining observations Among them, historical observation Used for model input, remaining observations Used as the true value to calculate the model prediction error. The length of historical observations of the sample. The sample true value length is used; the model parameters are randomly initialized in preparation for subsequent model training.
4. The method for predicting crowd activity based on a dynamic graph-assisted neural differential model according to claim 3, characterized in that, The state initialization module achieves this through early observation. Estimating the state quantities of the initial neural differential equation module Control module status variables and dynamic graph adjacency matrix The specific calculation formula is as follows: , , , , in, and These represent the feature dimensions of the state variables of the neural differential equation module and the control module, respectively. It is the size of the latent space feature dimension. It is the tanh activation function. These are trainable parameters. It is after the first Features after layer feature extraction It is a 3D convolution operation with a kernel size of . [ , ] represents splitting a vector into two vectors based on its feature dimension. The pooling layer operates on the time dimension, and Corr calculates the correlation matrix. By splitting the features after the pooling layer, we can obtain... and By calculating the correlation between regional characteristics, we can obtain... .
5. The method for predicting crowd activity based on a dynamic graph-assisted neural differential model according to claim 4, characterized in that, The control module is based on its own state value at the previous moment. Current input and the predicted amount Output the current state of itself. Adjacency Matrix The specific calculation formula is as follows: , , , , , , Here, [ || ] concatenates the vectors according to their feature dimensions. , , , These are the training parameters, and K is the number of parallel gated computation units. These are the characteristics after the merger. Represents which gated computational unit, The character represents which phylum it belongs to. Represents Hamiltonian multiplication. This is the weight matrix. It is a learnable static feature of the region. The formula for the sigmoid activation function is: .
6. The method for predicting crowd activity based on a dynamic graph-assisted neural differential model according to claim 5, characterized in that, The neural differential equation module is based on control. and current state quantity Derivation of the state quantity at future time moments The specific calculation formula is as follows: , , in, The range of values is [ The integral variable of ] Learnable parameters It is a second-order approximation of the differential equation, and its original form is:
7. A method for predicting crowd activity based on a dynamic graph-assisted neural differential model according to any one of claims 1-6, characterized in that, The historical population activity data has object, location, and time attributes, including information reflecting population activity patterns; event indicators include information reflecting event characteristics and trends.
8. A method for predicting crowd activity based on a dynamic graph-assisted neural differential model according to any one of claims 1-6, characterized in that, The validation set training is performed at most a given number of times. Each training is based on the model obtained from the previous training, and the new model obtained after each training is validated on the next validation set. The model that performs best on the validation set is selected as the final prediction model.