Disease prediction research based on improved comparative learning

By improving contrast learning and adaptive high-frequency masking technology, a global disease co-occurrence graph is constructed and multiple diagnostic roles are defined, the problem that existing models are underutilized in the EHR data is solved, and the accuracy of disease prediction and the robustness of the model is improved.

CN120260896APending Publication Date: 2025-07-04YUNNAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510183699.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-19
Publication Date
2025-07-04

AI Technical Summary

Technical Problem

When using EHR data to predict diseases, existing deep learning models fail to fully explore the global graph structure and disease dynamics among diseases, resulting in insufficient prediction accuracy and inefficient efficiency in processing large-scale data.

Method used

The improved contrast learning method is adopted to enhance disease embedding through adaptive high-frequency masks, build a global disease co-occurrence graph, and define three diagnostic roles: persistent disease, emerging neighbor disease and emerging unrelated disease. The patient embedding vector is calculated in combination with the attention mechanism to predict health time.

Benefits of technology

It improves the accuracy of disease prediction and the generalization ability of the model, can sensitively capture the changes in the fine-grained characteristic of the disease, improves the prediction ability of abnormalities and critical time points, and enhances the robustness of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120260896A_ABST
    Figure CN120260896A_ABST
Patent Text Reader

Abstract

The invention discloses a disease prediction research based on improved comparative learning, which comprises the following steps: acquiring and sorting EHR data, and carrying out code conversion on diagnosis information of a patient to form a data set format; constructing a global disease co-occurrence graph, performing data enhancement on disease embedding by setting a self-adaptive high-frequency mask from the angle of a frequency domain by adopting comparative learning, taking a neighbor node of each anchor point as a positive signal, and adding comparative loss into a loss function; extracting three dynamic sub-graphs from the global disease co-occurrence graph; defining three diagnosis roles according to changes of node attributes in the dynamic subgraph; setting a corresponding transfer function to extract historical context information; calculating a patient embedding vector by adopting an attention-based method; and inputting the patient embedded vector into a classifier for health time prediction. Potential values in the EHR data are fully mined, and a disease dynamic change rule is explored, so that more powerful support is provided for medical decision making.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of medical data processing and analysis, and particularly relates to a disease prediction study based on improved contrastive learning. Background Art

[0002] In the current era of the booming development of digital medicine, electronic health records (EHRs) have been widely popularized in various medical institutions. It covers rich patient visit information, including multi-dimensional data such as diagnosis details, treatment processes, examination results, etc., providing a vast and extremely valuable information resource for medical research and practice. With the rapid progress of information technology, deep learning technology has emerged in the field of health time prediction with its powerful data processing ability and pattern recognition ability, attracting the attention of many researchers. Currently, most of the health event prediction work based on deep learning focuses on the historical diagnosis information in EHR data, attempting to extract valuable patterns and rules from it to predict future possible health events, such as the occurrence and development of diseases, the readmission risk of patients, mortality, etc. However, although deep learning models have achieved certain results to some extent, the existing work still faces many severe challenges and obvious limitations.

[0003] Regarding the problem of insufficient utilization of disease combination information: Most studies regard diagnoses as independent diseases and do not fully consider the clinical relationships between diseases. Common deep learning models such as GRAM, Timeline, and G-BERT, etc., fail to effectively utilize the global graph structure formed by disease combinations when performing health event predictions, and this structure contains hidden patterns between diseases, which is of great significance for prognosis judgment. For example, in actual medical practice, diseases such as hypertension and heart failure often occur simultaneously, and their combination reflects potential disease associations, but the existing models do not fully explore this information.

[0004] Regarding the situation where the disease dynamics have not been fully explored: The development of diseases is not static. The same diagnosis may have different priorities at different visit times, and diseases may appear or disappear at different stages of the visit. Some models assume that the disease representations remain unchanged during different patient visits, ignoring the dynamic changes of diseases. For example, EHR datasets such as MIMIC-Ⅲ provide diagnostic priority indicators, indicating that the impact of diseases on patients changes over time, but the existing models have not captured these dynamic information and it is difficult to accurately predict the disease development trend. Secondly, the performance of the existing models needs to be improved: In the health event prediction task, the existing models have deficiencies in terms of accuracy, etc., and some models face efficiency challenges in processing large-scale EHR data due to parameter settings or structural problems, such as high storage and computational costs. For example, some models have limited prediction accuracy in tasks such as predicting diagnoses and heart failure, and cannot meet clinical needs. Summary of the Invention

[0005] The objective of the present invention is: aiming at the above problems existing currently, a disease prediction study based on improved contrastive learning is provided. In the method for predicting health events with context awareness based on the transfer function on the improved dynamic disease map, contrastive learning is added. This contrastive learning performs data augmentation on disease embeddings by setting an adaptive high-frequency mask from the frequency domain perspective. At the same time, the neighbor nodes of each anchor point are used as positive signals. By adding the contrastive loss to the loss function, the accuracy of patient disease prediction is improved without increasing the model parameters.

[0006] The technical solution of the present invention is as follows:

[0007] A disease prediction study based on improved contrastive learning, comprising the following steps:

[0008] Obtain and organize EHR data, convert the diagnosis information of patients according to a preset disease classification system for encoding to form a dataset format, and preprocess the data;

[0009] Construct a global disease co-occurrence graph based on the historical diagnosis data of patients. Use contrastive learning to perform data augmentation on disease embeddings by setting an adaptive high-frequency mask from the frequency domain perspective. Take the neighbor nodes of each anchor point as positive signals, and add the contrastive loss to the loss function;

