Drug recommendation method and system based on drug mapping and diagnosis augmentation
By constructing a drug recommendation model and establishing an explicit mapping relationship between drugs and diseases using a large language model and graph convolutional networks, the problems of ambiguity and misuse in drug recommendations in existing technologies are solved, enabling personalized and safe drug recommendations and improving the interpretability and accuracy of clinical applications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-11
- Publication Date
- 2026-03-24
AI Technical Summary
Existing drug recommendation methods lack an explicit mapping relationship between drugs and diseases in clinical applications, resulting in serious ambiguity in recommendations in scenarios with multiple coexisting diseases. This makes it difficult to meet the diagnostic and treatment needs of doctors, poses a risk of misuse and omission, and lacks interpretability and accuracy.
By constructing a drug recommendation model, including a diagnosis enhancement module, a drug mapping module, and a drug recommender module, a large language model is used to establish a clear correspondence between drugs and diagnoses and treatments. Drug representation is performed by combining cross-attention and graph convolutional networks, and the loss function is optimized for joint training, thereby realizing explicit mapping between drugs and diseases and personalized recommendations.
It improves the interpretability and accuracy of drug recommendations, meets the clinical needs in scenarios with multiple comorbidities, provides logically clear medication advice, reduces the risk of misuse and omission, and enhances the safety and effectiveness of treatment.
Smart Images

