Clinical feature fused graph contrast learning drug recommendation method and system
By constructing conditional probability matrices and structure guidance matrices to guide graph attention propagation, and combining multi-layer graph GCN and drug co-modeling, the lack of fine-grained modeling of patient and drug representations in drug recommendation systems is solved, thereby improving the accuracy and safety of drug combinations.
Patent Information
- Application Number
- CN202511114713.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-11
- Publication Date
- 2025-11-25
AI Technical Summary
Existing drug recommendation systems lack fine-grained modeling of graph structures in patient and drug representations, neglect the structured relationships of diagnosis and treatment behaviors within the patient visit, and lack collaborative modeling of EHR networks or drug interaction networks generated from the entire patient's historical medical record dataset, leading to semantic deviations between drug combination effects and safety risks.
A structural prior generation module is used to construct conditional probability matrices and structural guidance matrices. Patient representation is performed using a multi-layer graph GCN. Hellinger distance is used to constrain attention distribution. Drug molecular structure, EHR network, and DDI network are co-modeled using MPNN and GCN to guide drug representation learning. Transformer is used for sequence modeling. Finally, personalized drug recommendations are generated through loss function optimization.
It improves the accuracy and safety of drug recommendations, reduces the risk of potential adverse drug interactions, and enhances the interpretability and consistency of drug combinations.
Smart Images