[0010] For each visit of each patient, extract three dynamic subgraphs from the global disease co-occurrence graph that can integrate the local context of the visit and the context information of the global EHR dataset; according to the changes in the node attributes in the dynamic subgraph, define three diagnostic roles: persistent diseases, emerging neighbor diseases, and emerging unrelated diseases; set corresponding transfer functions for different roles to extract historical context information;

[0011] Integrate all the visit information of the patient, calculate the patient embedding vector using an attention-based method; input the patient embedding vector into a classifier for health time prediction.

[0012] Furthermore, the construction of the global disease co-occurrence graph includes:

[0013] Construct a global disease co-occurrence graph G, where the graph G uses disease codes (c i , c j ) as nodes. When a pair of disease codes co-occur in the patient visit record, add a corresponding directed edge in the graph G, and calculate the edge weight according to the co-occurrence frequency f ij . Screen out disease combinations Δ i with important associations by setting a threshold δ, and represent this graph with an adjacency matrix A ij :

[0014]

[0015] Among them, q i represents the total frequency of qualified diseases co-occurring with c i

[0016] Furthermore, the data augmentation of disease embeddings by contrastive learning from the frequency domain perspective through setting an adaptive high-frequency mask includes:

[0017] Performing a fast Fourier transform on the processed global disease co-occurrence map data to convert to the frequency domain:

[0018]

[0019] Among them, the Fourier transform converts the image from the time domain to the frequency domain, x(m,n) is the pixel value of the input image, (m,n) are the spatial coordinates, F(u,v) is the value in the frequency domain corresponding to the frequency (u,v); the exponential term is the kernel function of the Fourier transform, mapping the pixel value co-occurrence to the frequency;

[0020] Calculating the spectral energy, which is the frequency domain representation; the spectral energy calculation formula is:

[0021] E(u,v) = [F(u,v)] 2 = Re([F(u,v)] 2 ) + Im([F(u,v)] 2 ),

[0022] Among them, F(u,v) is a complex number in the frequency domain, including the real part Re(F(u,v)) and the imaginary part Im(F(u,v)), and the energy E(u,v) of the spectrum is the square of the complex amplitude, representing the information intensity contained in the image at that frequency;

[0023] Calculating the normalized energy, through median normalization to dynamically adjust the threshold of the mask:

[0024]

[0025] Among them, median(E) is the median of the energies of all frequency points, representing the intermediate level of the overall energy distribution of the image spectrum, and ∈ is a very small value to avoid a denominator of zero;

[0026] Calculating the distance to distinguish the high-frequency and low-frequency regions:

[0027]

[0028] Among them, (u,v) are the coordinates of the frequency point, (H / 2,W / 2) is the center of the spectrum, that is, the position of zero frequency, and the formula represents the normalized Euclidean distance, normalizing the physical distance of the frequency point from the center to the range of [0,1]; ​

[0029] Define and create a mask to dynamically select and retain high-frequency information while suppressing low-frequency information:

[0030]

[0031] Among them, the mask M(u, v) is used for the selection mechanism of retaining frequency points. If the normalized energy is greater than the threshold θ, the mask value is 1, indicating that the frequency point is retained; otherwise, the mask value is 0, indicating that the frequency point is suppressed.

[0032] Apply the mask to enhance the high-frequency features in the frequency domain while removing the useless low-frequency parts:

[0033] F′ (u,v) = F(u, v)·M(u, v),

[0034] where F(u, v) is the original spectrum and M(u, v) is the generated adaptive mask;

[0035] Convert the processed frequency-domain information back to the time domain to obtain the enhanced image, highlighting the high-frequency features in the image:

[0036]

[0037] The inverse Fourier transform converts the processed spectrum F′(u, v) back to the time domain to restore the image. The exponential term is the kernel function of the inverse transform, which is used to map the contributions in the frequency domain back to the spatial domain.

[0038] Furthermore, the contrastive learning obtains effective data representations by learning to distinguish similar samples. The formula for the loss function of contrastive learning is:

[0039]

[0040] where nei_count represents the number of neighbors, and its calculation formula is: nei_count = 2·∑ j adj ij ,

[0041] intra_view_sim(i, j) represents the similarity within the same view, and its calculation formula is:

[0042]

[0043] inter_view_sim(i, j) represents the similarity across different views, and its calculation formula is:

[0044]

[0045] inter_view_sim(i,i) represents the cross-view similarity of itself.

[0046] Furthermore, the dynamic subgraphs are local diagnostic graph, global diagnostic-neighbor graph, and global neighbor graph; the local diagnostic graph is composed of the diagnosed diseases in the current visit; the global diagnostic-neighbor graph describes the connection relationship between the diagnosed diseases in the current visit and their neighbor diseases in the global graph; the global neighbor graph is a graph about the neighbor diseases not diagnosed in the current visit;

[0047] Local diagnostic graph A complete graph composed of the diagnoses in visit t, represented by the adjacency matrix M t ∈R d×d If c i and c j are diagnosed in visit t, then Otherwise it is 0;

[0048] Global diagnostic-neighbor graph Is a bipartite graph that describes the connection between the diagnoses in visit t and their neighbors in G, represented by the adjacency matrix B t ∈R d×d Represents the connection from the diagnosis to the neighbor. If c i is diagnosed in visit t, c j is its neighbor and not diagnosed in the current visit, then Otherwise it is 0; for the reverse connection, it is represented by B t′ and the calculation method is similar;

[0049] Global neighbor graph Is a graph of the neighbors in visit t, represented by the adjacency matrix N t ∈R d×d If c i and c j are neighbors not diagnosed in visit t, then Otherwise it is 0.

[0050] Furthermore, for each diagnostic node, the local context aggregates the embeddings of other diagnoses as the local context;

[0051] For each diagnostic node in the diagnostic global EHR dataset context, aggregates the embeddings of the connected neighbors as the diagnostic global context;

