Pathogen propagation prediction method and system based on GraphSAGE model
By constructing an individual-place bipartite graph through the GraphSAGE model, the problem of insufficient modeling of inter-individual contact networks in existing technologies is solved, automatic learning and efficient prediction of complex transmission paths are achieved, and causal reasoning is supported for public health decision-making.
Patent Information
- Application Number
- CN202510621492.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-14
- Publication Date
- 2025-09-16
AI Technical Summary
Existing technologies make it difficult to effectively model complex contact networks between individuals, and are unable to automatically learn multi-layer transmission paths between places and individuals. In addition, the model lacks scalability and interpretability, and cannot support causal reasoning of epidemic prevention strategies.
The GraphSAGE model was used to construct an individual-place bipartite graph, identify stay points using DBSCAN clustering, calculate individual-place edge weights, perform stratified neighbor sampling and mean aggregation, and generate individual infection probability predictions.
It achieves efficient processing of large-scale social network data, captures complex individual interaction behaviors, has good generalization capabilities, and provides scientific prediction results to support public health decision-making.
Smart Images

Figure CN120656749A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and specifically to a pathogen transmission prediction method and system based on a GraphSAGE model. Background Art
[0002] In the long history of infectious disease prevention and control, traditional epidemiological models, such as the classic SIR and SEIR models, have played an important role. These models are based on the homogeneous mixing assumption, which simply assumes that individuals in the population have the same probability of infection and transmission, and that the contact patterns are uniformly distributed. However, in the real world, individual behaviors vary greatly, and the scope, frequency, and methods of social activities of different individuals vary. In addition, the spread of infectious diseases also presents complex dynamic changes in time and space. For example, during an epidemic, some people need to frequently contact a large number of people due to the nature of their work, while others are isolated at home for a long time. The infection risk and transmission ability of these two groups of people are very different. It is difficult for traditional models to accurately capture these differences and spatiotemporal dynamic transmission characteristics;
[0003] Although existing machine learning-based forecasting methods (such as ARIMA time series and random forest regression) can handle some nonlinear relationships, they have the following problems:
[0004] 1. It is difficult to effectively model the complex contact networks between individuals, resulting in insufficient accuracy in contact tracing;
[0005] 2. The ability to extract features from high-dimensional spatiotemporal data is limited, making it impossible to automatically learn multi-layered transmission paths between locations and individuals;
[0006] 3. The model has poor interpretability, making it difficult to support causal reasoning for epidemic prevention strategies;
[0007] Although graph neural networks (GNNs) have shown advantages in social network analysis, traditional GCN models have the following application bottlenecks:
[0008] 1. The calculation of the full-graph Laplacian matrix results in O(N 2 ) complexity, and cannot be expanded to city-scale networks with tens of millions of nodes;
[0009] 2. The direct learning mechanism limits the generalization ability of newly emerged nodes (such as migrant population);
[0010] 3. Module redundancy. Complex modules such as spatiotemporal attention and multi-task learning lead to high deployment costs. Summary of the Invention
[0011] (1) Technical problems solved
[0012] In response to the shortcomings of the existing technology, the present invention provides a pathogen transmission prediction method and system based on the GraphSAGE model, which has the advantages of providing timely and reliable dynamic monitoring data and early warning information, and solves the above technical problems.
[0013] (2) Technical solution
[0014] To achieve the above object, the present invention provides the following technical solution: a method for predicting pathogen transmission based on a GraphSAGE model, comprising the following steps:
[0015] S1: Data input: Collect individual GPS trajectory data and site scan data, identify stop points using the DBSCAN clustering algorithm, and extract individual movement paths, site visit records, and real-time pedestrian flow;
[0016] S2: Graph structure construction: Construct a bipartite graph containing individual nodes and venue nodes, where individual node attributes include daily travel distance and number of venue visits, venue node attributes include venue type and real-time pedestrian flow, and the weight of the edge between individual nodes and venue nodes, that is, the individual-venue edge weight, is calculated by the visit duration ratio formula, which is specifically expressed as:
[0017]
[0018] Among them, t stay : The actual length of time an individual stays at a venue (unit: hours), t max : The preset maximum stay time threshold (12 hours) is used for normalization, w up : The weight of the individual-place edge, reflecting the proportion of visit duration;
[0019] S3: Hierarchical neighbor sampling: for the target individual node, the first K1 visited places are selected as first-order neighbors according to the weight of the individual-place edge, and the Jaccard contact similarity between the place nodes is calculated. The first K2 are selected as second-order neighbors, and the edges with similarity higher than the threshold τ are dynamically pruned.
[0020] S4: Mean aggregation: For the target individual node u, a new embedding representation is generated by aggregating the features of itself and its neighboring nodes (first-order place nodes and second-order individual nodes). Aggregation formula Perform node feature aggregation
[0021] in Embedding representation of individual node u at layer l
[0022] N(u): The neighbor set of node u (including first-order place nodes and second-order individual nodes)
[0023] W: trainable weight matrix, initialized with He
[0024] ReLU: activation function, enhancing nonlinear expression capabilities;
[0025] S5: Infection probability prediction: The nodes aggregated by the lightweight GraphSAGE model are embedded into the input fully connected layer, the infection probability is output through the Sigmoid function, and the model is trained based on the cross-entropy loss.
[0026] As an optimal technical solution of the present invention, the GPS trajectory data collects latitude and longitude coordinates at intervals of 5 minutes, and the stay point identification parameters are set as: DBSCAN clustering neighborhood radius ε = 50 meters, minimum sample number min_samples = 3, and cluster areas with a stay time of more than 10 minutes are marked as place visit records.
[0027] As a preferred technical solution of the present invention, the Jaccard contact similarity calculation formula is:
[0028]
[0029] Where S(u) is the set of places visited by individual u, S(v) is the set of places visited by individual v, and J(u,v) represents the degree of overlap between the places visited by individuals u and v, with a value range of [0,1].
[0030] As a preferred technical solution of the present invention, the mean aggregation is implemented by two layers of GraphSAGE, with output dimensions of 64 and 32 respectively, the weight matrix W is initialized using He, and the bias term is initialized to zero.
[0031] The present invention also provides a pathogen transmission prediction system based on the GraphSAGE model, comprising:
[0032] Data input module, used to process GPS trajectory data and venue scan code data, extract individual movement paths, venue visit records and real-time pedestrian flow;
[0033] Simplified graph structure construction module: used to construct individual-place bipartite graphs and dynamically update node attributes and edge weights;
[0034] Lightweight GraphSAGE model module: used to perform hierarchical neighbor sampling, mean aggregation, and node embedding generation;
[0035] Prediction task module: used to output individual infection probability prediction results and achieve real-time updates through streaming deployment
[0036] Compared with the existing technology, the present invention provides a pathogen transmission prediction method and system based on the GraphSAGE model, which has the following beneficial effects:
[0037] The system constructed by this invention can efficiently process large-scale social network data and capture complex individual interaction behaviors through sophisticated graph structure modeling and innovative algorithm design. At the same time, the model has good generalization capabilities. Even when faced with newly emerging nodes, such as migrant populations, it can quickly generate reliable prediction results through reasonable initialization and neighbor sampling strategies. These prediction results can provide a scientific and accurate basis for public health decision-making, helping public health departments to formulate and adjust prevention and control strategies in a timely manner and effectively curb the spread of pathogens. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a schematic diagram of the process of the present invention;
[0039] Figure 2 The algorithm flow of GraphSAGE of the present invention;
[0040] Figure 3 Schematic diagram of the sampling and aggregation process of the GraphSAGE model of the present invention;
[0041] Figure 4 This is the structure of the present invention. DETAILED DESCRIPTION
[0042] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0043] See also Figure 1-4 ,A pathogen transmission prediction method based on the GraphSAGE model includes the following steps:
[0044] S1: Data input: Collect individual GPS trajectory data and venue scan data, identify stop points using the DBSCAN clustering algorithm, and extract individual movement paths, venue visit records, and real-time pedestrian flow;
[0045] S2: Graph structure construction: Construct a bipartite graph containing individual nodes and venue nodes, where individual node attributes include daily travel distance and number of venue visits, venue node attributes include venue type and real-time pedestrian flow, and the weight of the edge between individual nodes and venue nodes, that is, the individual-venue edge weight, is calculated by the visit duration ratio formula, which is specifically expressed as:
[0046]
[0047] Among them, t stayIndicates the actual length of time an individual stays in a place (unit: hours), t max Indicates the preset maximum stay time threshold (12 hours), used for normalization, w up represents the weight of the individual-venue edge, reflecting the proportion of visit duration;
[0048] S3: Hierarchical neighbor sampling: for the target individual node, the first K1 visited places are selected as first-order neighbors according to the weight of the individual-place edge, and the Jaccard contact similarity between the place nodes is calculated. The first K2 are selected as second-order neighbors, and the edges with similarity higher than the threshold τ are dynamically pruned.
[0049] S4: Mean aggregation: For the target individual node u, a new embedding representation is generated by aggregating the features of itself and its neighboring nodes (first-order place nodes and second-order individual nodes). Perform node feature aggregation,
[0050] in Embedding representation of individual node u at layer l
[0051] N(u): The neighbor set of node u (including first-order place nodes and second-order individual nodes)
[0052] W: trainable weight matrix, initialized with He
[0053] ReLU: activation function, enhancing nonlinear expression capabilities.
[0054] The present invention also provides a pathogen transmission prediction system based on the GraphSAGE model, comprising:
[0055] Data input module, used to process GPS trajectory data and venue scan code data, extract individual movement paths, venue visit records and real-time pedestrian flow;
[0056] Specifically include:
[0057] 1. GPS trajectory data processing:
[0058] (1) Data collection: Using the high-precision positioning system built into mobile devices, the latitude and longitude coordinates of individuals are collected at 5-minute intervals. This high-frequency collection method can record the individual's movement trajectory as completely as possible, providing rich data support for subsequent analysis. The collected data is stored in the format of (user ID, timestamp, latitude, longitude). This format facilitates data management and subsequent processing, and can clearly identify the individual to whom each data point belongs and the collection time.
[0059] (2) Stay point identification: The DBSCAN clustering algorithm is used to perform cluster analysis on continuous trajectory points. In practical applications, the parameters are set as neighborhood radius ε = 50 meters and minimum number of samples min_samples = 3. The selection of these two parameters is based on a large number of experiments and data analysis, and can accurately identify individual stay points in different urban environments and data distribution conditions. When the same user stays in a cluster area for more than 10 minutes continuously, the area is marked as a "place visit record" and the visit duration and location of the place are extracted. This means that within a radius of 50 meters, if there are at least 3 consecutive trajectory points, these points are considered to belong to the same cluster area. When the same user stays in a cluster area for more than 10 minutes continuously, the area is marked as a "place visit record" and the user's visit duration and precise location information of the place are extracted.
[0060] (3) Calculation of individual attributes:
[0061] Daily Distance: Calculates the user's total daily distance traveled using the coordinates of their track points. This calculation uses geospatial distance calculation formulas, such as the Haversine formula, to accurately calculate the distance between adjacent track points, taking into account the curvature of the Earth. The distances between all adjacent track points within a day are then accumulated to determine the user's total daily distance traveled, expressed in kilometers.
[0062] Number of Place Visits: By counting the marked "Place Visit Records", you can get the total number of times a user visits different places every day. During the counting process, you need to pay attention to removing duplicate records to ensure that each place is counted only once;
[0063] 2. Venue code scanning data processing
[0064] (1) Data integration: Extract key information (user ID, venue ID, entry time, and exit time) from the venue QR code scanning records. This information is the basis for constructing the individual-venue bipartite graph. By integrating this data, the association between individuals and venues can be clearly established, providing data support for subsequent analysis of the spread of pathogens within venues.
[0065] (2) Real-time flow calculation: The real-time flow of people in the venue is dynamically updated based on the timestamp of the code scan. A 5-minute window is used to count the number of people currently present. Specifically, within each 5-minute window, the number of people entering the venue is subtracted from the number of people leaving the venue to obtain the real-time flow of people within that window. This dynamic update method can promptly reflect changes in the flow of people in the venue and provide real-time data for analyzing transmission risks.
[0066] (3) Edge weight calculation:
[0067] The weight formula of the individual-site edge is:
[0068] (t max =12 hours)
[0069] Among them, t stay : The actual length of time an individual stays at the venue (unit: hours),
[0070] t max : The preset maximum stay time threshold (12 hours) is used for normalization.
[0071] w up : The weight of the individual-place edge, reflecting the proportion of visit duration
[0072] During the calculation process, the visit duration of each individual in each location needs to be compared with 12 hours to calculate the visit duration ratio. If the visit duration exceeds 12 hours, it is truncated and the weight is set to the maximum value of 1;
[0073] Individual-place graph construction module: used to construct an individual-place bipartite graph and dynamically update node attributes and edge weights;
[0074] Construction of the individual-place graph:
[0075] 1. Node definition and attributes
[0076] (1) Individual nodes:
[0077] Individual node attributes include daily distance traveled (continuous value) and number of venue visits (integer). These two attributes reflect the individual's activity characteristics and infection risk from different perspectives. Daily distance traveled reflects the range of an individual's activities; a larger range indicates a higher likelihood of exposure to pathogens. Number of venue visits reflects the frequency of an individual's interactions with different venues; a greater number of visits indicates a higher risk of infection.
[0078] (2) Location Node:
[0079] The attributes of a venue node include venue type (enclosed / semi-enclosed / open, coded as 0 / 1 / 2) and real-time human traffic (a dynamically updated value). Venue type is an important factor influencing pathogen transmission. Different types of venues have different ventilation conditions, occupancy density, and mobility, and their impact on transmission risk varies greatly. Real-time human traffic, as a dynamically updated value, can reflect the degree of gathering of people in a venue in real time, providing a key indicator for assessing transmission risk.
[0080] 2. Edge definition and dynamic update
[0081] (1) Individual-place edge:
[0082] The weight w of the individual-place edge up The weights are updated in real time based on scanned data. This is because the duration and activity of individuals within a venue are constantly changing, and updating the weights in real time can more accurately reflect the degree of connection between individuals and venues. The weights are reset and recalculated at dawn each day to avoid errors caused by data accumulation and ensure that the weights accurately reflect the actual situation of the day.
[0083] (2) Graph storage structure:
[0084] Adjacency lists are used to store graph structures in the format of (node ID, neighbor node ID list, edge weight list). Adjacency lists are a commonly used graph storage structure with the advantages of high storage efficiency and support for fast dynamic updates. In this system, adjacency lists are used to store graph structures, which can easily add and delete nodes and edges, improving the system's operating efficiency.
[0085] Lightweight GraphSAGE model module: used to perform hierarchical neighbor sampling, mean aggregation, and node embedding generation;
[0086] Implementation of lightweight GraphSAGE model
[0087] like Figure 2 As shown, the process of the GraphSAGE algorithm is divided into three steps:
[0088] Stratified neighbor sampling: filter first-order and second-order neighbors based on edge weights and Jaccard similarity.
[0089] Mean aggregation: Aggregate neighbor node features to generate an embedding representation of the target node.
[0090] Infection probability prediction: Map the final embedding into a probability value and output the individual infection risk.
[0091] 1. Stratified Neighbor Sampling Strategy
[0092] (1) Direct contact module (first-order neighbor):
[0093] For the target individual node u, according to the weight w of the individual-place edge up Sorting and selecting the top K1 = 5 frequently visited places as first-order neighbors. These five frequently visited places are the places the target individual most frequently visits and are also high-risk areas for pathogen transmission. By selecting these places as first-order neighbors, we can quickly locate the transmission environment closely related to the target individual.
[0094] (2) Indirect contact sampling (second-order neighbors):
[0095] The Jaccard contact similarity between individuals is calculated based on the real-time flow of people at the venue node p:
[0096]
[0097] Where S(u) is the set of places visited by individual u, S(v) is the set of places visited by individual v, J(u,v) represents the degree of overlap of the places visited by individuals u and v, and its value range is [0,1]. |S(u)∩S(v)| represents the number of places in the intersection of the sets of places visited by individuals u and v (i.e., the total number of places visited by the two people), and |S(u)∪S(v)| represents the total number of places in the union of all places visited by individuals u and v (i.e., the number of all different places visited by the two people).
[0098] Individuals with K2=10 similarities are selected as second-order neighbors, and the dynamic pruning threshold is set to τ=0.4 to remove edges with similarity lower than the threshold.
[0099] 2. Aggregation function design
[0100] Mean aggregation formula:
[0101]
[0102] in Embedding representation of individual node u at layer l
[0103] N(u): The neighbor set of node u (including first-order place nodes and second-order individual nodes)
[0104] W: trainable weight matrix, initialized with He
[0105] ReLU: activation function, enhancing nonlinear expression capabilities
[0106] MEAN means taking the mean of the embedded features of the target node and its neighboring nodes
[0107] Represents the embedding representation of node v at layer l
[0108] v∈N(u) means traversing all neighbor nodes v of u.
[0109] In practical applications, it is necessary to calculate the mean of the features of the neighboring nodes of each node. When initializing the parameters, the weight matrix W is initialized using He. This initialization method can effectively avoid the gradient vanishing and gradient exploding problems and improve the training efficiency of the model. The bias term is initialized to zero, which is a common initialization method that can simplify the model training process. The model uses a two-layer GraphSAGE with output dimensions of 64 and 32 respectively, which can ensure model accuracy while taking into account computational efficiency.
[0110] Prediction task module: used to output individual infection probability prediction results and achieve real-time updates through streaming deployment;
[0111] Implementation of the prediction task module
[0112] 1. Infection probability prediction
[0113] The final node embedding is mapped to infection probability through a fully connected layer:
[0114]
[0115] in The final embedding (dimension 32) of individual u after two layers of GrapSAGE aggregation, W out ,b out : The weight and bias parameters of the fully connected layer, Sigmoid: maps the output to a probability value of [0,1], representing the individual's infection risk in the next 24 hours, The infection probability predicted by the model.
[0116] The specific implementation method is to input the node features output by the lightweight GraphSAGE model into a fully connected layer. After a series of linear transformations and activation functions, the output is finally mapped to a probability value between 0 and 1 using the Sigmoid function. The prediction target is the probability of infection of an individual within the next 24 hours. This prediction can provide timely warning information to public health departments, helping them to take appropriate prevention and control measures.
[0117] 2. Model Training
[0118] Loss function: cross entropy loss
[0119] Among them, y u : The true label of individual u, The infection probability predicted by the model, ∑ u∈V It means to accumulate and sum the loss values of all individual nodes in the set V.
[0120] 3. Real-time prediction and deployment
[0121] The graph data is updated every hour, and the model processes the new data in a streaming manner.
[0122] New nodes (such as migrant population) are embedded by zero initialization and prediction results are quickly generated based on neighbor sampling;
[0123] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A pathogen transmission prediction method based on the GraphSAGE model, characterized by: The following steps are involved: S1: Data input: Collect individual GPS trajectory data and venue scan data, identify stop points using the DBSCAN clustering algorithm, and extract individual movement paths, venue visit records, and real-time pedestrian flow; S2: Graph structure construction: Construct a bipartite graph containing individual nodes and venue nodes, where individual node attributes include daily travel distance and number of venue visits, venue node attributes include venue type and real-time pedestrian flow, and the weight of the edge between individual nodes and venue nodes, that is, the individual-venue edge weight, is calculated by the visit duration ratio formula, which is specifically expressed as: Among them, t stay Indicates the actual length of time an individual stays in a place, t max Indicates the preset maximum stay time threshold, used for normalization, w up represents the weight of the individual-site edge; S3: Hierarchical neighbor sampling: for the target individual node, the first K1 visited places are selected as first-order neighbors according to the weight of the individual-place edge, and the Jaccard contact similarity between the place nodes is calculated. The first K2 are selected as second-order neighbors, and the edges with similarity higher than the threshold τ are dynamically pruned. S4: Mean aggregation: by formula Perform node feature aggregation; in, Represents the embedding of individual node u in the l+1 layer, ReLU represents the activation function, W represents the trainable weight matrix, N(u) represents the neighbor set of node u, ∪ represents the union, and MEAN represents the mean of the embedding features of the target node and its neighbor nodes. represents the embedding representation of node v at layer l, v∈N(u) represents traversing all neighbor nodes v of u; S5: Infection probability prediction: The aggregated node embedding is mapped to the individual's infection probability in the next 24 hours, the binary classification result is output through the Sigmoid function, and the model is trained based on the cross-entropy loss.
2. The pathogen transmission prediction method based on the GraphSAGE model according to claim 1, characterized in that: The GPS trajectory data collects latitude and longitude coordinates at 5-minute intervals, and the stay point identification parameters are set as: DBSCAN clustering neighborhood radius ε=50 meters, minimum sample number min_samples=3, and cluster areas with a stay time of more than 10 minutes are marked as place visit records.
3. The pathogen transmission prediction method based on the GraphSAGE model according to claim 1, characterized in that: The Jaccard contact similarity calculation formula is: Where S(u) is the set of places visited by individual node u, S(v) is the set of places visited by individual node v, J(u,v) represents the degree of overlap of places visited by individual node u and individual node v, and its value range is [0,1]. |S(u)∩S(v)| represents the number of places in the intersection of the sets of places visited by individual nodes u and v, and |S(u)∪S(v)| represents the total number of places in the union of all places visited by individual nodes u and v.
4. The pathogen transmission prediction method based on the GraphSAGE model according to claim 1, characterized in that: The mean aggregation is implemented by two layers of GraphSAGE, with output dimensions of 64 and 32 respectively. The weight matrix W is initialized with He and the bias term is initialized to zero.
5. A pathogen transmission prediction system based on the GraphSAGE model, characterized by: include: Data input module, used to process GPS trajectory data and venue scan code data, extract individual movement paths, venue visit records and real-time pedestrian flow; Simplified graph structure construction module: used to construct individual-place bipartite graphs and dynamically update node attributes and edge weights; Lightweight GraphSAGE model module: used to perform hierarchical neighbor sampling, mean aggregation, and node embedding generation; Prediction task module: used to output individual infection probability prediction results and achieve real-time updates through streaming deployment.