Figure CN121011305A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of drug recommendation, in particular to a graph contrast learning drug recommendation method and system fusing clinical features, which is suitable for a multi-label drug prediction task based on patient electronic health records (EHR). BACKGROUND
[0002] With the rapid development of EHR systems, the continuous accumulation and quality improvement of medical data provide a solid foundation for intelligent drug recommendation (MR). MR systems can assist doctors in developing more scientific and personalized drug combination plans by mining diagnosis, surgery, and prescription data from patient historical medical records. On the one hand, MR systems can provide accurate and efficient drug prescription suggestions for doctors in the context of multiple diseases coexisting or complex clinical decision-making, alert to adverse drug reactions, and avoid drug interactions. On the other hand, MR systems can match to the corresponding replacement drugs based on patient historical medical records and through consistent learning of drug representation, thereby alleviating the pressure of medical resource allocation and improving treatment quality. In recent years, the model of MR systems has been continuously deepened, and its efficiency and effectiveness have been significantly improved. Researchers have continuously explored key issues such as patient representation and drug representation, used sequence models to capture temporal dependencies, and used graph neural networks (GNN) to model the structural associations between drugs. When patient representation and drug representation are jointly input into a multi-label classifier, the recommended drug set for each visit scenario can be output.
[0003] Although existing methods have made significant progress in patient modeling and drug representation learning, they still face several challenges. First, in terms of patient representation, current mainstream methods mostly use recurrent neural networks (RNN) to directly encode diagnosis and surgery sequences, ignoring the structured relationships between internal diagnosis and treatment behaviors at each visit and lacking fine-grained modeling based on graph structures. In addition, when using graph neural networks to model the propagation of visit information, most methods use static or pre-set adjacency matrices and rarely guide the co-occurrence relationship between EHR entities, also lacking regular constraints on the attention distribution of different levels of graph. In terms of drug representation, through techniques such as graph convolution network (GCN), the co-occurrence information or interaction relationship between drugs is used to learn the latent representation of drugs from a holistic perspective. Current research has attempted to introduce drug molecular structure information and encode molecular graphs through graph neural networks to improve representation effectiveness. However, these methods often treat molecular structure as an independent channel, lacking collaborative modeling with EHR networks or drug-drug interaction (DDI) networks generated based on the entire patient historical medical record dataset. This fragmented modeling approach may lead to semantic divergence between drug representations from different perspectives, affecting the model's comprehensive perception of drug combination effectiveness and safety risks.
[0004] Therefore, there is an urgent need for a new drug recommendation model to fully mine and effectively fuse multi-perspective medical knowledge, improve the rationality of patient representation structure and the consistency of drug representation, and thus improve the accuracy and safety of drug recommendation. SUMMARY
[0005] To solve the above problems, the purpose of the present application is to provide a graph contrastive learning drug recommendation method and system fusing clinical features, aiming to fully mine the structural information in EHR data and drug multi-source information, and improve the accuracy and safety of drug recommendation. The key technologies of the system mainly include six modules, as follows:
[0006] ① History medical record data acquisition and preprocessing module, used for collecting and processing EHR data of patients, extracting diagnosis, surgery and drug information corresponding to each visit of each patient, and constructing structured visit sequence; and generating drug co-occurrence EHR network according to the whole patient historical medical record data set, collecting and arranging DDI network and molecular structure information of all prescription drugs, and establishing drug molecular structure graph in SMILES form.
[0007] ② Structure prior generation module, used for constructing conditional probability matrix according to entity co-occurrence relationship in EHR, and constructing structure guiding matrix (mask matrix) to assist graph representation learning. This module constructs conditional probability matrix by calculating conditional probability, captures the co-occurrence frequency between different types of entities, and generates structure guiding matrix to guide the attention propagation structure in graph convolution network (GCN).
[0008] ③ Patient representation module, used for constructing historical medical record heterogeneous graph for each patient's previous T-1 times of historical medical record data set respectively, propagating features through multi-layer GCN, wherein the first layer uses conditional probability matrix as adjacency matrix, and the subsequent layers use self-attention mechanism to generate adjacency matrix, and Hellinger distance is used to constrain the difference between attention distribution of different layers; then the diagnosis and surgery code sequence in the Tth visit is extracted, combined with the previous T-1 times of heterogeneous graph representation, the diagnosis and surgery sequence is constructed, and sent into the Transformer module for sequence modeling to generate the patient's current visit representation.
[0009] ④ Drug representation module, which obtains the chemical molecular structure representation of the drug through message passing neural network (MPNN), and performs collaborative contrastive learning on the co-occurrence relationship in EHR network and the embedding of DDI network to learn drug representation from multiple perspectives to improve the consistency and explainability of drug representation.
[0010] ⑤ Drug combination prediction module, used for fusing patient representation and drug representation to generate personalized drug recommendation list.
[0011] ⑥Loss function design and optimization module, used for jointly optimizing four types of objective functions, including prediction accuracy loss, multi-label consistency loss, drug safety loss and graph contrastive learning loss, to improve the accuracy and safety of drug recommendation results through weighted combination.
[0012] In order to better understand the drug recommendation system, the main steps involved in the modules in ②-⑥ above will be described in detail as follows:
[0013] (1) The structure prior generation module of the application comprises the following steps:
[0014] S1: Conditional probability matrix generation process, based on all patient historical medical record data sets, the conditional probabilities p(m|d), p(d|m), p(p|m) and p(m|p) corresponding to all diagnosis information d, surgery information p and drug information m are calculated respectively, and then a conditional probability matrix P is generated. And normalized, so that the sum of each row is 1, where V represents the set of all nodes in the graph, and |V| is the total number of entities.
[0015] S2: Structure guide matrix generation process, generating a structure guide matrix M from the conditional probability matrix P. Used to determine whether the connection between nodes in the heterogeneous graph is allowed. If the connection is not allowed, set M ij =-∞; otherwise, set M ij =0.
[0016] (2) The patient representation module of the application learns the structured representation of the patient's historical visit by constructing a multi-layer graph attention network. It comprises the following steps:
[0017] S1: Heterogeneous graph construction process, for the T-1th historical medical record data set of patient i, a heterogeneous graph G is constructed, where 1≤t≤T-1, the node set V t contains the diagnosis, surgery and drug information of the tth visit, the edge set E t represents the co-occurrence relationship between nodes, and the edge weight is initialized based on the conditional probability matrix.
[0018] S2: Heterogeneous graph attention adjacency matrix generation process, using self-attention mechanism to calculate the adjacency matrix of the jth layer of the tth visit, the formula is:
[0019]
[0020] Where j is the jth layer of graph propagation, and are the query and key matrices obtained by linear transformation of the previous layer node representation H (j-1) , and d is the representation dimension.
[0021] S3: Isomorphic graph propagation process, each graph convolution layer updates the rule as follows:
[0022]
[0023] Where P is the conditional probability matrix, used to guide attention learning, j is the jth layer of graph propagation, is the linear transformation parameter of the jth layer.
[0024] S4: Introduce Hellinger distance to regularize the graph structure, encourage the attention distribution to be consistent with the prior structure, the expression is as follows:
[0025]
[0026]
[0027] Where P i and respectively represent the ith row of the conditional probability matrix and the structure attention matrix, N represents the number of nodes in the graph, λ H is a predefined hyperparameter, representing the Hellinger regularization coefficient, λ H The larger, the closer the learned attention matrix to the conditional probability.
[0028] S5: Sequence modeling of the diagnosis and surgery node representation of each patient. First, for the first T-1 times historical medical record data set, the heterogeneous graph representation of the diagnosis and surgery node is extracted respectively, and the diagnosis and surgery representation of the Tth visit is combined to obtain the visit vector Subsequently, the diagnosis sequence And the surgery sequence Respectively sent to the Transformer coding module for sequence modeling to obtain the current visit representation q t That is
[0029]
[0030] Where f(·) is a transformation function that projects the hidden state to the query, and is realized in the form of a single hidden layer fully connected neural network.
[0031] (3) The drug representation module described in the application learns the multi-perspective unified representation of the drug by fusing drug molecular structure, clinical co-occurrence and interaction information. Specifically, the following steps are included:
[0032] S1: Molecular structure encoding process, using MPNN to encode the molecular structure graph G mol =(A,X) of each drug to obtain the drug molecular vector Right now
[0033] Z MPNN =MPNN(A,X).
[0034] S2: Multi-view graph encoding, based on EHR network G ehr and DDI network G ddi Drug extraction node representation using GCN:
[0035] Z ehr =GCN(G ehr ),Z ddi =GCN(G ddi ).
[0036] S3: A multi-perspective fusion process of molecular perception, which integrates molecular structure information into graph representation to enhance drug characterization capabilities, and maps it to the contrast space through projection layers respectively:
[0037] E ehr =Proj([Z ehr Z MPNN ]), E ddi =Proj([Z ddi Z MPNN ]),
[0038] in
[0039] S4: Fusion representation computation, which integrates feature representations from two perspectives based on a gating mechanism to obtain the fused drug representation M. ed ,Right now
[0040] M ed =σ(W[E ehr E ddi ])·E ehr +(1-σ(W[E ehr E ddi ]))·E ddi ,
[0041] in σ is the Sigmoid function. This is the learnable parameter matrix for gating fusion.
[0042] (4) The drug combination prediction module of this invention integrates patient representation and drug representation, and generates a final multi-label prediction result through multi-source information fusion. Specifically, it includes the following steps:
[0043] S1: Graph attention representation of the score calculation process. The drug embedding representation matrix M is obtained through graph contrastive learning based on molecular perception. ed The patient is represented by q tProjection to drug space, get attention matching score:
[0044]
[0045] S2: History memory score calculation process. Build key-value structure Represent the health status and drug use of the patient in the previous T-1 visit, calculate the matching weight with the current query based on the attention mechanism, and get the history memory score:
[0046]
[0047] S3: Final drug recommendation generation process. Represent the patient's current visit q t , drug representation And Splice the drug representation of the three perspectives, and output the final drug prediction result through the fusion layer:
[0048]
[0049] Where σ is the Sigmoid function, Indicates the recommended probability score of each drug in the current visit scenario.
[0050] (5) The loss function design and optimization module of the application combines multiple optimization objectives to jointly train the model to improve the recommendation accuracy and safety. Specifically, the following steps are included:
[0051] S1: Construction of prediction accuracy loss function. The binary cross-entropy loss function is used to measure the difference between the model prediction result and the true drug label, that is,
[0052]
[0053] Where, And The i-th item of the target drug representation and the output drug representation respectively, |M| is the number of drugs.
[0054] S2: Construction of multi-label consistency loss. To ensure that the score of the correct class is higher than that of the wrong class, introduce multi-label hinge loss, that is,
[0055]
[0056] S3: Drug safety loss function design. To reduce the potential risk of adverse drug-drug interactions in the drug combination recommended by the model, construct DDI constraint loss function, that is,
[0057]
[0058] Where is a drug-drug interaction (DDI) network, denotes that the ith drug and the jth drug have an interaction, otherwise 0.
[0059] S4: Contrastive learning loss design, by maximizing the consistency of the same drug in different perspectives and minimizing the similarity of DDI drug pairs, to achieve safe and effective drug representation, whose expressions are respectively:
[0060]
[0061] L contrast =L InfoNCE +λ·L margin ,
[0062] where are the representations of drug i in EHR and DDI graph respectively, is the gated fusion representation of drug i, λ is a predefined hyperparameter, and τ is a temperature hyperparameter.
[0063] S5: Final loss function construction. By weighted fusion of four kinds of loss functions, the final optimization target is formed:
[0064] L=αL bce +βL multi +γL ddi +λL contrast ,
[0065] where α, β, γ, λ are hyperparameters controlling the loss weight of each loss function, used to achieve the optimal trade-off between recommendation accuracy and drug safety.
[0066] The drug recommendation method and system for graph contrastive learning of fusion clinical features proposed by the present application, aiming at the key problems in the process of patient historical medical record and drug representation learning, introduce conditional probability matrix and structure guiding matrix to guide the attention propagation of the graph, and combine Hellinger distance to constrain the attention distribution of different propagation layers, effectively improve the structure rationality and stability in patient modeling. In terms of drug representation, by co-modeling the drug molecular structure, drug co-occurrence EHR network and drug interaction DDI network, the model is guided to learn consistent and highly interpretable drug vector representation under multiple perspectives. The present application not only can improve the accuracy of drug combination recommendation, but also can effectively reduce the risk of potential adverse interactions, thereby having stronger recommendation safety. BRIEF DESCRIPTION OF DRAWINGS
[0067] Figure 1 is a model process diagram of the present application.
[0068] Figure 2 is a model framework diagram of the present application.
[0069] Figure 3 is the Jaccard, PRAUC, F1-Score, DDIRate, and Avg#of Drugs of the present application under the MIMIC-III dataset compared with other methods. DETAILED DESCRIPTION
[0070] The fusion clinical feature graph comparison learning drug recommendation method and system proposed by the present application will be described in detail below with reference to the accompanying drawings. It should be understood that the specific implementation methods described herein are only used to explain the present application and do not limit the present application. Changes, modifications, additions, or replacements made by ordinary skilled in the art within the scope of the present application should be covered by the claims of the present application.
[0071] Figure 1 is the process diagram of the fusion clinical feature graph comparison learning drug recommendation method and system proposed by the present application. From Figure 1 It can be seen that the drug recommendation system first obtains the electronic health record data of the patient from the clinical patient historical medical record database, including the diagnosis, surgery, and drug information in each visit. Then, the heterogeneous graph of the patient's previous T-1 historical medical record data is constructed, and the Hellinger distance constraint based graph attention propagation module is inputted to complete the node information propagation under the structure guidance, and then the heterogeneous graph representation of the diagnosis and surgery nodes is extracted respectively, and the diagnosis and surgery representation of the Tth visit is combined to obtain the visit vector through average pooling. Then, the diagnosis and surgery representation of the Tth visit is inputted into the Transformer sequence modeling module to generate the overall representation of the patient. At the same time, the system generates the drug co-occurrence EHR network from the database, extracts the DDI network and molecular structure graph, and obtains the drug representation with strong interpretability through the graph comparison learning mechanism. Then, the patient representation and drug representation are fused to calculate the drug matching score and generate the personalized drug recommendation list under the current visit. Finally, the model is jointly optimized through the joint of four types of loss functions (prediction loss, structure loss, and DDI safety loss, and graph comparison learning loss), so as to improve the recommendation accuracy and reduce the potential drug interaction risk.
[0072] Figure 2 is the framework diagram of the fusion clinical feature graph comparison learning drug recommendation method and system proposed by the present application. From Figure 2It can be seen that the drug recommendation system comprises a historical medical record data acquisition and preprocessing module, a structure prior generation module, a patient representation module, a drug representation module, a drug combination prediction module and a loss function design and optimization module. ① The historical medical record data acquisition and preprocessing module is used for collecting and processing EHR data of patients, extracting diagnosis, surgery and drug information corresponding to each visit of each patient, and constructing a structured visit sequence; and generating a drug co-occurrence EHR network according to the historical medical record data set of all patients, collecting and arranging a DDI network and molecular structure information of all prescription drugs, and establishing a drug molecular structure graph in the form of SMILES. ② The structure prior generation module is used for statistically analyzing the co-occurrence frequency among diagnosis, surgery and drug entities according to the historical medical record data set of all patients, constructing a conditional probability matrix, and generating a structure guide matrix for guiding the connection feasibility and attention distribution structure between nodes in the graph neural network. ③ The patient representation module is used for constructing a historical medical record heterogeneous graph for each patient's historical medical record data set of the first T-1 times, respectively, propagating features through a multi-layer graph neural network, wherein the first layer uses the conditional probability matrix as the adjacency matrix, the subsequent layers use the self-attention mechanism to generate the adjacency matrix, and the Hellinger distance is used to constrain the difference between the attention distributions of different layers; then the diagnosis and surgery code sequence in the Tth visit is extracted, combined with the heterogeneous graph representation of the first T-1 times, a diagnosis and surgery sequence is constructed, and sent into a Transformer module for sequence modeling to generate a patient current visit representation. ④ The drug representation module is used for learning a consistent representation of the drug from multiple perspectives. First, the MPNN is used to encode the drug molecular structure graph to obtain a structure-level drug representation. Second, based on the EHR network and the DDI network, the GCN is used to extract the representation of the drug in the clinical co-occurrence and interaction network, and the molecular representation is fused. Through the gating mechanism and contrastive learning, a consistent drug representation under multiple perspectives is output. ⑤ The drug combination prediction module is used for splicing the patient current visit representation, the drug representation and the historical visit information representation, outputting through a fusion layer, and finally forming a personalized drug recommendation set. ⑥ The loss function design and optimization module is used for jointly optimizing four types of objective functions, including a prediction accuracy loss, a multi-label consistency loss, a drug safety loss and a graph contrastive learning loss, so as to improve the recommendation accuracy, control the potential interaction risk in the drug combination, and enhance the recommendation safety of the model.
[0073] Figure 3 is the advantage display of the present application on the clinical data set. Figure 3As can be seen, the drug recommendation system proposed in this invention significantly improves recommendation accuracy (Jaccard, PRAUC, F1-Scores, etc.) and safety (DDI rate). The following section uses the MIMIC-III dataset as an example to illustrate the proposed graph contrastive learning-based drug recommendation method and system that integrates clinical features:
[0074] The MIMIC-III dataset contains EHR data for M patients. For any patient, their medical records can be represented as a chronologically ordered sequence of visits, P = [x1, x2, ..., x...]. T ], where T represents the number of times the patient visits the doctor, and each visit is x. t It contains information on several medical events. Specifically, each visit (x) t This multi-label set consists of three parts: a diagnostic code set, a diagnostic code set, and a diagnostic code set. Surgical operation code set With drug code set That is in, All are multi-hot encoded forms, used to represent the diagnosis, surgery, and prescribed medications received by a patient during their t-th visit. This is illustrated using the electronic health record of patient i from the MIMIC-III dataset as an example.
[0075] First, the diagnostic, surgical, and medication information from all patients' historical medical records is extracted using the data acquisition and preprocessing module, and then loaded with the EHR network, DDI network, and drug molecule map. The specific implementation steps of the proposed graph contrastive learning drug recommendation method and system that integrates clinical features are shown below:
[0076] S1: Historical medical record data acquisition and preprocessing module, which obtains the required data information from the database, including the diagnosis ID, surgery ID, and drug ID of each patient's several visits, and loads the adjacency matrix of the EHR network, DDI network, and drug molecule graph.
[0077] S2: Structure Prior Generation Module, which includes the following steps:
[0078] 1) The conditional probability matrix generation process involves calculating the conditional probabilities p(m|d), p(d|m), p(p|m), and p(m|p) for each diagnostic information d, surgical information p, and medication information m, based on the historical medical record dataset of all patients, thereby generating the conditional probability matrix. Then, normalization is performed so that the sum of each row is 1, where V represents the set of all nodes in the graph, and |V| is the total number of entities.
[0079] 2) Structure-guided matrix generation process, generating structure-guided matrix from conditional probability matrix P For judging whether the connection between nodes in the heterogeneous graph is allowed to be established. If the connection is not allowed, set M ij = -∞; otherwise, set M ij = 0.
[0080] S3: Patient representation module, learning the structured representation of patient historical visits by constructing multi-layer graph attention network. Specifically, the following steps are included:
[0081] 1) Heterogeneous graph construction process, for the T-1 historical medical record data set of patient i, respectively constructing the heterogeneous graph Where 1≤t≤T-1, the node set V t contains the diagnosis, surgery and drug information of the tth visit, the edge set E t represents the co-occurrence relationship between nodes, and the edge weight is initialized based on the conditional probability matrix.
[0082] 2) Heterogeneous graph attention adjacency matrix generation process, using self-attention mechanism to calculate the adjacency matrix of the jth layer of the tth visit, and the formula is:
[0083]
[0084] Where j is the jth layer of graph propagation, and are the query and key matrices obtained by linear transformation of the last layer node representation H (j-1) , d is the representation dimension.
[0085] 3) Heterogeneous graph propagation process, and the update rule of each graph convolution layer is as follows:
[0086]
[0087] Where P is the conditional probability matrix, used to guide attention learning, j is the jth layer of graph propagation, is the linear transformation parameter of the jth layer.
[0088] 4) Introducing Hellinger distance to regularize the graph structure, encouraging the attention distribution to be consistent with the prior structure, and the expression is as follows:
[0089]
[0090]
[0091] Where P i and represent the ith row of the conditional probability matrix and the structure attention matrix respectively, N represents the number of nodes in the graph, and λ HTo predefine hyperparameters, represent the Hellinger regularization coefficient, λ H The larger, the closer the learned attention matrix is to the conditional probability.
[0092] 5) Sequence modeling of diagnosis and surgery node representations for each patient. First, for the first T-1 times of historical medical record data sets, the heterogeneous graph representations of diagnosis and surgery nodes are extracted respectively, and combined with the diagnosis and surgery representations of the Tth visit, the visit vector is obtained through average pooling Subsequently, the diagnosis sequence And the surgery sequence Respectively into the Transformer encoding module for sequence modeling, to obtain the current visit representation q of the patient t That is
[0093]
[0094] Where f(·) is a transformation function that projects the hidden state to the query, and is implemented in the form of a single hidden layer fully connected neural network.
[0095] S4: Drug representation module, learn the multi-perspective unified representation of drugs by fusing molecular structure, clinical co-occurrence and interaction information. Specifically, the following steps are included:
[0096] 1) Molecular structure encoding process, use MPNN to encode the molecular structure graph G mol =(A,X) of each drug, to obtain the drug molecular vector That is
[0097] Z MPNN =MPNN(A,X).
[0098] 2) Multi-perspective graph encoding, respectively based on EHR network G ehr and DDI network G ddi Use GCN to extract drug node representation:
[0099] Z ehr =GCN(G ehr ),Z ddi =GCN(G ddi ).
[0100] 3) Multi-perspective fusion process with molecular perception, integrate molecular structure information into graph representation to enhance drug representation ability, and respectively mapped to contrast space through projection layer:
[0101] E ehr =Proj([Z ehr ;Z MPNN ]),E ddi =Proj([Zddi ; Z MPNN ]),
[0102] wherein
[0103] 4) Fusion representation calculation, integrating the feature representations of the two perspectives based on a gating mechanism to obtain the fused drug representation M ed :
[0104] M ed = σ(W[E ehr ; E ddi ]) · E ehr + (1-σ(W[E ehr ; E ddi ])) · E ddi
[0105] wherein σ is a Sigmoid function, is a learnable parameter matrix of gated fusion.
[0106] S5: Drug combination prediction module, fusing patient representation and drug representation to generate final multi-label prediction results through multi-source information fusion. Specifically, the following steps are included:
[0107] 1) Graph attention representation score calculation process. The drug embedding representation matrix M ed obtained by molecular perception graph contrastive learning is used to project the patient representation q t into the drug space to obtain the attention matching score:
[0108]
[0109] 2) History memory score calculation process. A key-value structure is constructed to represent the health status and drug use of the patient in the previous T-1 visits, and the matching weight with the current query is calculated based on the attention mechanism to obtain the history memory score:
[0110]
[0111] 3) Final drug recommendation generation process. The patient's current visit representation q t , drug representation and three perspectives of drug representation are spliced, and the final drug prediction result is output after the fusion layer:
[0112]
[0113] wherein σ is a Sigmoid function, represents the recommendation probability score of each drug in the current visit scenario.
[0114] S6: Loss function design and optimization module, combined with multiple optimization objectives to jointly train the model to improve recommendation accuracy and safety. Specifically, the following steps are included:
[0115] 1) Prediction accuracy loss function construction. Binary cross-entropy loss function is used to measure the difference between model prediction results and true drug labels, the expression is:
[0116]
[0117] Where, and are the ith term of the target drug representation and the output drug representation, |M| is the number of drugs.
[0118] 2) Multi-label consistency loss construction. To ensure that the correct class score is higher than the wrong class, multi-label hinge loss is introduced, the expression is as follows:
[0119]
[0120] 3) Drug safety loss function design. To reduce the potential risk of adverse drug-drug interactions in the recommended drug combination, a DDI constraint loss function is constructed, the expression is as follows:
[0121]
[0122] Where is the drug interaction (DDI) network, indicates that the ith drug and the jth drug have interaction, otherwise it is 0.
[0123] 4) Contrastive learning loss design, by maximizing the consistency of the same drug from different perspectives and minimizing the similarity of DDI drug pairs, to achieve safe and effective drug representation, the expressions are respectively:
[0124]
[0125] L contrast =L InfoNCE +λ·L margin ,
[0126] Where are the representations of drug i in EHR and DDI graph, is the gated fusion representation of drug i, λ is a pre-defined hyperparameter, τ is a temperature hyperparameter.
[0127] 5) Final loss function construction. By weighted fusion of four kinds of loss functions, the final optimization objective is formed:
[0128] L = aL bce + bL multi + gL ddi + lL contrast ,
[0129] where a, b, g, l are hyperparameters that control the weight of each loss, used to achieve an optimal trade-off between recommendation accuracy and drug safety.
Claims
1. A method and system of graph contrastive learning of fused clinical features for safe and effective personalized drug combination recommendation from patient electronic health records (EHRs), characterized in that, The key technologies of the system mainly include six modules: 1) Historical medical record data collection and preprocessing module, used to collect and process patient EHR data, extract the corresponding diagnosis, surgery and drug information of each patient for each visit, and construct a structured visit sequence; And generate drug co-occurrence EHR network according to the whole patient historical medical record data set, collect and organize drug-drug interaction (DDI) network and molecular structure information of all prescription drugs, and establish drug molecular structure graph in SMILES form. 2) Structure prior generation module, used to construct conditional probability matrix according to the entity co-occurrence relationship in EHR, and construct structure guide matrix (mask matrix) to assist graph representation learning. This module constructs a conditional probability matrix by calculating the conditional probability, captures the co-occurrence frequency between different types of entities, and generates a structure guide matrix to guide the attention propagation structure in the graph convolution network (GCN). 3) Patient representation module, used to construct a historical medical record heterogeneous graph for each patient's first T-1 historical medical record data set respectively, and perform feature propagation through multi-layer graph GCN, where the first layer uses the conditional probability matrix as the adjacency matrix, and the subsequent layers use the self-attention mechanism to generate the adjacency matrix, and the Hellinger distance is used to constrain the difference between the attention distribution of different layers; Then extract the diagnosis and surgery code sequence in the Tth visit, combine the first T-1 heterogeneous graph representation, construct the diagnosis and surgery sequence, and input it into the Transformer module for sequence modeling to generate the patient's current visit representation. 4) Drug representation module, which obtains the chemical molecular structure representation of the drug through the message passing neural network (MPNN), and combines the co-occurrence relationship in the EHR network and the embedding of the DDI network for collaborative contrast learning, to learn drug representation from multiple perspectives to improve the consistency and explainability of drug representation. 5) Drug combination prediction module, used to fuse patient representation and drug representation to generate personalized drug recommendation list. 6) Loss function design and optimization module, used to jointly optimize four types of objective functions, including prediction accuracy loss, multi-label consistency loss, drug safety loss and graph contrast learning loss, to improve the accuracy and safety of drug recommendation results through weighted combination.
2. The structure prior generation module of claim 1, the main steps of which are as follows: S1: conditional probability matrix generation process, based on all patient historical medical record data sets, respectively calculate the conditional probabilities p(m|d), p(d|m), p(p|m), p(m|p) corresponding to all diagnosis information d, surgery information p, drug information m, and then generate a conditional probability matrix and normalized to make the sum of each row equal to 1, where V represents the set of all nodes in the graph, and |V| is the total number of entities. S2: structure guiding matrix generation process, generating a structure guiding matrix from the conditional probability matrix P For determining whether a connection between nodes in a heterogeneous graph is allowed. If the connection is not allowed, M ij = -∞; otherwise, set M ij = 0.
3. The patient representation module of claim 1, which learns the structured representation of the patient's historical visits by constructing a multi-layer graph attention network, comprising the following steps: S1: Heterogeneous graph construction process, respectively, for the first T-1 times of the patient i's historical medical record data set, build a heterogeneous graph Where 1≤t≤T-1, node set V t Contains the diagnosis, surgery and drug information of the tth visit, edge set E t Indicates the co-occurrence relationship between nodes, and the edge weight is initialized based on the conditional probability matrix. S2: Heterogeneous graph attention adjacency matrix generation process, using self-attention mechanism to calculate the adjacency matrix of the jth layer of the tth visit, the formula is: where j is the jth layer of graph propagation, and is the representation of the previous layer node H (j -1) query and key matrices obtained by linear transformation, d is the dimension. S3: Heterogeneous graph propagation process, the update rule of each graph convolution layer is as follows: where P is a conditional probability matrix used to guide attention learning, j is the jth layer of graph propagation, is a linear transformation parameter for the jth layer. S4: Introduce Hellinger distance to regularize the graph structure and encourage the attention distribution to be consistent with the prior structure, the formula is: where P i and denote the i-th row of the conditional probability matrix and the structure attention matrix, respectively, N denotes the number of nodes in the graph, λ H is a predefined hyper-parameter, and λ H represents the Hellinger regularization coefficient. The larger λ H is, the closer the learned attention matrix is to the conditional probability. S5: Sequence modeling of diagnosis and surgery node representations for each patient. First, for the previous T-1 times of historical medical record data sets, the heterogeneous graph representations of diagnosis and surgery nodes are extracted respectively, and combined with the diagnosis and surgery representations of the Tth visit to obtain the visit vector through average pooling Subsequently, the diagnosis sequence and the surgery sequence are constructed respectively and sent into the Transformer encoding module for sequence modeling to obtain the current visit representation q of the patient t , that is wherein f(·) is a transformation function that projects the hidden state to the query and is implemented in the form of a single hidden layer fully connected neural network.
4. The drug representation module of claim 1, which learns the consistent representation of the drug from multiple perspectives by fusing the drug molecular structure, clinical co-occurrence and interaction information, comprising the following steps: S1: Molecular structure encoding process, using MPNN on the molecular structure graph G of each drug mol = (A, X) to obtain the drug molecule vector i.e. Z MPNN = MPNN(A, X). S2: Multi-view graph encoding, based on EHR network G ehr and DDI network G ddi Drug node representation using GCN: Z ehr = GCN(G ehr ), Z ddi = GCN(G ddi ). S3: Multi-view fusion process of molecular perception, which integrates molecular structure information into the graph representation to enhance drug characterization ability, and is mapped to the contrast space through the projection layer respectively: E ehr = Proj([Z ehr ; Z MPNN ]), E ddi = Proj([Z ddi ; Z MPNN ]), wherein S4: Fusion representation calculation, integrate the feature representations of the two perspectives based on the gating mechanism to obtain the fused drug representation M ed i.e. M ed = σ(W[E ehr ; E ddi ]) · E ehr + (1 - σ(W[E ehr ; E ddi ])) · E ddi , wherein σ is a Sigmoid function, is a learnable parameter matrix for gated fusion.
5. The drug combination prediction module of claim 1, fusing the patient representation and the drug representation to generate a final multi-label prediction result through multi-source information fusion. Specifically, it includes the following steps: S1: Graph attention representation score computation process. Drug embedding representation matrix M obtained by molecular perception graph contrastive learning ed , obtaining attention matching scores by projecting the patient representation q t to the drug space S2: History memory score calculation process. Build key-value structure Represent the health status and drug use of the patient in the previous T-1 visit, calculate the matching weight with the current query based on the attention mechanism, and get the history memory score: S3: Final drug recommendation generation process. Represent the current visit of the patient q t , drug representation and Splicing of drug representations from three perspectives, output final drug prediction results through fusion layer: where σ is a sigmoid function, representing the recommended probability score of each drug in the current consultation scenario.
6. The loss function design and optimization module of claim 1, combining multiple optimization objectives to jointly train the model to improve the recommendation accuracy and safety. Specifically, it includes the following steps: S1: Prediction accuracy loss function construction. Binary cross-entropy loss function is used to measure the difference between the model prediction result and the true drug label, that is wherein, and are the ith term of the target drug representation and the output drug representation, respectively, and |M| is the number of drugs. S2: Multi-label consistency loss construction. To ensure that the score of the correct class is higher than that of the wrong class, multi-label hinge loss is introduced, that is S3: Drug safety loss function design. To reduce the potential adverse reactions caused by drug interactions in the recommended drug combination, DDI constraint loss function is constructed, that is wherein is a drug-drug interaction (DDI) network, denotes that the ith drug and the jth drug have an interaction, otherwise 0. S4: Contrast learning loss design. By maximizing the consistency of the same drug from different perspectives and minimizing the similarity of DDI drug pairs, safe and effective drug representation is achieved, and its expressions are respectively: L contrast = L InfoNCE + λ · L margin , wherein are the representations of drug i in the EHR and DDI graphs, respectively, is the gated fusion representation of drug i, and λ is a predefined hyperparameter and τ is a temperature hyperparameter. S5: Final loss function construction. Four kinds of loss functions are fused by weighted method, and the final optimization objective function is constructed as: L = aL bce + βL multi + γL ddi + λL contrast , Where α, β, γ, λ are hyperparameters for controlling the weight of each loss, used to achieve the optimal trade-off between drug recommendation accuracy and safety.
Citation Information
Cited By
Drug recommendation method and device, electronic equipment and storage medium
CN121281868A
A method, apparatus, electronic device, and storage medium for recommending a drug
CN121281868B