[0052] It also includes: for each neighbor node in the neighbor global EHR dataset context, aggregates the embeddings of the connected diagnostic nodes and the connected neighbor nodes as the neighbor global context;

[0053] Add the corresponding context to the node embeddings for message aggregation, and calculate the hidden embeddings of the diagnosis and neighbors through a specific formula

[0054] Furthermore, the three diagnostic roles explore the temporal features of the visit sequence through a deep learning model to learn the previous diagnosis and predict future events; for the diagnostic vector m of visit t (t≥2) t , it is divided into three disjoint parts to represent the disease states;

[0055] Persistent diseases represent diseases that are diagnosed in both visits t and t-1;

[0056] Emerging neighbor diseases represent diseases that are diagnosed in visit t but are neighbors in t-1;

[0057] Emerging unrelated diseases represent diseases that are diagnosed in visit t but are neither a diagnosis nor a neighbor in t-1, where ∩, ∪, are element-wise logical AND, OR, and NOT operations on multi-hot vectors.

[0058] Furthermore, the transformation function extracts historical context information including:

[0059] Emerging disease transformation function: For and are non-consecutive transitions and do not directly inherit the previous diagnosis information. The scaled dot-product attention mechanism is used as the transformation function; for use the hidden neighbor embedding as the query Q and key K, and the hidden diagnosis embedding as the value V; for use the general embedding of unrelated diseases as the query and key, and also use as the value, and calculate the transformation output through the attention formula and

[0060]

[0061] where α is the attention magnitude, W q , W k , W v are attention weights;

[0062]

[0063] where, represents the transformation output of emerging neighbor diseases at time t, represents the state of emerging neighbor diseases at time t, Denote the hidden state of the neighbor's disease at time t-1, Denote the hidden state of the diagnosed disease at time t;

[0064]

[0065] where, Denote the transition output of the emerging unrelated disease at time t, Denote the state of the emerging unrelated disease at time t, R denotes the general embedding of the unrelated disease, Denote the hidden state of the diagnosed disease at time t;

[0066] Persistent disease transition function: For Since it directly inherits the previous diagnostic information, design an improved gated recurrent unit as the transition function; in visit t, Consist of and Calculated by M-GRU, including the update gate z t , reset gate r t , candidate hidden state h t′ and the final hidden state Calculation, where apply the tanh function to the emerging disease output and store its hidden state into the persistent disease hidden state, and ignore the corresponding part of the calculation when some disease types do not exist; the M-GRU calculation formula is as follows:

[0067]

[0068]

[0069] where, W z,r,h and U z,r,h are GRU weights, b z,r,h is the bias, σ and represent the sigmoid and tanh activation functions respectively.

[0070] Furthermore, the calculation of the patient embedding vector includes:

[0071] When t = 1, since there is no emerging disease in the first visit, let Use the original GRU and the initial hidden state Calculate

[0072] After calculating the transition outputs of the three parts, use max pooling to calculate the visit embedding v t , and finally apply position-based attention to calculate the final hidden representation o of all visits, calculate the attention score α and the patient embedding o through a specific formula; the calculation formula is as follows:

[0073] α = softmax([v 1 , v 2 ,... v T W α ) ∈ R T ,

[0074] o = α[v 1 , v 2 ,... v T T ∈ R p ,

[0075] where W α ∈ R p is the context vector of attention, α is the attention score of the visit, and the patient embedding o will be used by the classifier for final task prediction.

[0076] Furthermore, the preprocessing includes cleaning and normalization.

[0077] Compared with the existing technologies, the beneficial effects of the present invention are:

[0078] 1. Introducing adaptive high-frequency enhancement, the dynamic changes of the disease map not only exist in the global trend (low-frequency information), but also in some high-frequency micro-changes in the disease-disease and disease-symptom relationships. For example, when the disease spreads, the weights between some nodes increase or decrease rapidly; by enhancing the high-frequency information, the model can pay attention to these rapidly changing patterns, making it more sensitive to fine-grained features, especially to changes in anomalies, mutations or critical time points (such as the multi-disease association changes caused by the sudden outbreak of a certain disease). By introducing an adaptive mechanism, the high-frequency enhancement can be adjusted in real time according to the dynamic state of the current map; for example: in the stage of rapid relationship changes (such as the peak of disease spread), enhance the attention to high-frequency features; in the stage of relatively stable relationships (such as the end of disease spread), weaken the attention to high-frequency features to avoid overfitting details;

[0079] ​2. Research on disease prediction based on improved contrastive learning. By introducing the contrastive learning method, positive and negative sample pairs are constructed. Contrastive learning can bring similar samples closer (such as the representations of the same disease at different times) and push unrelated samples farther apart (such as the representations between unrelated diseases). This feature optimization method enables diseases to have clearer boundaries in the high-dimensional feature space and enhances the distinctiveness of features. The positive and negative sample optimization process of contrastive learning is equivalent to an embedded noise filter, which can highlight truly meaningful sample pairs (such as accurate disease associations) and suppress unrelated or incorrect noise samples. By bringing the feature representations of the same disease at different times closer through contrastive learning, the model can learn more stable and consistent dynamic representations. Since contrastive learning optimizes the temporal distribution of features, the model will also perform better on future unseen data (such as new time periods or association patterns of new diseases), and the generalization ability of the model will be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0080] Figure 1 is a flowchart of the present application.

[0081] Figure 2 is the overall network structure diagram after improvement of the present application.

[0082] Figure 3 is a partial network structure diagram of the present application.

[0083] Figure 4 is the structure diagram of the data augmentation module of the present application.

[0084] Figure 5 is the diagram of the neighbor contrast loss module of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0085] It should be noted that relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variation thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the element.