Figure CN121096523B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing and the field of recommendation systems, in particular to a drug recommendation method and system based on drug mapping and diagnosis enhancement. BACKGROUND
[0002] With the integration of medical research and artificial intelligence technology, drug recommendation has become a key supporting technology in modern medical system. Traditional clinical drug decision-making relies on the personal experience of doctors, which is highly subjective and limited by experience level. The rise of drug recommendation technology has brought innovation to this model. However, existing drug recommendation technology still has significant defects despite attempts to optimize recommendations through electronic health records, medical history data, etc.
[0003] 1. Drug recommendation is based only on the patient's current diagnosis code (such as ICD code) and prescription record, ignoring the time series characteristics contained in the medical history, making it difficult to capture the dynamic changes in the patient's health status. To make up for this deficiency, subsequent research has introduced time series modeling and recurrent neural networks to try to extract the association patterns between disease progression and drug prescriptions from historical consultation sequences. However, these methods generally model the patient as a whole, and the recommendation result is a unified drug set, without establishing an explicit mapping relationship between drugs and specific diseases, limiting the practicality of drug recommendation devices in complex multiple co-morbidity scenarios.
[0004] 2. In real clinical scenarios, doctors usually adopt the "one disease one drug" or "one disease multiple drugs" strategy when facing patients with multiple co-morbidities, i.e., developing a drug regimen for each diagnosis to ensure clear treatment logic and sufficient basis. This treatment paradigm requires drug recommendation methods not only to recommend drug combinations, but also to clearly identify the disease entities corresponding to each drug. However, existing mainstream drug recommendation methods still directly output a list of drugs in an end-to-end manner, lacking explicit modeling of the drug-disease association structure. Although some work attempts to reflect the importance of information sources through attention weights, the association mechanism is still implicit in the model, making it impossible to provide intuitive and traceable drug-disease correspondence paths.
[0005] 3. The "black box" recommendation mechanism makes it impossible for doctors to confirm that the drug is intended for the primary diagnosis, complications, or medical history, which can easily lead to misuse and omission risks, especially in complex multiple co-morbidity scenarios. The ambiguity of the recommendation seriously limits the practicality of the technology, which can easily lead to misuse or omission, thereby affecting treatment effectiveness and even endangering patient safety.
[0006] In summary, existing drug recommendation methods have key deficiencies in clinical interpretability and decision support accuracy. SUMMARY
[0007] The application aims to provide a drug recommendation method and system based on drug mapping and diagnosis enhancement, which improves the clinical interpretability and decision support accuracy of the model by decomposing multiple disease to multiple drug recommendation tasks into one disease to one or more drug recommendation tasks.
[0008] To achieve the above-mentioned purpose, the application is implemented through the following technical solutions.
[0009] The drug recommendation method based on drug mapping and diagnosis enhancement comprises the following steps:
[0010] S1, constructing a data set of a drug recommendation model: downloading a public medical data set, preprocessing the medical data set, dividing the medical data set into training data, verification data and test data in proportion, and combining to form a final data set;
[0011] S2, constructing a drug recommendation model: the drug recommendation model comprises a diagnosis enhancement module, a drug mapping module, a drug recommender module and a joint training module;
[0012] The diagnosis enhancement module takes diagnosis information, treatment method information and physical examination information as input, and outputs enhanced diagnosis information to the drug recommender module;
[0013] The drug mapping module takes diagnosis information, treatment method information and drug information as input, and outputs mapped drug information as a training label for single disease drug recommendation to the drug recommender module;
[0014] The drug recommender module takes enhanced diagnosis information, all drug information, all diagnosis information and all treatment method information as input, and outputs drug recommendation probability;
[0015] The joint training module takes drug recommendation probability as input, defines a local loss function and a global loss function, and optimizes the single disease drug recommendation task and the overall drug recommendation task target;
[0016] S3, training the drug recommendation model: in the final data set of step S1, a binary cross-entropy loss function and a multi-label hinge loss function are used to construct a total loss function, and an Adam optimizer is used to perform multiple rounds of iterative training on the drug recommendation model of step S2.
[0017] Further, the medical data set in step S1 comprises patient diagnosis records, patient treatment method records, patient physical examination records and patient prescription records, and the preprocessing comprises integrating the four types of records according to patient numbers and medical record numbers to form a medical record comprising diagnosis information, treatment method information, physical examination information and drug information;
[0018] The diagnosis enhancement module in step S2 first constructs a diagnosis enhancement Prompt by a pre-defined diagnosis enhancement Prompt template and inputs it into a large language model for matching, establishes a corresponding relationship between diagnosis and treatment methods and physical examinations, and generates diagnosis enhancement information without examination; then generates a diagnosis examination Prompt by a diagnosis examination Prompt template and inputs it into a large language model for auditing, and the information that passes the auditing is taken as enhanced diagnosis information; the drug mapping module first generates a drug mapping Prompt by a pre-defined drug mapping Prompt template and inputs it into a large language model for mapping, establishes a corresponding relationship between drugs and diagnosis and treatment methods, and generates drug mapping information without examination; generates a drug examination Prompt by a drug examination Prompt template and inputs it into a large language model for auditing, and the information that passes the auditing is taken as mapped drug information; the drug recommender module includes a diagnosis coding submodule and a drug coding submodule, the diagnosis coding submodule generates enhanced diagnosis representation, and the drug coding submodule constructs an external knowledge graph to obtain drug representation, and then calculates drug recommendation probability through weighted aggregation and a Sigmoid activation function.
[0019] Further, the diagnosis enhancement Prompt template in step S2 requires the output form to be a triple list of ["diagnosis", ["treatment method"], ["physical examination"]], and the diagnosis examination Prompt template requires auditing of medical relevance in the triple, and outputs "1" if it is correct, and outputs "0" otherwise;
[0020] The drug mapping Prompt template requires the output form to be a triple list of ["drug", ["diagnosis"], ["treatment method"]], and the drug examination Prompt template requires auditing of medical logic in the triple, and outputs "1" if it is correct, and outputs "0" otherwise.
[0021] Further, the specific implementation of the diagnosis coding submodule in step S2 includes: converting diagnosis, treatment methods and physical examinations into embedding representation through embedding matrix, calculating the influence weight of treatment methods and physical examinations on diagnosis through cross attention mechanism, and obtaining enhanced diagnosis representation through weighted aggregation;
[0022] The specific steps of the drug recommender module for calculating drug recommendation probability are: calculating the importance of enhanced diagnosis representation to each drug representation through attention mechanism, and outputting drug recommendation probability through linear transformation and Sigmoid activation function after weighted aggregation.
[0023] Further, the diagnosis coding submodule generates enhanced diagnosis representation by using cross attention mechanism:
[0024] ,
[0025] , ,
[0026] ,
[0027] wherein, , , is a trainable embedding matrix, converting diagnoses, treatment means and physical examinations into embedding representations , , , , , is the current enhanced diagnosis information, the plurality of treatment means corresponding to the diagnosis, and the physical examination information; , are the learnable parameter matrices of the two cross-attention mechanisms; is the dimension of the embedding vector representation; Softmax represents the Softmax activation function; , respectively represent the treatment means representation and the physical examination representation after importance is calculated; is the enhanced diagnosis representation; is a trainable parameter matrix, is a trainable bias parameter.
[0028] Further, the external knowledge graph of the drug encoding sub-module includes four kinds: drug and drug co-occurrence graph, drug and drug adverse interaction graph, drug and diagnosis co-occurrence graph, drug and treatment means co-occurrence graph;
[0029] The drug and drug co-occurrence graph and the drug and drug adverse interaction graph are modeled using a graph convolution network:
[0030] ,
[0031] ,
[0032] , , ,
[0033] wherein, , are the drug and drug co-occurrence representation and the drug and drug adverse interaction representation, respectively; , is a learnable parameter matrix; is the drug and drug co-occurrence graph, which is a matrix obtained by counting the frequency of all drug co-occurrences in the statistical drug recommendation training data set, and the value size in the matrix is between 0 and 1; is the drug and drug adverse interaction graph, which is used to indicate whether each pair of drugs has adverse interaction, 1 if yes, 0 if no; , are the initialized drug representations in the two graphs respectively; ReLU is the ReLU activation function; represents the value in the i-th row and i-th column of the matrix , is a diagonal matrix; represents the identity matrix, represents the activation function as a hyperparameter;
[0034] The drug and diagnosis co-occurrence graph and the drug and treatment means co-occurrence graph are modeled using a graph attention network:
[0035] ,
[0036] ,
[0037] , , ,
[0038] wherein, , are the drug and diagnosis co-occurrence representation and the drug and treatment means co-occurrence representation respectively; , , is a learnable parameter matrix; is the drug and diagnosis co-occurrence graph, which is a matrix obtained by counting the frequency of co-occurrence of all drugs and all diagnoses in the same prescription in the statistical drug recommendation training data set, and the value in the matrix ranges between 0 and 1; is the drug and treatment means co-occurrence graph, which is a matrix obtained by counting the frequency of co-occurrence of all drugs and all treatment means in the same prescription in the statistical drug recommendation training data set, and the value in the matrix ranges between 0 and 1; is the initialized drug representation; , is the initialized diagnosis and treatment means representation output by the diagnosis encoding submodule; LeakyReLU is the LeakyReLU activation function; m represents a drug, p represents a treatment means, M represents a set of all drugs, represents the neighbors of the i-th node, and H represents the number of attention heads in multi-head attention, and represent the first or neighbor node in the neighbor node set, represents the embedding representation of the k-th neighbor node, which can be the embedding representation of a certain diagnosis in or the embedding of a certain treatment means, denotes the embedding of the ith drug node;
[0039] Finally, the drug embeddings in the four graphs are weighted aggregated to obtain drug representations:
[0040]
[0041] wherein, are learnable parameters; [;] denotes the concatenation operation;
[0042] The drug recommendation probability is:
[0043]
[0044] wherein, is a learnable parameter matrix; Softmax and Sigmoid are the Softmax and Sigmoid activation functions, respectively.
[0045] Further, the joint training module generates a global drug recommendation probability based on the maximum pooling is:
[0046]
[0047]
[0048] wherein, is a loss function used for the final training combining the local drug recommendation task and the global drug recommendation task, are the loss function of the drug recommendation task and the loss function of the global drug recommendation task of the kth diagnosis in the ith patient, respectively; is a hyperparameter for balancing the local drug recommendation task and the global drug recommendation task; is the set of diagnosis information of the jth visit of the ith patient.
[0049] Further, the total loss function construction process of the drug recommendation model in step S3 is:
[0050]
[0051]
[0052] wherein, is a binary cross-entropy loss function, is a multi-label hinge loss function, represents the probability that the kth drug is recommended for the jth diagnosis of the ith patient; represents the true label of whether the kth drug is recommended for the jth diagnosis of the ith patient; M is the set of all drugs;
[0053] The above loss function is brought into the joint training module to obtain the final loss function:
[0054] ,
[0055] wherein, and have the same mathematical definition and are uniformly represented as , is a hyperparameter used to coordinate the binary cross-entropy loss function and the multi-label hinge loss function.
[0056] Further, the learning rate of the Adam optimizer is set to 0.0001, and other hyperparameters adopt the default values of PyTorch; the division ratios of training data, validation data and test data are 4:1:1.
[0057] The drug recommendation system based on drug mapping and diagnosis enhancement is used to implement the above method, comprising:
[0058] A drug recommendation data set construction unit is configured to download a public medical data set, preprocess the medical data set, and divide the training data, validation data and test data in proportion;
[0059] A drug recommendation model construction unit is configured to construct a diagnosis enhancement module, a drug mapping module, a drug recommender module and a joint training module to form a drug recommendation model to predict the drug recommendation probability required by a patient currently visiting a doctor;
[0060] A drug recommendation model training unit is configured to construct a total loss function, adopt an Adam optimizer, and perform multi-round iterative training on the drug recommendation model.
[0061] The advantages of the present application are:
[0062] The drug recommendation method based on drug mapping and diagnosis enhancement proposed by the present application deeply mines the relationship between recommended drugs and diseases, can recommend the required drug prescription for a single disease, thereby improving the explainability and precision of drug recommendation, constructs the overall recommended result, and coordinates the training process of single disease recommendation and overall recommendation;
[0063] Enhance the richness of diagnosis information: the diagnosis enhancement module associates diagnosis with treatment methods and physical examinations through a large language model, supplements the clinical background and severity information of diagnosis, and provides more comprehensive patient health state modeling for accurate recommendation;
[0064] Improving recommendation accuracy: The drug mapping module uses large language models to establish clear connections between drugs, diagnoses, and treatment methods in medical records, supporting the training process for single-disease drug recommendations;
[0065] Ensuring clinical safety: The drug recommender module implements single-disease drug recommendations. Based on enhanced diagnostic information, the module accurately models the health status of patients under a single disease and provides accurate and personalized drug recommendations. The drug coding submodule models drug adverse interactions to reduce potential drug safety hazards;
[0066] Clinical practicality: The system conforms to the diagnosis and treatment paradigm of real clinical multiple medication, with clear and sufficient recommendation results. It can directly assist doctors in developing medication plans and is suitable for complex clinical scenarios such as multiple disease coexistence. BRIEF DESCRIPTION OF DRAWINGS
[0067] Figure 1 The figure is a schematic diagram of the overall framework of the drug recommendation method based on drug mapping and diagnosis enhancement;
[0068] Figure 2 The figure is a flowchart of the diagnosis enhancement module;
[0069] Figure 3 The figure is a flowchart of the drug mapping module;
[0070] Figure 4 The figure is a structural flowchart of the drug recommendation model;
[0071] Figure 5 The figure is a schematic diagram of the drug recommendation system based on drug mapping and diagnosis enhancement. DETAILED DESCRIPTION
[0072] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application.
[0073] Embodiment 1
[0074] This embodiment is based on the PyTorch deep learning framework, and the data set is implemented using the MIMIC-III medical data set. Please refer to Figure 1 .
[0075] S1, Constructing a drug recommendation data set
[0076] The MIMIC-III data set disclosed on the download network is taken as the original data of drug recommendation. The medical data set mainly uses four data files: patient diagnosis record, patient treatment record, patient physical examination record and patient prescription record. The patient diagnosis record contains patient number, medical record number, diagnosis order, diagnosis disease number; the patient treatment record contains patient number, medical record number, treatment method order, treatment method procedure number; the physical examination record contains patient number, medical record number, physical examination type, physical examination value, value unit; the patient prescription record contains patient number, medical record number, prescription drug number; a specific patient is identified according to the patient number and medical record number in different record tables, and the patient's medical record is obtained by integrating all four files.
[0077] The MIMIC-III data set provides detailed information of patient inquiry. The data format of patient diagnosis record is as follows:
[0078] Table 1. Patient diagnosis record
[0079]
[0080] The diagnosis order is the diagnosis order of the same medical record of the same patient, which only determines the order of the diagnosis issued by the doctor and has no other meaning; the diagnosis disease number is ICD-9 code.
[0081] The data format of patient treatment record is as follows:
[0082] Table 2. Patient treatment record
[0083]
[0084] The treatment method order and diagnosis order are the same and have no other meaning; the treatment method procedure number is ICD-9 code.
[0085] The data format of patient physical examination record is as follows:
[0086] Table 3. Patient physical examination record
[0087]
[0088] The data format of patient prescription record is as follows:
[0089] Table 4. Patient prescription record
[0090]
[0091] The prescription drug number is international drug code (NDC).
[0092] S2、Data preprocessing
[0093] Preprocess each diagnosis record in the medical dataset, combine the patient data from different record tables using the patient number, and form a new table suitable for model reading.
[0094] Example: The data format after preprocessing the dataset is as follows:
[0095]
[0096] Among them, the medical record is a record of a patient's visit, which is divided into four parts: diagnosis information, treatment information, physical examination information, and drug information.
[0097] S3, build training, validation and test data
[0098] After preprocessing, the patient's inquiry data is randomly divided into 4:1:1 sets, corresponding to the training set, validation set, and test set.
[0099] S4, drug recommendation model construction, please refer to Figure 4 , including diagnosis enhancement module, drug mapping module, drug recommender module and joint training module:
[0100] S41, diagnosis enhancement module, taking diagnosis, treatment and physical examination information as input, generating enhanced diagnosis information according to the above information, please refer to Figure 2 .
[0101] First, fill in the diagnosis, treatment and physical examination information into the pre-defined diagnosis enhancement Prompt template to form the diagnosis enhancement Prompt; then send the Prompt into the large language model for matching to establish the correspondence between diagnosis and treatment and physical examination, thereby generating the unexamined diagnosis enhancement information:
[0102]
[0103] Among them, diag, proc and test represent the diagnosis, treatment and physical examination information of the i-th patient, respectively; diag represents the unexamined diagnosis enhancement information;
[0104] Example of diagnosis enhancement Prompt content as follows:
[0105]
[0106] Among them, diag is the diagnosis information in the patient's medical record; proc is the treatment information in the patient's medical record; test is the physical examination information in the patient's medical record; len() function is used to determine the number of codes in the information.
[0107] The unexamined diagnostic enhancement information is filled into the template of the diagnostic examination Prompt to generate the diagnostic examination Prompt, which is sent to the large language model for examination and review to verify whether the unexamined diagnostic enhancement information meets the standardized format and medical logic. If the examination is passed, the mapped diagnostic information is sent to the drug recommender module, otherwise the mapping is performed again; the formula is as follows:
[0108]
[0109]
[0110] wherein, represents the examination result of the unexamined diagnostic enhancement information of the i-th patient; represents the enhanced diagnostic information.
[0111] The content of the diagnostic examination Prompt is as follows:
[0112]
[0113] wherein, input_list is the unexamined diagnostic enhancement information.
[0114] S42, a drug mapping module is constructed, which takes diagnosis, treatment means and drug information as input, and generates mapped drug information according to the above information, please refer to Figure 3 .
[0115] The diagnosis, treatment means and drug information are filled into the pre-defined drug mapping Prompt template to form the drug mapping Prompt; then the Prompt is sent to the large language model for mapping to establish the corresponding relationship between the drug and the treatment means and the diagnosis, thereby generating unexamined drug mapping information:
[0116]
[0117] wherein, diag, proc and med respectively represent the diagnosis, treatment means and drug information of the i-th patient; represents the unexamined drug mapping information;
[0118] The content of the drug mapping Prompt is as follows:
[0119]
[0120] wherein, diag is the diagnosis information in the patient's medical record; proc is the treatment means information in the patient's medical record; med is the drug information in the patient's medical record; the len() function is used to judge the number of codes in the information.
[0121] The unexamined drug mapping information is filled into the template of the drug examination Prompt to generate the drug examination Prompt, which is sent to the large language model for examination and review to verify whether the unexamined drug mapping information meets the standardized format and medical logic. If the examination is passed, the drug mapping information is sent to the drug recommender module as mapped drug information, otherwise the mapping is performed again:
[0122]
[0123]
[0124] wherein, represents unexamined drug mapping information, represents the review result of the drug mapping information, represents the final drug mapping information.
[0125] The drug examination Prompt content is as follows:
[0126]
[0127] wherein, input_list is unexamined drug mapping information.
[0128] S43, a drug recommender module is constructed, which takes the enhanced diagnosis information output by the diagnosis enhancement module and all drug, diagnosis and treatment method information as input, and is used to predict the drug recommendation probability required by the patient in the current visit. In this embodiment, taking a single piece of enhanced diagnosis information of a single patient as an example, removing the superscript representing the i-th patient, the construction steps of the drug recommender module are as follows.
[0129] S431, a diagnosis coding submodule is constructed
[0130] The diagnosis coding submodule takes the enhanced diagnosis information output by the diagnosis enhancement module as input, uses the cross-attention attention mechanism to capture the importance of treatment methods and physical examinations for diagnosis, and outputs enhanced diagnosis representation:
[0131] ,
[0132] , ,
[0133] ,
[0134] wherein, , , is a trainable embedding matrix, which converts diagnosis, treatment method and physical examination into embedding representation , 、 , 、 、 diagnoses, a plurality of treatment means corresponding to the diagnoses, and physical examination information in the current enhanced diagnosis information; 、 are learnable parameter matrices of two cross-attention mechanisms; is the dimension of the embedded vector representation; Softmax represents the Softmax activation function; 、 respectively represent the treatment means representation and the physical examination representation after importance is calculated; is an enhanced diagnosis representation; is a trainable parameter matrix, is a trainable bias parameter.
[0135] For example, in the pytorch framework, the corresponding code implementation is as shown below:
[0136] diagnoses_embeddings=self.diagnosis_embedding(torch.LongTensor(diag).to(self.device));
[0137] procedures_embeddings=[];
[0138] for index,pinenumerate(proc):
[0139] procedure_embeddings=self.procedure_embedding(torch.LongTensor([p]).to(self.device));
[0140] procedure_embeddings=torch.softmax(self.p_attn_w(procedure_embeddings)@diagnoses_embeddings[index].unsqueeze(-1),dim=1) procedure_embeddings;
[0141] procedures_embeddings.append(torch.sum(procedure_embeddings,keepdim=False,dim=1));
[0142] procedures_embeddings = torch.cat(procedures_embeddings, dim = 0);
[0143] labtests_embeddings = [];
[0144] for index, l in enumerate(labtest):
[0145] labtest_embeddings = self.lab_embedding(torch.LongTensor([l[0]]).to(self.device));
[0146] scale = torch.LongTensor([l[1]]).to(self.device).view(1, -1, 1);
[0147] labtest_embeddings = labtest_embeddings * scale;
[0148] labtest_embeddings = torch.softmax(self.l_attn_w(labtest_embeddings) @ diagnoses_embeddings[index].unsqueeze(-1), dim = 1) * labtest_embeddings;
[0149] labtests_embeddings.append(torch.sum(labtest_embeddings, keepdim = False, dim = 1))labtests_embeddings = torch.cat(labtests_embeddings, dim = 0);[[ID=?]] [[ID=?]]
[0150] diagnoses_embeddings = torch.cat([diagnoses_embeddings, procedures_embeddings, labtests_embeddings], dim = 1) 。
[0151] S432. Build the drug encoding sub - module
[0152] It should be noted that there seems to be an error in line 26 where there is an incorrect concatenation in the original code. The corrected code might be something like `labtests_embeddings.append(torch.sum(labtest_embeddings, keepdim = False, dim = 1)); labtests_embeddings = torch.cat(labtests_embeddings, dim = 0);` which is reflected in the translation. Also, there are some lines with tags ` ` and `
[0150] ` which seem to be mislabeled in the original, and I've just left them as they are in the translation for the sake of following the instruction.The drug coding sub-module takes all diagnoses, all drugs and all treatment methods in the drug recommendation training data set as input, and builds all drugs, diagnoses and treatment methods in the drug recommendation training data set into four external knowledge graphs, that is, drug and drug co-occurrence graph, drug and drug adverse interaction graph, drug and diagnosis co-occurrence graph, and drug and treatment method co-occurrence graph. Among them, the drug and drug co-occurrence graph and the drug and drug adverse interaction graph enter the graph convolution network for relationship modeling, and the drug and diagnosis co-occurrence graph and the drug and treatment method co-occurrence graph enter the graph attention network for modeling. Then, the drug embeddings in the four graphs are aggregated to obtain drug representation.
[0153] The drug and drug co-occurrence graph and the drug and drug adverse interaction graph are modeled using a graph convolution network:
[0154] ,
[0155] ,
[0156] ,
[0157] , ,
[0158] wherein, , are drug and drug co-occurrence representation and drug and drug adverse interaction representation, respectively; , are learnable parameter matrices; is the drug and drug co-occurrence graph, which is a matrix obtained by counting the frequency of all drug co-occurrences in the drug recommendation training data set, and the value in the matrix is between 0 and 1; is the drug and drug adverse interaction graph, which is used to indicate whether each pair of drugs has an adverse effect, and is 1 if it has an adverse effect and 0 if it does not; , are the initialized drug representations in the two graphs, respectively; ReLU is the ReLU activation function; represents the value in the i-th row and i-th column of the matrix , is a diagonal matrix; represents the unit matrix, represents the activation function as a hyperparameter;
[0159] The drug and diagnosis co-occurrence graph and the drug and treatment method co-occurrence graph are modeled using a graph attention network:
[0160] ,
[0161] ,
[0162] , ,
[0163] ,
[0164] where, , are drug and diagnosis co-occurrence representation and drug and treatment co-occurrence representation, respectively; , , are learnable parameter matrices; is drug and diagnosis co-occurrence graph, which is a matrix obtained by counting the frequency of all drugs and all diagnoses co-occurring in the same prescription in the statistical drug recommendation training data set, and the value in the matrix is between 0 and 1; is drug and treatment co-occurrence graph, which is a matrix obtained by counting the frequency of all drugs and all treatments co-occurring in the same prescription in the statistical drug recommendation training data set, and the value in the matrix is between 0 and 1; is the initialized drug representation; , is the initialized diagnosis and treatment representation output by the diagnosis encoding submodule; LeakyReLU is a LeakyReLU activation function; m represents a drug, p represents a treatment, and M represents a set of all drugs, represents the neighbors of the ith node, and H represents the number of attention heads in multi-head attention, and represent the first or neighbor node in the neighbor node set, represents the embedding representation of the kth neighbor node, which can be the embedding representation of a diagnosis in or the embedding representation of a treatment in, represents the embedding representation of the ith drug node;
[0165] Finally, the drug embeddings in the four graphs are aggregated to obtain the drug representation:
[0166] ,
[0167] where, , , are all learnable parameters; [;] represents the concatenation operation.
[0168] For example, in the pytorch framework, the code implementation corresponding to the concatenation of the four types of representations described above is as follows:
[0169] ehr_embedding, ddi_embedding=self.med_gcn();
[0170] dmc_embedding,pmc_embedding=self.med_gat(self.diagnosis_embedding(torch.LongTensor([i for i in range(self.voc_size[0])]).to(self.device)),self.procedure_embedding(torch.LongTensor([i for i in range(self.voc_size[1])]).to(self.device)));
[0171] drug_embedding=self.med_linear(torch.cat([ehr_embedding-self.inter2 ddi_embedding, dmc_embedding, pmc_embedding], dim=1))
[0172] Wherein, self.med_gcn() is a graph convolutional network for encoding drug and drug co-occurrence graph, drug and drug adverse interaction graph; self.med_gat() is a graph attention network for encoding drug and diagnosis co-occurrence graph, drug and treatment method co-occurrence graph.
[0173] S433, calculate drug recommendation probability
[0174] The global representation aggregation layer takes the enhanced diagnosis representation output by the diagnosis encoding submodule in step S431 and the drug representation output by the drug encoding submodule in step S432 as input, aggregates the representation, and calculates the drug recommendation probability. Specifically, the importance of the enhanced diagnosis representation to each drug in the drug representation is queried using a weighted aggregation method based on an attention mechanism, and this information is added to the original enhanced diagnosis representation. After linear transformation, the drug recommendation probability is calculated using an activation function:
[0175] ,
[0176] Wherein, is a learnable parameter matrix; Softmax and Sigmoid are the Softmax and Sigmoid activation functions, respectively.
[0177] For example, in the pytorch framework, the code implementation corresponding to the above description is as follows:
[0178] diagnoses_embeddings=self.patient_linear(diagnoses_embeddings);
[0179] logit=F.sigmoid(self.final_fcn(F.softmax(diagnoses_embeddings@drug_embedding.transpose(0,1), dim=-1)@drug_embedding + diagnoses_embeddings))
[0180] where self.patient_linear is a learnable linear layer.
[0181] S44, a joint training module is constructed, taking the drug recommendation probability output by the drug recommender module in S43 as input, to optimize the parameters of the drug recommender module in the single disease drug recommendation scenario, and realize end-to-end joint training. Specifically, the module optimizes these single disease drug recommendation task objectives and the original overall drug recommendation task objectives by defining joint local loss functions and global loss functions, thereby ensuring the collaboration and consistency between different tasks, improving the interpretability and overall performance of the model.
[0182] S5, based on the data set of the drug recommendation model, the drug recommendation model is trained in multiple rounds of iteration, as follows
[0183] S51, a loss function is constructed, and the training target is to calculate the probability of each drug being recommended, so binary cross-entropy loss function and multi-label hinge loss function are used.
[0184] The above loss function is brought into the joint training module constructed in S44 to obtain the final loss function, which coordinates the binary cross-entropy loss function and the multi-label classification loss function through hyperparameters.
[0185] ,
[0186] ,
[0187] wherein, is the binary cross-entropy loss function, is the multi-label hinge loss function, represents the probability of the kth drug being recommended for the jth diagnosis of the ith patient; represents the true label of whether the kth drug is recommended for the jth diagnosis of the ith patient; M is the set of all drugs;
[0188] The loss function is brought into the joint training module to obtain the final loss function:
[0189] ,
[0190] wherein, and have the same mathematical definition, and are uniformly represented as , is a hyperparameter used to coordinate the binary cross-entropy loss function and the multi-label hinge loss function.
[0191] The loss function described above can be represented in pytorch using the following code:
[0192] sub_loss_bce=F.binary_cross_entropy(result, sub_loss_bce_target);
[0193] sub_loss_multi=F.multilabel_margin_loss(result, sub_loss_multi_target);
[0194] max_logits, max_indices=torch.max(result, dim=0);
[0195] max_logits=max_logits.view(1, -1);
[0196] all_loss_bce=F.binary_cross_entropy(max_logits, all_loss_bce_target);
[0197] all_loss_multi=F.multilabel_margin_loss(max_logits, all_loss_multi_target);
[0198] loss=(0.95 sub_loss_bce + 0.05 sub_loss_multi) args.alpha + (1-args.alpha) (0.95 all_loss_bce + 0.05 all_loss_multi).
[0199] wherein, result is the single disease drug recommendation probability output by the model; max_logits is the global drug recommendation probability after pooling; F.binary_cross_entropy and F.multilabel_margin_loss are classes representing the binary cross-entropy loss function and the multi-label classification loss function in pytorch; sub_loss_bce_target and sub_loss_multi_target are the results used for the binary cross-entropy loss function and the multi-label classification loss function, respectively, output by the drug mapping module; and all_loss_bce_target is the real result used for the binary cross-entropy loss function and the multi-label classification loss function.
[0200] S52, using the Adam algorithm as the optimization function of the model, the learning rate parameter is set to 0.0001, and other hyperparameters use the default values in PyTorch.
[0201] In the experiment, the area under the ROC curve, the adverse drug interaction rate between drugs, the Jaccard coefficient and the F1 score are selected as evaluation indexes.
[0202] The optimization function described above can be represented by the following code in pytorch:
[0203] optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate);
[0204] wherein, torch.optim.Adam is the Adam optimization function embedded in pytorch; model.parameters() is the parameter set for model training; and learning_rate is the learning rate.
[0205] The model of the present application is tested on the MIMIC-III public data set, and the experiment shows that the model of the present application has better results than the existing model, and the comparison of the experimental results is shown in the following table:
[0206] Table 5 Comparison of experimental results
[0207]
[0208] The model of the present application and the existing model are compared, and it can be seen that the method of the present application has the best performance among other methods.
[0209] Embodiment 2
[0210] The embodiment is based on the embodiment 1, and a drug recommendation system based on drug mapping and diagnosis enhancement is constructed. Please refer to Figure 5 , comprising:
[0211] A drug recommendation dataset construction unit is configured to download a public medical dataset, preprocess the medical dataset, and proportionally divide training data, verification data, and test data;
[0212] A drug recommendation model construction unit is configured to construct a diagnosis enhancement module, a drug mapping module, a drug recommender module, and a joint training module, and form a drug recommendation model to predict a drug recommendation probability required by a patient in a current visit;
[0213] A drug recommendation model training unit is configured to construct a total loss function, adopt an Adam optimizer, and perform multi-round iterative training on the drug recommendation model.
[0214] Finally, it should be noted that: the above only describes the preferred embodiments of the present application and is not used to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A drug recommendation method based on drug mapping and diagnostic enhancement, characterized in that, Including the following steps: S1. Dataset for constructing the drug recommendation model: Download publicly available medical datasets, preprocess the medical datasets, divide them proportionally to obtain training data, validation data and test data, and combine them to form the final dataset; S2. Constructing a drug recommendation model: The drug recommendation model includes a diagnostic enhancement module, a drug mapping module, a drug recommender module, and a joint training module; The diagnostic enhancement module takes diagnostic information, treatment information, and physical examination information as input, and outputs enhanced diagnostic information to the drug recommender module. The drug mapping module takes diagnostic information, treatment information, and drug information as input, and outputs mapped drug information to serve as training labels for drug recommendations for a single disease to the drug recommender module. The drug recommender module takes enhanced diagnostic information, all drug information, all diagnostic information, and all treatment information as input, and outputs the drug recommendation probability. The joint training module takes the drug recommendation probability as input, defines a local loss function and a global loss function, and optimizes the objectives of the single disease drug recommendation task and the overall drug recommendation task. S3. Training the drug recommendation model: In the final dataset of step S1, the total loss function is constructed using the binary cross-entropy loss function and the multi-label hinge loss function. The Adam optimizer is used to train the drug recommendation model of step S2 in multiple rounds of iteration. The medical dataset mentioned in step S1 includes patient diagnosis records, patient treatment records, patient physical examination records, and patient prescription records. The preprocessing includes integrating the four types of records by patient number and medical record number to form a medical record containing diagnostic information, treatment information, physical examination information, and medication information. In step S2, the diagnostic enhancement module first constructs a diagnostic enhancement prompt using a predefined diagnostic enhancement prompt template and sends it to a large language model for matching, establishing a correspondence between diagnosis and treatment methods and physical examinations, generating unchecked diagnostic enhancement information; then, the unchecked diagnostic enhancement information is used to generate a diagnostic examination prompt using a diagnostic examination prompt template and sent to the large language model for review, with the approved information serving as enhanced diagnostic information; the drug mapping module first generates a drug mapping prompt using a predefined drug mapping prompt template and sends it to the large language model for mapping, establishing a correspondence between drugs and diagnosis and treatment methods, generating unchecked drug mapping information; then, the unchecked drug mapping information is used to generate a drug examination prompt using a drug examination prompt template and sent to the large language model for review, with the approved information serving as mapped drug information; the drug recommender module includes a diagnostic encoding submodule and a drug encoding submodule. The diagnostic encoding submodule generates enhanced diagnostic representations, and the drug encoding submodule constructs an external knowledge graph to obtain drug representations, which are then weighted and aggregated using a Sigmoid activation function to calculate the drug recommendation probability; The specific implementation of the diagnostic coding submodule includes: converting diagnosis, treatment methods, and physical examinations into embedded representations through an embedding matrix; calculating the influence weights of treatment methods and physical examinations on diagnosis through a cross-attention mechanism; and obtaining an enhanced diagnostic representation after weighted aggregation. The external knowledge graph of the drug coding submodule includes four types: drug-drug co-occurrence graph, drug-drug adverse interaction graph, drug-diagnosis co-occurrence graph, and drug-treatment co-occurrence graph. Using graph convolutional networks to model drug-drug co-occurrence graphs and drug-drug adverse interaction graphs: , , , , , in, , These are, respectively, the representation of drug and drug co-occurrence and the representation of drug and adverse drug interactions; , It is a learnable parameter matrix; It is a drug co-occurrence map, which is a matrix obtained by statistically analyzing the co-occurrence frequency of all drugs in the drug recommendation training dataset. The values in the matrix are between 0 and 1. This is a drug-drug interaction diagram, used to illustrate whether each pair of drugs has an adverse effect; if it does, it is 1, and if it does not, it is 0. , These are the drug representations initialized in the two graphs; ReLU is the ReLU activation function. Representation matrix The value in the i-th row and i-th column of the data. It is a diagonal matrix; Represents the identity matrix. This represents the activation function as a hyperparameter. For function The independent variable; Modeling drug-diagnosis co-occurrence graphs and drug-treatment co-occurrence graphs using graph attention networks: , , , , , in, , These are, respectively, the representation of co-occurrence of drugs and diagnostics, and the representation of co-occurrence of drugs and treatments; , , It is a learnable parameter matrix; It is a drug and diagnosis co-occurrence map, which is a matrix obtained by statistically analyzing the frequency of all drugs and all diagnoses in the same prescription in the drug recommendation training dataset. The value of the matrix is between 0 and 1. It is a drug and treatment co-occurrence graph, which is a matrix obtained by statistically analyzing the frequency of all drugs and all treatments in the same prescription in the drug recommendation training dataset. The value of the matrix is between 0 and 1. Drug representation for initialization; , This represents the initialization of diagnostic and treatment methods output by the diagnostic coding submodule; LeakyReLU is the LeakyReLU activation function; m represents the drug, p represents the treatment method, and M represents the set of all drugs. Let H represent the neighbors of the i-th node, and let H represent the number of attention heads in the multi-head attention mechanism. and Represents the set of neighboring nodes. or One neighboring node, The embedding representation of the k-th neighbor node may be: Embedded representation of a certain diagnosis or Embedded representation of a certain treatment method in the text. This represents the embedding representation of the i-th drug node; Finally, the drug embeddings from the four graphs are weighted and aggregated to obtain the drug representation: , in, , , All are learnable parameters; [;] indicates a concatenation operation; The probability of recommending the drug is: , in, It is a learnable parameter matrix; Softmax and Sigmoid are the Softmax and Sigmoid activation functions, respectively.
2. The drug recommendation method based on drug mapping and diagnostic enhancement according to claim 1, characterized in that, The diagnostic enhancement prompt template in step S2 requires the output to be a list of triplets in the form of ["diagnosis", ["treatment method"], ["physical examination"]]. The diagnostic examination prompt template requires the verification of medical relevance within the triplets. If the relevance is met, the output is "1"; otherwise, the output is "0". The drug mapping prompt template requires the output to be a list of triples in the form of ["drug", ["diagnosis"], ["treatment"]]. The drug check prompt template requires the medical logic within the triples to be verified. If the logic is correct, the output is "1"; otherwise, the output is "0".
3. The drug recommendation method based on drug mapping and diagnostic enhancement according to claim 1, characterized in that, The diagnostic coding submodule uses a cross-attention mechanism to generate enhanced diagnostic representations: , , , , in, , , To create a trainable embedding matrix, diagnoses, treatments, and physical examinations are converted into embedding representations. , , , , , This includes the diagnosis, the multiple treatment options corresponding to the diagnosis, and the physical examination information in the current enhanced diagnostic information. , Here are the learnable parameter matrices for the two cross-attention mechanisms; It represents the dimension of the embedding vector representation; Softmax represents the Softmax activation function; , These represent treatment methods and physical examinations, respectively, after calculating their importance. To enhance diagnostic representation; For a trainable parameter matrix, These are trainable bias parameters.
4. The drug recommendation method based on drug mapping and diagnostic enhancement according to claim 1, characterized in that, The joint training module generates global drug recommendation probabilities based on maximized pooling. for: , , in, The loss function used for the final training that combines the local drug recommendation task and the global drug recommendation task. , These are the loss functions for the drug recommendation task for the k-th diagnosis in the i-th patient and the loss function for the global drug recommendation task, respectively. These are hyperparameters used to balance the local drug recommendation task and the global drug recommendation task. It is the set of diagnostic information for the i-th patient during the j-th visit.
5. The drug recommendation method based on drug mapping and diagnostic enhancement according to claim 4, characterized in that, The process of constructing the total loss function of the drug recommendation model in step S3 is as follows: , , in, The binary cross-entropy loss function is... For multi-label hinge loss function, This represents the probability that the k-th drug is recommended for the j-th diagnosis of the i-th patient; This represents the true label indicating whether the j-th diagnosis and k-th drug are recommended for the i-th patient; M is the set of all drugs. Substituting the above loss function into the joint training module, we obtain the final loss function: , in, and Having the same mathematical definition, they are uniformly represented as , These are hyperparameters used to coordinate the binary cross-entropy loss function and the multi-label hinge loss function.
6. The drug recommendation method based on drug mapping and diagnostic enhancement according to claim 1, characterized in that, The learning rate of the Adam optimizer is set to 0.0001, and other hyperparameters use the default values of PyTorch; the ratio of training data, validation data, and test data is 4:1:
1.
7. A drug recommendation system based on drug mapping and diagnostic enhancement, characterized in that, To implement the method of claim 1, comprising: Drug recommendation dataset construction unit: used to download publicly available medical datasets, preprocess the medical datasets, and divide them into training data, validation data, and test data according to a certain ratio; Drug recommendation model building unit: used to build a diagnostic enhancement module, a drug mapping module, a drug recommender module, and a joint training module, forming a drug recommendation model to predict the probability of drug recommendations needed for a patient's current medical visit; Drug recommendation model training unit: used to construct the total loss function, employing the Adam optimizer to perform multiple rounds of iterative training on the drug recommendation model.
Citation Information
Patent Citations
Drug recommendation method and system based on drug importance representation learning
CN117995424A
Drug recommendation method and system based on fine-grained relationship enhancement
CN119296720A