[0086] The features and performance of the present invention will be further described in detail below in conjunction with the embodiments.

[0087] Please refer to Figures 1-5, A disease prediction study based on improved contrastive learning, as Figure 1 and Figure 2 shown, includes the following steps:

[0088] Obtain and organize EHR data, encode and convert the patient's diagnosis information according to a preset disease classification system (such as ICD-9-CM or ICD-10) to form a dataset format, and clean and normalize the data to ensure the quality and consistency of the data;

[0089] Construct a global disease co-occurrence graph based on the patient's historical diagnosis data, use contrastive learning to perform data augmentation on disease embeddings from the frequency domain perspective by setting an adaptive high-frequency mask, take the neighbor nodes of each anchor point as positive signals, and add the contrastive loss to the loss function;

[0090] Input the patient's diagnosis data into the model to adjust the model parameters for training until the optimal model is obtained; input the diagnosis data of the patient to be predicted into the optimal model obtained after training, and finally obtain the prediction result; according to the prediction result, the patient can predict their possible future disease conditions based on their medical records. In the context-aware health event prediction method based on the transfer function of the improved dynamic disease map, contrastive learning is added. This contrastive learning performs data augmentation on disease embeddings from the frequency domain perspective by setting an adaptive high-frequency mask, and at the same time takes the neighbor nodes of each anchor point as positive signals. By adding the contrastive loss to the loss function, the accuracy of patient disease prediction is improved without increasing the model parameters.

[0091] For each patient's each visit, extract three dynamic subgraphs from the global disease co-occurrence graph that can integrate the local context of the visit and the context information of the global EHR dataset; according to the changes in the node attributes in the dynamic subgraph, define three diagnostic roles: persistent diseases, emerging neighbor diseases, and emerging unrelated diseases; set corresponding transfer functions for different roles to extract historical context information; through these transfer functions, the dynamic change process of diseases can be better captured;

[0092] Integrate all the patient's visit information, use an attention-based method to calculate the patient embedding vector, which comprehensively combines the patient's historical visit information and disease dynamic change characteristics; input the patient embedding vector into a classifier (such as a fully connected layer with a sigmoid activation function) for health time prediction, such as diagnosis prediction or heart failure prediction, etc.

[0093] As Figure 3 shown, constructing the global disease co-occurrence graph includes:

[0094] Construct a global disease co-occurrence graph G, where the graph G uses disease codes (c i ,c j) is a node. When a pair of disease codes co-occur in a patient's medical record, a corresponding directed edge is added to the graph G, and the edge weight is calculated according to the co-occurrence frequency f ij Calculate the edge weights, and filter out the disease combinations Δ with important associations by setting a threshold δ i , and use the adjacency matrix A ij to represent this graph to reflect the global association relationship between diseases:

[0095]

[0096] where q i represents the total frequency of qualified diseases co-occurring with c i .

[0097] Contrastive learning obtains effective data representations by learning to distinguish similar samples. The formula for the loss function of contrastive learning is:

[0098]

[0099] where nei_count represents the number of neighbors, and its calculation formula is: nei_count = 2·∑ j adj ij ,

[0100] intra_view_sim(i,j) represents the similarity within the same view, and its calculation formula is:

[0101]

[0102] inter_view_sim(i,j) represents the cross-view similarity, and its calculation formula is:

[0103]

[0104] inter_view_sim(i,i) represents the cross-view similarity of itself.

[0105] As Figure 4 shown, data augmentation of disease embeddings by contrastive learning from the frequency domain perspective by setting an adaptive high-frequency mask includes:

[0106] Perform a fast Fourier transform (FFT) on the processed global disease co-occurrence graph data to convert to the frequency domain:

[0107]

[0108] where the Fourier transform converts the image from the time domain (pixel value distribution) to the frequency domain, x(m,n) is the pixel value of the input image, (m,n) are the spatial coordinates, F(u,v) is the value in the frequency domain corresponding to the frequency (u,v); the exponential term is the kernel function of the Fourier transform, which maps pixel value co-occurrences to frequencies;

[0109] Calculate the spectral energy, which is the representation in the frequency domain. After performing the Fourier transform on an image, the value at each frequency point is a complex number F(u,v), which contains amplitude and phase information. The spectral energy is used to quantify the "intensity" or "contribution" of that frequency point. The formula for spectral energy is:

[0110] E(u,v) = [F(u,v)] 2 = Re([F(u,v)] 2 ) + Im([F(u,v)] 2 ),

[0111] where F(u,v) is the complex number in the frequency domain, containing the real part Re(F(u,v)) and the imaginary part Im(F(u,v)). The energy of the spectrum E(u,v) is the square of the complex magnitude, representing the intensity of the information contained in that frequency in the image;

[0112] Calculate the normalized energy. Through median normalization, the threshold of the mask is dynamically adjusted to ensure that high-frequency features can be appropriately highlighted in different images, making the selection of the mask robust to different images:

[0113]

[0114] where median(E) is the median of the energies of all frequency points, representing the middle level of the overall energy distribution of the image spectrum. The normalization is achieved by dividing the energy of each frequency point by the median, making the energy values comparable among different images. ∈ is a very small value to avoid a zero denominator;

[0115] Calculate the distance to distinguish high-frequency and low-frequency regions and provide spatial position information for the mask:

[0116]

[0117] where (u,v) are the coordinates of the frequency point, and (H / 2,W / 2) is the center of the spectrum, i.e., the position of the zero frequency. The formula represents the normalized Euclidean distance, which normalizes the physical distance of the frequency point from the center to the range [0,1];

[0118] Define and create a mask to dynamically select and retain high-frequency information and suppress low-frequency:

[0119]

[0120] Among them, the mask M(u, v) is used for the selection mechanism of retaining frequency points. If the normalized energy is greater than the threshold θ, the mask value is 1, indicating that the frequency point is retained; otherwise, the mask value is 0, indicating that the frequency point is suppressed.

[0121] Apply the mask to enhance high-frequency features in the frequency domain, such as edges and textures, while removing the useless low-frequency parts:

[0122] F′ (u,v) = F(u, v)·M(u, v),

[0123] where F(u, v) is the original spectrum and M(u, v) is the generated adaptive mask; the element-wise multiplication of the mask will selectively retain high-frequency information while suppressing the low-frequency parts.

[0124] Convert the processed frequency-domain information back to the time domain to obtain the enhanced image, highlighting the high-frequency features in the image:

[0125]

[0126] The inverse Fourier transform converts the processed spectrum F′(u, v) back to the time domain to restore the image. The exponential term is the kernel function of the inverse transform, which is used to map the contributions in the frequency domain back to the spatial domain.

[0127] The dynamic subgraphs are the local diagnostic graph, the global diagnostic-neighbor graph, and the global neighbor graph; the local diagnostic graph is composed of the diagnosed diseases in the current visit; the global diagnostic-neighbor graph describes the connection relationship between the diagnosed diseases in the current visit and their neighbor diseases in the global graph (not diagnosed in the current visit but connected to the diagnosed diseases in other patients' visits); the global neighbor graph is about the neighbor diseases not diagnosed in the current visit;

[0128] Local diagnostic graph A complete graph composed of the diagnoses in visit t, represented by the adjacency matrix M t ∈R d×d If c i and c j are diagnosed in visit t, then Otherwise, it is 0;

[0129] Global diagnostic-neighbor graph Is a bipartite graph that describes the connection between the diagnoses in visit t and their neighbors in G, represented by the adjacency matrix B t ∈R d×d Represents the connection from the diagnosis to the neighbor. If c i is diagnosed in visit t and c j is its neighbor and not diagnosed in the current visit, then Otherwise, it is 0; for the reverse connection, use B t′Indicates that the calculation methods are similar;

[0130] Global neighbor graph Is the graph of neighbors in visit t, represented by the adjacency matrix N t ∈R d×d Indicates that if c i and c j Are neighbors not diagnosed in visit t, then Otherwise it is 0.

[0131] Local context information and global context information. Disease combinations have an impact on future visits. The roles of diagnoses and their neighbors are different. Therefore, two embedding matrices M, N ∈ R d×x Are used to represent diagnoses and neighbor diseases respectively, and is used to represent irrelevant diseases. In the layer, local and global contexts are extracted for the diagnoses and neighbors in the visit.

[0132] For local context, for each diagnosis node, from Aggregate the embeddings of other diagnoses as local context;

[0133] For the context of the diagnostic global EHR dataset, for each diagnosis node, from Aggregate the embeddings of connected neighbors as the diagnostic global context;

[0134] It also includes: For the context of the neighbor global EHR dataset, for each neighbor node, from Aggregate the embeddings of connected diagnosis nodes and connected neighbor nodes as the neighbor global context;

[0135] Add the corresponding context to the node embeddings for message aggregation, and calculate the hidden embeddings of diagnoses and neighbors through a specific formula

[0136] Three diagnostic roles explore the temporal features of the visit sequence through a deep learning model to learn previous diagnoses and predict future events; for the diagnostic vector m t Of visit t (t ≥ 2), it is divided into three non - overlapping parts to represent the disease state;

[0137] Persistent diseases Represent diseases diagnosed in both visit t and t - 1;

[0138] Emerging neighbor diseases Represent diseases diagnosed in visit t but were neighbors in t - 1;

[0139] Emerging irrelevant diseases Represent diseases diagnosed in visit t but were neither diagnoses nor neighbors in t - 1, where ∩, ∪, Are element - wise logical AND, OR, and NOT operations on multi - hot vectors.

[0140] As Figure 5 shown, the conversion function extracts historical context information including:

[0141] Emerging disease conversion function: For and which are non - continuous transitions and do not directly inherit the previous diagnosis information, the scaled dot - product attention mechanism is used as the conversion function; for using the hidden neighbor embedding as the query Q and key K, and the hidden diagnosis embedding as the value V; for using the general embedding of unrelated diseases as the query and key, and also using as the value, calculating the conversion output through the attention formula and

[0142]

[0143] where α is the attention magnitude, W q , W k , W v are attention weights;

[0144]

[0145] where, represents the conversion output of emerging neighbor diseases at time t, represents the state of emerging neighbor diseases at time t, represents the hidden state of neighbor diseases at time t - 1, represents the hidden state of diagnosed diseases at time t;

[0146]

[0147] where, represents the conversion output of emerging unrelated diseases at time t, represents the state of emerging unrelated diseases at time t, R represents the general embedding of unrelated diseases, represents the hidden state of diagnosed diseases at time t;

[0148] Persistent disease conversion function: For since it directly inherits the previous diagnosis information, an improved gated recurrent unit (M - GRU) is designed as the conversion function; at visit t, is composed of and Calculated by M-GRU, including the update gate z t , the reset gate r t , the candidate hidden state h t′ and the final hidden state . For the output of emerging diseases, the tanh function is applied and its hidden state is stored in the persistent disease hidden state. When some disease types do not exist, the corresponding part of the calculation is ignored. The formula for M-GRU is as follows:

[0149]

[0150] where W z,r,h and U z,r,h are GRU weights, b z,r,h is the bias, and σ and represent the sigmoid and tanh activation functions respectively.

[0151] Calculating the patient embedding vector includes:

[0152] When t = 1, since there are no emerging diseases at the first visit, let Calculate using the original GRU and the initial hidden state

[0153] After calculating the conversion outputs of the three parts, use max pooling to calculate the visit embedding v t . Finally, apply position-based attention to calculate the final hidden representation o (i.e., the patient embedding) of all visits. Calculate the attention score α and the patient embedding o through specific formulas. The formulas are as follows:

[0154] α = softmax([v 1 , v 2 ,... v T W α ) ∈ R T ,

[0155] o = α[v 1 , v 2 ,... v T T ∈ R p ,

[0156] where W a ∈ R p is the context vector of attention, α is the attention score of the visit, and the patient embedding o will be used by the classifier for the final task prediction.

[0157] ​By introducing adaptive high-frequency enhancement, the model can focus on these rapidly changing patterns, making it more sensitive to fine-grained features, especially to changes in anomalies, mutations, or critical time points (such as the multi-disease association changes caused by the sudden outbreak of a certain disease). By introducing an adaptive mechanism, high-frequency enhancement can be adjusted in real time according to the dynamic state of the current atlas. For example, during the stage of rapid relationship changes (such as the peak of disease transmission), the attention to high-frequency features is enhanced; during the relatively stable stage of the relationship (such as the end of disease transmission), the attention to high-frequency features is weakened to avoid overfitting details.

[0158] Adaptive high-frequency enhancement is a technique that dynamically enhances details and clarity by analyzing the frequency domain information of images, especially focusing on high-frequency components (representing details and edges). Its core idea is to adaptively adjust the enhancement parameters according to the characteristics of different regions of the image to prevent the generation of noise and artifacts, thereby highlighting important features. At the same time, it combines multi-scale processing and other image processing techniques to optimize the natural appearance and detail presentation of the image.

[0159] By introducing the contrastive learning method, by constructing positive and negative sample pairs, contrastive learning can bring similar samples closer (such as the representations of the same disease at different times) and pull unrelated samples farther apart (such as the representations between unrelated diseases). This feature optimization method enables diseases to have clearer boundaries in the high-dimensional feature space and improves the distinctiveness of features. The positive and negative sample optimization process of contrastive learning is equivalent to an embedded noise filter, which can highlight truly meaningful sample pairs (such as accurate disease associations) and suppress irrelevant or incorrect noise samples. By bringing the feature representations of the same disease at different times closer through contrastive learning, the model can learn more stable and consistent dynamic representations.

[0160] After introducing the adaptive high-frequency enhancement and contrastive learning methods, the improved algorithm not only does not increase in terms of parameters, but also has a significant improvement in the accuracy and speed of disease prediction compared to the original disease prediction algorithm, fully meeting the real-time requirements. The model can more accurately capture subtle lesion features when analyzing medical images. The adaptive high-frequency enhancement technology effectively strengthens key details, making early lesions easier to identify, while contrastive learning improves the model's sensitivity to subtle differences between patient samples by optimizing the feature extraction process. This combination not only improves the prediction accuracy but also enhances the robustness of the model, making it more reliable in complex and changing clinical environments and providing strong support for early diagnosis and intervention.

[0161] Experimental verification:

[0162] The test platform and experimental environment are as follows: The experimental environment uses the Windows operating system, performs operations using an A40 graphics card with a video memory size of 48GB, the CPU configuration is Intel(R) Xeon(R) Platinum 8358P CPU@2.60GHz, the CUDA version is 11.1.0, the Pytorch version is 1.9.0, and the Python language environment is 3.8.10.

[0163] The dataset used is sourced from the MIMIC public dataset:

[0164] MIMIC-III dataset: Covers 7493 patients with multiple visit records (T≥2) during the period from 2001 to 2012. The number of medical codes contained in this dataset is 4880, the maximum number of codes per visit is 39, and the average number of codes per visit is 13.06. In the experiment, it is randomly divided into a training set (6000 patients), a validation set (493 patients), and a test set (1000 patients) based on patients, and the last visit is used as the label, and the remaining visits are used as features to construct the global combined graph G. In the test set of the heart failure prediction task, the proportion of positive samples is 36.70%, and the proportion of negative samples is 63.30%.

[0165] MIMIC-IV dataset: Contains 85155 patients with multiple visit records during the period from 2008 to 2019. Due to the time overlap range with MIMIC-III, 10000 patients from 2013 to 2019 are randomly selected for the experiment. There are 6102 medical codes in this dataset, the maximum number of codes per visit is 50, and the average number of codes per visit is 13.38. Similarly, it is randomly divided into a training set (8000 patients), a validation set (1000 patients), and a test set (1000 patients) based on patients, using the last visit as the label and the rest as features to construct the global combined graph G. In the test set of the heart failure prediction task, the proportion of positive samples is 15.70%, and the proportion of negative samples is 85.30%. These datasets provide rich medical data for the training, validation, and testing of the model, and help to evaluate the performance of the model in the health event prediction task.

[0166] The evaluation metrics used are Evaluation loss (evaluation loss), F1-score (weighted F1 score), and Top-K recall (top K recall rate). The calculation formulas for precision (Precision), recall (Recall), F1-score (weighted F1 score), and Top-K recall (top K recall rate) are as follows:

[0167]

[0168] Among them, TP is the number of positive samples predicted as positive samples; FP is the number of positive samples predicted as negative samples, and FN is the number of negative samples predicted as positive samples. Precision refers to the proportion of the part that the classifier considers as positive and is indeed positive among all the parts that the classifier considers as positive; Recall refers to the proportion of the part that the classifier considers as positive and is indeed positive among all the parts that are indeed positive; where n is the number of samples, is the top k prediction results of the i-th sample, is the true label of the i-th sample.

[0169] In another specific embodiment, to verify the effectiveness of the algorithm, the algorithm and the original algorithm were tested on the same test set, and the comparison results of various performance indicators are shown in Table 1 below:

[0170] Table 1 Comparison of Performance Indicators

[0171]

[0172] By comparing the performance of the original algorithm and the algorithm of the present application in various indicators, it can be seen that the algorithm of the present application has obvious advantages. In terms of F1-score, the algorithm of the present application reaches 24.38%, which is 0.84 percentage points higher than 23.54% of the original algorithm, and the overall performance is better. In terms of Top-10 recall, the algorithm of the present application is 28.68%, which is 1.09 percentage points higher than 27.59% of the original algorithm, and the accuracy is better in the first 10 prediction results. In Top-20 recall, the algorithm of the present application reaches 38.34%, which is 1.7 percentage points higher than 36.64% of the original algorithm. When the prediction range is expanded to the first 20, the recall ability is stronger. In Top-30 recall, the algorithm of the present application is 44.54%, leading 42.52% of the original algorithm by 2.02 percentage points, and the advantage is prominent in larger-scale prediction tasks. In Top-40 recall, the algorithm of the present application is 48.64%, which is 1.84 percentage points higher than 46.80% of the original algorithm, and the overall recall ability is stable and superior. Generally speaking, the algorithm of the present application is significantly superior to the original algorithm in terms of accuracy and recall ability, can provide better results in different scenarios, and has higher practical value and application potential.

[0173] The above-described embodiments only represent the specific implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the protection scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the technical solution of the present application, several deformations and improvements can still be made, and these all belong to the protection scope of the present application.

Claims

1. A disease prediction study based on improved contrastive learning, characterized in that, It includes the following steps: Obtain and organize EHR data, perform coding conversion on the patient's diagnosis information according to a preset disease classification system to form a dataset format, and preprocess the data; Construct a global disease co-occurrence graph based on the patient's historical diagnosis data. Use contrastive learning to perform data augmentation on disease embeddings from the frequency domain perspective by setting an adaptive high-frequency mask. Take the neighbor nodes of each anchor point as positive signals and add the contrastive loss to the loss function; For each visit of each patient, extract three dynamic subgraphs from the global disease co-occurrence graph that can integrate the local context of the visit and the context information of the global EHR dataset; Define three diagnostic roles of persistent diseases, emerging neighbor diseases, and emerging unrelated diseases according to the changes in node attributes in the dynamic subgraph; Set corresponding transformation functions for different roles to extract historical context information; Integrate all the visit information of the patient and calculate the patient embedding vector using an attention-based method; Input the patient embedding vector into a classifier for health time prediction.

2. The disease prediction research based on improved contrastive learning according to claim 1, wherein The construction of the global disease co-occurrence graph includes: Construct the global disease co-occurrence graph G. The graph G takes disease codes (c i , c j ) as nodes. When a pair of disease codes co-occur in the patient visit records, a corresponding directed edge is added to the graph G, and the edge weight is calculated according to the co-occurrence frequency f ij . By setting a threshold δ, the disease combinations Δ i with important associations are screened out, and the adjacency matrix A ij is used to represent this graph: Among them, q i represents the total frequency of qualified diseases co-occurring with c i ​ 3. A disease prediction study based on improved contrastive learning according to claim 1 or 2, characterized in that, The data augmentation of disease embeddings using contrastive learning from the frequency domain perspective by setting an adaptive high-frequency mask includes: Perform a fast Fourier transform on the processed global disease co-occurrence graph data to convert to the frequency domain: Among them, the Fourier transform converts an image from the time domain to the frequency domain, x(m,n) is the pixel value of the input image, (m,n) are the spatial coordinates, F(u,v) is the value in the frequency domain corresponding to the frequency (u,v); the exponential term is the kernel function of the Fourier transform, which maps the pixel value co-occurrence to the frequency; Calculate the spectral energy, which is the representation in the frequency domain; The formula for calculating the spectral energy is: E(u, v) = [F(u, v)] 2 = Re([F(u, v)] 2 ) + Im([F(u, v)] 2 ) where F(u,v) is a complex number in the frequency domain, including the real part Re(F(u,v)) and the imaginary part Im(F(u,v)), and the energy E(u,v) of the spectrum is the square of the complex amplitude, representing the information intensity contained in this frequency in the image; Calculate the normalized energy, and perform median normalization to dynamically adjust the threshold of the mask: where median(E) is the median of the energies of all frequency points, representing the intermediate level of the overall energy distribution of the image spectrum, and ∈ is a very small value to avoid a zero denominator; Calculate the distance to distinguish the high-frequency and low-frequency regions: where (u,v) is the coordinate of the frequency point, and (H / 2,W / 2) is the center of the spectrum, that is, the position of zero frequency. The formula represents the normalized Euclidean distance, which normalizes the physical distance of the frequency point from the center to the range [0,1]; Define and create a mask to dynamically select and retain high-frequency information and suppress low-frequency: where the mask M(u,v) is used for the selection mechanism of retaining frequency points. If the normalized energy is greater than the threshold θ, the mask value is 1, indicating that this frequency point is retained; otherwise, the mask value is 0, indicating that this frequency point is suppressed; Apply the mask to enhance the high-frequency features in the frequency domain while removing the useless low-frequency part: F′ (u,v) = F(u, v) · M(u, v), where F(u,v) is the original spectrum and M(u,v) is the generated adaptive mask; Convert the processed frequency domain information back to the time domain to obtain the enhanced image, highlighting the high-frequency features in the image: The inverse Fourier transform converts the processed spectrum F′(u,v) back to the time domain to restore the image. The exponential term is the kernel function of the inverse transform, which is used to map the contributions in the frequency domain back to the spatial domain.

4. A disease prediction study based on improved contrastive learning according to claim 1, characterized in that The contrastive learning obtains effective data representations by learning to distinguish similar samples. The formula for the loss function of contrastive learning is: where nei_count represents the number of neighbors, and its calculation formula is: nei_count = 2·∑ j adj ij , intra_view_sim(i,j) represents the similarity within the view, and its calculation formula is: inter_view_sim(i, j) represents the cross-view similarity, and its calculation formula is as follows: inter_view_sim(i, i) represents the cross-view similarity of itself.

5. A disease prediction study based on improved contrastive learning according to claim 1, characterized in that, The dynamic subgraphs are the local diagnosis graph, the global diagnosis-neighbor graph, and the global neighbor graph; the local diagnosis graph is composed of the diagnosed diseases in the current visit; the global diagnosis-neighbor graph describes the connection relationships between the diagnosed diseases in the current visit and their neighbor diseases in the global graph; the global neighbor graph is a graph about the neighbor diseases that are not diagnosed in the current visit; Local diagnosis graph Complete graph composed of diagnoses in visit t, represented by adjacency matrix M t ∈R d×d Indicating that if c i and c j are diagnosed in visit t, then Otherwise 0; Global Diagnosis - Neighbor Graph is a bipartite graph that describes the connections between diagnoses in encounter t and their neighbors in G, represented by the adjacency matrix B t ∈R d×d represents the connection from a diagnosis to its neighbor. If c i is diagnosed in encounter t, and c j is its neighbor and not diagnosed in this encounter, then otherwise it is 0; for the reverse connection, it is represented by B t′ and the calculation method is similar; Global neighbor graph is the graph of neighbors in visit t, represented by the adjacency matrix N t ∈R d×d If c i and c j are neighbors not diagnosed in visit t, then Otherwise it is 0.

6. A disease prediction study based on improved contrastive learning according to claim 1, characterized in that, The local context, for each diagnostic node, aggregates the embeddings of other diagnoses as the local context from and uses them as the local context; The context of the diagnostic global EHR dataset For each diagnostic node, from aggregate the embeddings of connected neighbors as the diagnostic global context; Further included: the context of the neighbor global EHR dataset. For each neighbor node, from aggregate the embeddings of the connected diagnostic nodes and the connected neighbor nodes as the neighbor global context; Add the corresponding context to the node embeddings for message aggregation, and calculate the hidden embeddings of the diagnosis and neighbors through the formula 7. A disease prediction study based on improved contrastive learning according to claim 1, characterized in that, The three diagnostic roles explore the temporal features of the visit sequence through a deep learning model to learn previous diagnoses and predict future events; for the diagnostic vector m of visit t (t≥2) t , it is divided into three disjoint parts to represent the disease state; Persistent disease Indicates a disease diagnosed in both visits t and t-1; Emerging neighbor diseases Indicates diseases diagnosed in visit t but were neighbors in t-1; Emerging unrelated diseases Denotes a disease that was diagnosed during the visit at t but was neither a diagnosis nor a neighbor at t - 1, where ∩, ∪, Are element-wise logical AND, OR, and NOT operations on multi-hot vectors.

8. A disease prediction study based on improved contrastive learning according to claim 1, characterized in that, The conversion function extracts historical context information including: Emerging disease conversion function: For and which are discontinuous transitions and do not directly inherit the previous diagnosis information, the scaled dot - product attention mechanism is used as the conversion function; for use the hidden neighbor embedding as the query Q and key K, and the hidden diagnosis embedding as the value V; for use the general embedding of irrelevant diseases as the query and key, and also use as the value, and calculate the conversion output through the attention formula and Among them, α is the attention magnitude, W q , W k , W v are attention weights; Among them, represents the conversion output of the emerging neighbor disease at time t, represents the state of the emerging neighbor disease at time t, represents the hidden state of the neighbor disease at time t-1, represents the hidden state of the diagnosed disease at time t; Among them, represents the conversion output of emerging unrelated diseases at time t, represents the state of emerging unrelated diseases at time t, and R represents the general embedding of unrelated diseases, represents the hidden state of the diagnosed disease at time t; Persistent disease transition function: For Since it directly inherits the previous diagnostic information, an improved gated recurrent unit is designed as the transition function; in visit t, It is calculated by and through M-GRU, including the calculation of the update gate z t , reset gate r t , candidate hidden state h t′ and the final hidden state . The tanh function is applied to the output of emerging diseases and its hidden state is stored in the persistent disease hidden state, and the corresponding part of the calculation is ignored when some disease types do not exist; the calculation formula of M-GRU is as follows: Among them, W z,r,h and U z,r,h are GRU weights, b z,r,h is the bias, and σ and represent the sigmoid and tanh activation functions respectively.

9. A disease prediction study based on improved contrastive learning according to claim 8, characterized in that The calculation of the patient embedding vector includes: When t = 1, since there is no emerging disease in the first visit, let Use the original GRU and the initial hidden state Calculate After calculating the transformed outputs of the three parts, the visit embedding v is calculated using max pooling t , and finally, the final hidden representation o of all visits is calculated by applying position-based attention. The attention scores α and the patient embedding o are calculated through the following formula: α = softmax([v 1 , v 2 ,... v T W α ) ∈ R T , o = α[v 1 , v 2 ,... v T T ∈R p ,​ where W a ∈R p is the context vector of attention, α is the attention score of the visit, and the patient embedding o will be used by the classifier for final task prediction.

10. A disease prediction study based on improved contrastive learning according to claim 1, characterized in that, The preprocessing includes cleaning and normalization processing.