Drug recommendation method and system based on feature fusion and graph construction

The drug recommendation method based on feature fusion and graph construction, combined with CNN, Transformer and GAT, solves the problems of insufficient safety and interpretability in drug recommendation, and achieves more accurate and safe personalized drug combination recommendations.

CN120674094APending Publication Date: 2025-09-19SHANDONG NORMAL UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510770561.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

Existing deep learning-based drug recommendation methods fail to simultaneously consider the local correlation patterns and long-term conditions between various medical data in a single visit when modeling patient representation, and ignore the complex interactions between drugs, resulting in insufficient safety and interpretability of drug recommendations.

Method used

A feature fusion and graph construction method is adopted to extract local and global features through the CAT module of CNN and Transformer, and the graph attention network (GAT) is combined to model drug coexistence, interaction and sensitive information. Causal reasoning is used to correct errors, and a joint loss function is constructed to optimize model training.

Benefits of technology

It improves the safety and explainability of drug recommendations, enhances the personalization and accuracy of drug combinations, provides significant result interpretation capabilities, and reduces the risk of drug interactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120674094A_ABST
    Figure CN120674094A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of intelligent medical treatment, and provides a drug recommendation method and system based on feature fusion and graph construction, and the method comprises the steps: carrying out the local feature extraction and global feature extraction of a diagnosis sequence, an operation sequence and a drug sequence, fusing the local feature extraction and the global feature extraction, and carrying out the global feature extraction; obtaining a diagnostic representation, a surgical representation and a drug representation; by fusing local feature extraction and global feature extraction, the health condition of the patient can be represented more comprehensively; according to the electronic health record data set, establishing an electronic health record graph, a drug interaction graph and a drug sensitivity graph, obtaining a drug representation by using the established electronic health record graph, drug interaction graph and drug sensitivity graph and a preset graph attention network, and fusing the drug representation with the drug representation obtained by feature extraction to obtain a drug representation; weight contributions of different medical events in recommendation decisions can be displayed, doctors are helped to understand logic behind recommendation, and the model has remarkable result interpretation ability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of smart medical technology, and in particular relates to a drug recommendation method and system based on feature fusion and graph construction. Background Art

[0002] Electronic Health Records (EHRs) are electronic medical information generated during a patient's hospital visit, including diagnostic histories, surgical records, and medication prescriptions. As healthcare systems continue to improve, EHRs have shown great potential in assisting physicians in clinical decision-making and improving the quality of healthcare services. Leveraging the ever-increasing volume of EHR data, drug recommendations play a key role in promoting personalized medicine and improving patient health outcomes. Drug recommendation systems can learn from the correlations within EHR sequences to support clinical decision-making and develop effective and safe drug combinations tailored to a patient's health status. Furthermore, adverse drug interactions (DDIs) can lead to reduced efficacy, serious adverse reactions, increased toxicity, impaired metabolism, or even treatment failure. Therefore, it is crucial to provide safe prescriptions, avoid adverse recommendations, and ensure treatment outcomes when recommending drug combinations.

[0003] The rapid development of deep learning technology has provided strong support for drug recommendations. However, current drug recommendation methods based on deep learning technology still face many challenges. Specifically, there are deficiencies in patient representation modeling. When modeling historical EHR data, existing methods fail to simultaneously consider the local correlation patterns between various medical data in a single visit and the patient's long-term condition. Second, adverse drug interactions are not fully modeled. Most existing methods use a unified weight distribution method to reduce the DDI rate, ignoring the complex interactions between drugs. They fail to fully consider rich contextual information when modeling complex relationships between drugs, resulting in deficiencies in modeling drug coexistence relationships, potential adverse reactions, and drug sensitivity relationships, affecting the safety of drug recommendations. Third, the interpretability of recommendation results is still low. In clinical applications, doctors often need to understand the basis for the recommendation results when using drug recommendation technology. However, the black-box nature of existing methods leads to a lack of intuitive explanation of the recommendation results. Summary of the Invention

[0004] In order to solve the above problems, the present invention proposes a drug recommendation method and system based on feature fusion and graph construction, which performs local feature extraction and global feature extraction on the diagnosis sequence, surgery sequence and drug sequence respectively, and fuses the local feature extraction and global feature extraction to obtain diagnosis representation, surgery representation and drug representation; by fusing local feature extraction and global feature extraction, the patient's health status can be more comprehensively characterized; according to the electronic health record data set, an electronic health record graph, a drug interaction graph and a drug sensitivity graph are established, and the established electronic health record graph, drug interaction graph and drug sensitivity graph, as well as the preset graph attention network, are used to obtain drug representation. The model simulates the step-by-step medication logic of doctors in prescription decisions, and the generated drug representation of some recommended drugs is fused with the drug representation obtained by feature extraction to obtain a drug similarity score, and fusion with the drug representation obtained by feature extraction is achieved, which can show the weight contribution of different medical events in the recommendation decision, help doctors understand the logic behind the recommendation, and enable the model to have significant result interpretation capabilities.

[0005] In a first aspect, the present invention provides a drug recommendation method based on feature fusion and graph construction, comprising:

[0006] Obtain the patient's diagnosis sequence, surgical sequence, and medication sequence;

[0007] For the diagnosis sequence, surgery sequence, and drug sequence, local feature extraction and global feature extraction are performed respectively, and the local feature extraction and global feature extraction are integrated to obtain the diagnosis representation, surgery representation, and drug representation;

[0008] Based on the electronic health record dataset, an electronic health record graph, a drug interaction graph, and a drug sensitivity graph are established. The established electronic health record graph, drug interaction graph, and drug sensitivity graph, as well as a preset graph attention network, are used to obtain drug representations and fuse them with the drug representations obtained by feature extraction. The electronic health record graph and the drug interaction graph are represented by adjacency matrices, respectively. In the electronic health record graph, the adjacency matrix is ​​1 if and only if two drugs appear in the prescription of the same patient visit, otherwise it is 0; in the drug interaction graph, the adjacency matrix is ​​1 if and only if there is a drug interaction between the two drugs, otherwise it is 0;

[0009] Through encoding technology, a visit similarity score is obtained based on the diagnosis representation and the surgery representation; and a drug similarity score is obtained based on the fused drug representation; the visit similarity score and the drug similarity score are combined to obtain the predicted probability of the drug after considering the patient's historical visit;

[0010] Correct the predicted probability and adjust the drug recommendation probability according to the treatment effect threshold;

[0011] Drug recommendations are made based on the corrected predicted probability.

[0012] Furthermore, when performing local feature extraction and global feature extraction, the patient's diagnosis sequence, surgery sequence, and medication sequence are converted into embedding vectors through linear functions respectively; based on the embedding vectors, a convolutional neural network is used to obtain local features in the sequence, and a Transformer architecture is used to learn long-term dependencies in the sequence to obtain global features; the local features and global features are fused to obtain the patient's diagnostic representation, surgery representation, and medication representation.

[0013] Furthermore, a convolutional neural network is used to obtain local features in the sequence, including: using a one-dimensional convolutional neural network to extract features from the embedded vector to capture the local features in the sequence; after the convolution operation, the extracted features are normalized using the tanh activation function so that the distribution of the output data of each layer is in the same range;

[0014] The Transformer architecture is used to learn long-term dependencies in sequences and obtain global features, including: projecting the embedding vector into multiple embedding subspaces through multi-head self-attention layers, aggregating information from multiple perspectives, capturing global dependencies in medical events, and using a fully connected feedforward network for nonlinear transformation.

[0015] Furthermore, using the established electronic health record graph, drug interaction graph, and drug sensitivity graph, as well as the preset graph attention network, the drug representation is obtained, including: using the graph attention network to learn drug coexistence information and drug sensitivity information in the electronic health record and the introduced drug interaction knowledge, and fusing these two parts of information to obtain the drug representation;

[0016] The multi-head self-attention mechanism is used to learn diverse feature representations in multiple subspaces and obtain multi-angle drug features, as follows:

[0017]

[0018] Among them, LeakyReLU is a nonlinear activation function; a is the projection vector; the symbol || represents the splicing operation; W k is a learnable parameter matrix; the softmax activation function is used to ensure that the sum of all attention scores is 1, is the normalized adjacency matrix; I represents the identity matrix; D represents the degree matrix, which records the degree of each vertex in the graph; D -1 represents the inverse matrix of D; |M| represents the total number of drugs; h j is the characteristic vector of the jth drug; R α Represents the normalized matrix Embedded representation after the graph attention network layer; α∈{e, d, s}; head is the number of attention heads; ELU is the activation function; N i Indicates The neighbor nodes of the jth drug in the EHR graph, DDI graph and DS graph are embedded in R through the above process. e , drug interactions embedded in R d Relationship between drug sensitivity and s , the final drug representation is generated through weighted fusion as follows:

[0019] R g =R e +γR d +βR s ;

[0020] Among them, γ and β are learnable dynamic weight parameters.

[0021] Furthermore, the predicted probability calculation of drugs includes: using the patient's current diagnosis representation and surgery representation as key medical features to match the patient's potential disease; projecting the generated partial drug combination to the corresponding drug semantic representation with the help of the drug embedding table; generating the drug relationship representation of the currently generated drug sequence through the generated drug representation with the support of the drug encoder; combining the drug semantic representation and the drug relationship representation to obtain the complete drug representation M′ t ;

[0022] Use multi-head self-attention mechanism to represent the complete drug M′ t Processing is performed to capture the interactions between generated drugs and optimize feature representation through layer normalization:

[0023] M″ t =LayerNorm(M′ t +Multihead(M′ t , M′ t , M′ t ));

[0024] The patient's current diagnosis and surgery representations are fused with the feature representation optimized through layer normalization to adaptively model uncovered diseases to generate the next medication recommendation. The drug prediction probability is calculated through the multi-layer perceptron layer as follows:

[0025]

[0026] Among them, w g and b g is a learnable parameter; Pr g is the probability of all drugs; for The last line of .

[0027] Furthermore, calculating the final drug recommendation probability includes encoding the patient's diagnosis sequence and surgery sequence as follows:

[0028]

[0029] in, is a learnable parameter, d j ′ is the diagnosis representation of the jth visit, represents the diagnosis code of the diagnosis sequence in the jth visit after the aggregation layer; p j ′ is the surgical representation of the jth visit, represents the surgical code of the surgical sequence in the jth visit after the aggregation layer; the patient visit similarity score is:

[0030]

[0031] in, Represents the similarity score between the jth visit (1≤j≤t-1) and the current tth visit; drug matching similarity score for:

[0032]

[0033]

[0034] Among them, 1≤j≤t-1, m j ′, p represents the pth drug prescribed during the jth visit, for The last row of ; combined with the visit similarity score and drug similarity scores Get the predicted probability of each drug considering the patient's historical visits, that is, the historical similarity score:

[0035]

[0036] Among them, 1{m j,k =m i} in m j,k =m i The value is 1 when the value is 0; otherwise, the value is 0. Represents the probability of the i-th drug being recommended. After merging, we get the final probability of all drugs being recommended considering the patient's history of treatment. Where |M| represents the total number of drugs;

[0037] Combine the drug recommendation probability with the historical similarity score to obtain the final drug recommendation probability:

[0038]

[0039] Pr=w p +w g *Pr g +(1-w g -w p )*Pr c ;

[0040] Among them, W f 、b f and w p are all learnable parameters.

[0041] Furthermore, it also includes constructing a joint loss function: constructing a binary cross entropy loss function Loss BCE Used to measure the accuracy of the model's drug recommendations, as follows:

[0042]

[0043] Among them, τ is a learnable parameter; |M| represents the total number of drugs, M i represents the true label of the i-th drug, which takes the value 1 when the drug is recommended and takes the value 0 when it is not recommended; Pr i Represents the recommendation probability of the i-th drug; constructs the drug interaction loss function Loss DDI To reduce potential adverse interactions in recommended drug combinations, as follows:

[0044]

[0045] Here, the symbol · represents the product between scalars;

[0046] Adopt weighted fusion strategy, combined with binary cross entropy loss function Loss BCE and drug interaction loss function Loss DDI , forming the final joint loss function to balance the recommendation accuracy and medication safety:

[0047] Loss=ρLoss BCE +(1-ρ)Loss DDI ;

[0048] Among them, ρ is the weight hyperparameter.

[0049] Furthermore, error correction of predicted probabilities includes: constructing a causal graph based on electronic medical record data and optimizing the graph structure using a greedy intervention equivalent search algorithm; using causal reasoning methods and the Pearson correlation coefficient to quantify the therapeutic effects of drugs on diseases and surgeries and generate a causal effect matrix; and adjusting the probability of drug recommendation according to the therapeutic effect threshold.

[0050] In a second aspect, the present invention further provides a drug recommendation system based on feature fusion and graph construction, comprising:

[0051] The data acquisition module is configured to: obtain the patient's diagnosis sequence, operation sequence, and medication sequence;

[0052] The feature fusion module is configured to: perform local feature extraction and global feature extraction on the diagnosis sequence, the surgery sequence, and the medication sequence, respectively, and fuse the local feature extraction and the global feature extraction to obtain the diagnosis representation, the surgery representation, and the medication representation;

[0053] The graph construction module is configured to: establish an electronic health record graph, a drug interaction graph, and a drug sensitivity graph based on an electronic health record dataset, utilize the established electronic health record graph, drug interaction graph, and drug sensitivity graph, and a preset graph attention network to obtain drug representations, and fuse them with the drug representations obtained by feature extraction; wherein the electronic health record graph and the drug interaction graph are respectively represented by adjacency matrices; in the electronic health record graph, the adjacency matrix is ​​1 if and only if two drugs appear in the prescription of the same patient visit, otherwise it is 0; in the drug interaction graph, the adjacency matrix is ​​1 if and only if there is a drug interaction between the two drugs, otherwise it is 0;

[0054] The prediction probability determination module is configured to: obtain a diagnosis similarity score based on the diagnosis representation and the surgery representation through encoding technology; and obtain a drug similarity score based on the fused drug representation; and combine the diagnosis similarity score and the drug similarity score to obtain a predicted probability of the drug after considering the patient's historical visits;

[0055] An error correction module is configured to: perform error correction on the predicted probability and adjust the drug recommendation probability according to the treatment effect threshold;

[0056] The recommendation module is configured to make drug recommendations based on the corrected predicted probability.

[0057] In a third aspect, the present invention also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the drug recommendation method based on feature fusion and graph construction described in the first aspect are implemented.

[0058] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the drug recommendation method based on feature fusion and graph construction described in the first aspect.

[0059] Compared with the prior art, the present invention has the following beneficial effects:

[0060] 1. The present invention performs local feature extraction and global feature extraction on the diagnosis sequence, surgery sequence and drug sequence respectively, and fuses the local feature extraction and global feature extraction to obtain diagnosis representation, surgery representation and drug representation; by fusing local feature extraction and global feature extraction, the patient's health status can be more comprehensively characterized; based on the electronic health record data set, an electronic health record map, a drug interaction map and a drug sensitivity map are established, and the established electronic health record map, drug interaction map and drug sensitivity map, as well as the preset graph attention network, are used to obtain drug representation, and are fused with the drug representation obtained by feature extraction, which can show the weight contribution of different medical events in the recommendation decision, help doctors understand the logic behind the recommendation, and enable the model to have significant result interpretation capabilities.

[0061] 2. This invention uses the global feature extraction method Transformer and the multi-head self-attention mechanism in the graph attention network to demonstrate the weight contribution of different medical events in recommendation decisions, and combined with the causal reasoning method in the bias correction module, it can help doctors understand the logic behind the recommendation.

[0062] 3. The present invention analyzes the detailed quantitative causal impact between different entities by utilizing the causal relationship in the causal graph, and then adjusts the corresponding probability of drug recommendation, reducing the bias that may be introduced by co-occurrence relationship and enhancing the interpretability of recommended drugs.

[0063] 4. The present invention constructs an accurate, safe and explainable drug recommendation system. Combining the CAT modules of CNN and Transformer, the local and global features of the patient's medical sequence are integrated to enhance the personalized characterization capability; using GAT to model EHR graphs, DDI graphs and drug sensitivity graphs, the accuracy of drug representation and the safety of recommendations are improved; constructing a bias correction module based on causal reasoning to adjust the probability of drug recommendations, and improve the accuracy and interpretability of drug recommendations; using a joint loss function to optimize the training process to ensure the accuracy of the recommendation results and low interaction risk. At the same time, due to the multi-head attention mechanism in both GAT and Transformer, and the causal reasoning method in the bias correction module, the weight contribution of different medical events in the recommendation decision can be displayed, helping doctors understand the logic behind the recommendation, and enabling the model to have significant result interpretation capabilities. In summary, the present invention has achieved better performance in the drug recommendation task by optimizing patient feature modeling and drug representation, and improving interpretability, and has high value. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] The drawings constituting a part of the specification of this embodiment are used to provide a further understanding of this embodiment. The schematic embodiments and descriptions of this embodiment are used to explain this embodiment and do not constitute an improper limitation on this embodiment.

[0065] Figure 1 This is a schematic diagram of the structure of the drug recommendation system according to Example 1 of the present invention;

[0066] Figure 2 This is a framework diagram of the drug recommendation method according to Example 1 of the present invention;

[0067] Figure 3 This is an architectural diagram of the CAT module of Example 1 of the present invention;

[0068] Figure 4 This is an architectural diagram of the GAT module of Example 1 of the present invention. DETAILED DESCRIPTION

[0069] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0070] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present application belongs.

[0071] Example 1:

[0072] Electronic health records (EHRs) are electronic medical information generated by patients during their medical consultations, covering important data such as diagnostic histories, surgical records, and drug prescriptions. With the continuous development of medical informatization, EHRs have shown great potential in assisting clinical decision-making and improving the quality of medical services. Thanks to the growing amount of EHR data, drug recommendation technology plays a vital role in promoting personalized medicine and improving patient health outcomes. Drug recommendation systems can deeply analyze and mine patient health data, simulating doctors' thinking and diagnostic reasoning to assist clinical decision-making, helping doctors formulate safe and effective drug prescriptions based on patients' changing health conditions, and comprehensively improving medical treatment outcomes and the quality of medical services.

[0073] The rapid development of deep learning technology has provided strong support for drug recommendations. Models such as convolutional neural networks (CNNs), recurrent neural networks (RNNs), and long short-term memory networks (LSTMs) have been widely used in drug recommendation tasks, effectively improving the ability to learn features from patient EHR data. However, these models still have certain limitations. For example, CNNs are limited in their ability to capture long-term dependencies; RNNs are prone to the vanishing gradient problem when processing long sequences of data; and while Transformers have global modeling capabilities, they lack local feature extraction. Therefore, research has gradually shifted to multi-model fusion strategies, such as combining LSTMs with attention mechanisms to optimize medical data computation; combining bidirectional long short-term memory networks (BiLSTMs) with attention mechanisms to capture long-term dependencies in patient medical records; and combining gated recurrent units (GRUs) with attention mechanisms to distinguish the importance levels of medical events. Furthermore, graph neural networks (GNNs), due to their excellent performance in learning drug representations, are widely used to model electronic health record (EHR) graphs and drug-drug interaction (DDI) graphs. However, traditional graph convolutional neural networks (GCNs) assign equal weights to all edges when learning drug interactions, limiting the model's ability to capture complex relationships. To address this issue, lightweight graph convolutional neural networks (LGCNs) and relational graph convolutional neural networks (R-GCNs) have improved model performance to some extent, but interpretability remains a challenge.

[0074] In the task of drug recommendation, accurately recommending appropriate medications is a challenging prescription decision-making task, especially for patients suffering from multiple diseases. As can be seen from the above, in the task of drug recommendation, existing technologies have the following problems: Insufficient personalization of patient representation: As patients visit the doctor multiple times, different symptoms show different correlations and importance in historical medical events and EHR sequence data; however, when processing multiple patient visit records, existing methods usually assign the same weight to longitudinal medical records, ignoring the differential impact of different visit events on the patient's health status. This leads to a lack of personalization in learning patient representations, thereby reducing the accuracy of patient representations. Limited safety of drug recommendations: When modeling EHR graphs and DDI graphs, existing methods usually adopt a uniform attention allocation strategy, failing to fully explore drug features with rich contextual information, resulting in deficiencies in modeling drug co-existence relationships, potential adverse reactions, and drug sensitivity relationships, affecting the safety of drug recommendations. Existing deep learning models lack transparency in drug recommendation tasks, making it difficult to clearly explain the basis for drug recommendations, affecting their application value in clinical decision-making.

[0075] like Figure 1 As shown, this embodiment provides a drug recommendation method based on feature fusion and graph construction. First, the CAT module of CNN and Transformer is combined to capture the medical sequence features in the patient's EHR. Among them, CNN is mainly used to extract local correlation relationships in medical sequences, while Transformer effectively models the long-term dependencies between medical sequences. By combining the advantages of the two, an accurate patient representation is constructed to ensure that the information in the patient's medical sequence is fully considered; secondly, the attention mechanism in the graph attention network (GAT) can adaptively assign weights according to the importance of different neighbor nodes, thereby more accurately capturing the complex node relationships in the EHR graph, DDI graph and DS graph, thereby optimizing drug representation and improving the safety of drug recommendations. GAT models EHR graph, DDI graph and DS graph to learn the co-occurrence relationship, interaction relationship and drug sensitivity information between drugs, thereby obtaining drug representation. On this basis, the model simulates the doctor's step-by-step medication logic in prescription decision-making, and dynamically generates safe and accurate drug combinations in an iterative manner.

[0076] During the model training process, a bias correction module based on causal reasoning and a loss function combination are introduced, as well as a loss function combination (including weighted binary cross entropy loss function and DDI loss function) to optimize model training, in order to further improve prediction accuracy and effectively reduce adverse drug interactions in recommended drug combinations. In addition, with the help of the multi-head self-attention mechanism in Transformer and GAT and the causal reasoning method in the bias correction module, the model's ability to distinguish between different medical events and drug relationships is enhanced, and the interpretability of the recommendation results is improved. Experimental results show that this drug recommendation method effectively reduces the drug interaction rate while improving the recommendation accuracy, and can provide patients with more accurate and safe personalized drug combinations, providing strong support for clinical decision-making.

[0077] Different deep learning models show their respective advantages in the task of modeling patient visit data. CNN is mainly used to process local relationships. When modeling medical events in a patient's single visit sequence, it can capture the local correlation between medical events through convolution operations, effectively improve the ability to extract local features, and enhance the model's attention to local information; while Transformer, when modeling longitudinal EHR data, can use the self-attention mechanism to capture the long-term dependencies between patient visit sequences, integrate historical health status with current condition, model from a global perspective, and enhance the model's attention to global information. The attention mechanism in the graph attention network (GAT) can adaptively assign weights according to the importance of different neighbor nodes, thereby more accurately capturing the complex node relationships in the EHR graph and DDI graph, thereby optimizing drug representation and improving the safety of drug recommendations. The drug recommendation method in this embodiment includes the following steps:

[0078] S1. Obtain electronic health record data and preprocess it:

[0079] Based on the existing patient electronic health record dataset, the patient's diagnostic data, surgical data, and drug data are integrated and preprocessed to construct the dataset required for model training. The patient's electronic health record is represented as EHR = {v1, v2, ..., v t}, where t is the number of visits of the patient; the tth visit of the patient is represented by v t ={d t , p t , m t}, d t represents the diagnosis sequence of the patient’s t-th visit, p t represents the surgical sequence of the tth visit in the patient's medical record, m t represents the drug sequence of the patient at the tth visit.

[0080] S2. Construct a patient representation learning module (CAT module) that combines CNN and Transformer: Use three CAT modules to learn the patient's diagnosis, surgery, and medication sequences respectively to obtain the patient's diagnosis representation, surgery representation, and medication representation; the CAT module consists of CNN and Transformer, which are used to learn the patient's local features and global features respectively.

[0081] S3. Use a Graph Attention Network (GAT) to model the EHR graph, DDI graph, and drug sensitivity graph (DS graph) to obtain drug representations. Optionally, an EHR graph, drug interaction graph, and drug sensitivity graph are constructed based on the EHR dataset and external knowledge. The external knowledge refers to the TWOSIDES dataset. Specifically, the top 40 severe DDIs from this dataset are selected as a criterion for generating the DDI adjacency matrix. That is, the DDI adjacency matrix contains only the top 40 adverse DDI reactions in this dataset. If a drug has one of these 40 adverse reactions, the corresponding position is 1.

[0082] S4. Calculate the probability of drug recommendation: The drug recommendation probability is calculated considering only the patient's current health status and the generated drug sequence; then, by calculating the medical consultation similarity score and the drug similarity score, the historical similarity score is obtained, and the drug recommendation probability is generated in combination with the above-generated drug recommendation probability to calculate the final drug recommendation probability.

[0083] S5. Construct an error correction module based on causal reasoning:

[0084] First, a causal graph is constructed based on electronic medical record data, and the graph structure is optimized using the GIES algorithm. Next, causal inference methods and the Pearson correlation coefficient are used to quantify the therapeutic effects of drugs on diseases and surgeries, generating a causal effect matrix. Finally, the probability of drug recommendations is adjusted based on the therapeutic effect threshold, improving the accuracy and interpretability of the recommendations.

[0085] S6. Construct a joint loss function to optimize the model training process:

[0086] Construct a joint loss function to optimize the model training process: construct a binary cross-entropy loss function and a drug-drug interaction (DDI) loss function to balance recommendation accuracy and safety, and achieve accurate and safe drug recommendations.

[0087] Optionally, step S1 includes:

[0088] Download the publicly available MIMIC-III medical dataset from the internet, or obtain other legal datasets. Use this dataset as the raw EHR data for drug recommendations. Extract patient diagnostic sequences, surgical procedures, and medication sequences from this dataset to construct the dataset required for model training. Specifically, focus on processing the core data files closely related to the drug recommendation task, including the following three files: DIAGNOSES_ICD.csv, PROCEDURES_ICD.csv, and PRESCRIPTIONS.csv.

[0089] During the data fusion process, the above files are integrated based on the patient's visit ID and patient ID (Subject ID) to construct a structured patient visit dataset to support the training and analysis of the drug recommendation model. To improve the model's training efficiency and predictive performance, this example screened patients with at least two visit records and retained approximately 300 of the most commonly used medications to improve training efficiency and facilitate analysis. In addition, the NDC code for each drug was converted to its corresponding ATC-4 code to standardize the drug labels.

[0090] Through the above data preprocessing steps, not only a complete medical sequence dataset was constructed, but also the standardization and structuring of the input data were ensured, laying a solid data foundation for subsequent patient representation learning and personalized drug recommendations.

[0091] Optionally, step S2 constructs a patient representation learning module (CAT module) that combines CNN and Transformer.

[0092] In the drug recommendation task, when processing multiple medical records of patients, if the local correlation patterns in the patient's medical sequence and the long-term dependencies between each sequence are not learned, the learning of the patient representation will deviate from the patient's actual health status. This will affect the ultimate accuracy of the drug recommendation system. This embodiment uses the CAT module that integrates CNN and Transformer to model patient representation. This method can combine local features in medical sequences and global dependencies between medical sequences. This process includes 4 steps: medical sequence embedding, CNN capturing local features, Transformer capturing long-term dependencies, and feature fusion. That is, step S2, such as Figure 3 As shown, specifically including:

[0093] S21, three embedded tables E d ∈R |d|×dim , E p ∈R |p|×dim , aE m ∈R |m|×dim, where |d|, |p|, |m| represent the lengths of the diagnosis sequence, surgery sequence, and drug sequence respectively; dim represents the embedding dimension, which is set to 64; the three medical sequences d in the patient's electronic health record are respectively transformed into t , p t , m t Convert to embedding vector The details are as follows:

[0094]

[0095] Among them, v∈{d, p, m}, i represents the patient’s i-th visit sequence;

[0096] S22, the output result in step S21 As input, the CNN model is used to capture the local features in the sequence, and the output is

[0097] S23, the output result in step S21 As input, the Transformer architecture is used to learn the long-term dependencies in the EHR time series, obtain global features, and output is

[0098] S24, fusing the local features and global feature representations in steps S22 and S23 to generate patient diagnosis, surgery, and drug representations d′ t , p′ t , m′ t , as follows:

[0099]

[0100] Among them, v∈{d, p, m}, is the local feature representation, It is a global feature representation.

[0101] In some embodiments, optionally, a CNN model is used to capture local features in the sequence, including: a one-dimensional convolutional neural network (1D-CNN) and a tanh activation function to extract features;

[0102] Use 1D-CNN with a convolution kernel size of 3 and a stride of 1 to extract features from the embedded vector and capture the local features present in the sequence, as follows:

[0103]

[0104] Where v∈{d, p, m}, i represents the patient’s i-th visit, and the symbol “·” represents the convolution operator, which means multiplying the elements at corresponding positions in the two matrices. Represents the learnable parameter matrix, CNN v Represents the features extracted by 1D-CNN;

[0105] After the convolution operation, the tanh activation function is used to standardize the extracted features so that the distribution of the output data of each layer is in a roughly similar range to accelerate the convergence of the model. The details are as follows:

[0106]

[0107] Among them, B v The bias term is a learnable parameter. During model training, the learnable parameter is optimized to ensure that the output has local correlation information.

[0108] In some embodiments, a Transformer architecture is used to learn long-term dependencies in EHR time series, including multi-head self-attention layers, feedforward neural networks, residual connections, and layer normalization;

[0109] Through the multi-head self-attention layer, the input embedding vector is projected into multiple embedding subspaces, and then the information from multiple perspectives is aggregated to more comprehensively capture the global dependencies in medical events, as follows:

[0110]

[0111] Multihead(Q,K,V)=concat(head1,head2,...,head h )W O (7)

[0112] Among them, Q, K, V represent the query matrix, key matrix and value matrix respectively, which are the embedding vectors of the input Learning about the correlations between dim indicates that the model dimension is set to 64, and h indicates the number of attention heads, which is set to 8; W O These are parameters that the model can learn during the learning process;

[0113] Next, FFN is used for nonlinear transformation to improve the model's ability to express complex relationships. FFN consists of two linear transformation layers and a ReLU activation function, as follows:

[0114] H=LayerNorm(v t +Multihead(vt , v t , v t )) (8)

[0115]

[0116] Among them, v∈{d, p, m}, are all learnable parameters;

[0117] Finally, residual connections are used to improve model performance and accelerate training convergence; layer normalization is used to enhance the stability and robustness of the model, as follows:

[0118]

[0119] Among them, v∈{d, p, m}, during the model training process, the optimization of learnable parameters is used to make the output have global features.

[0120] In step S3, the Graph Attention Network (GAT) is used to model the EHR graph, DDI graph, and DS graph to obtain drug representation.

[0121] In the drug recommendation task, when learning drug representation, if a uniform attention allocation strategy is adopted, the drug features with rich contextual information cannot be fully mined, resulting in deficiencies in modeling drug coexistence relationships and potential adverse reactions, affecting the safety of drug recommendations. This embodiment uses the GAT model to model the EHR graph and DDI graph, and uses the attention mechanism to assign different weights to accurately learn the coexistence relationship and interaction relationship of drugs. This process includes two parts: learning the drug coexistence information in the electronic health record (stored in the EHR graph G e ), drug sensitivity information (stored in DS G s ) and the introduced drug interaction knowledge (stored in DDI graph G d ). That is, step S3, the framework of the GAT model is as follows Figure 4 As shown, specifically including:

[0122] GAT is used to model EHR graph, DDI graph and drug sensitivity graph (DS graph) to obtain drug representation, including: using GAT to learn drug co-occurrence information in electronic health records (stored in EHR graph G e ), drug sensitivity information of adverse reactions in some patients caused by drug sharing (stored in DS Figure G s ) and the introduced drug interaction knowledge (stored in DDI graph G d ) and integrate these three parts of information to obtain drug representation.

[0123] EHR Figure G eAvailable adjacency matrix A e ∈R |M|×|M| Denotes |M|, the total number of all drugs, where A is present if and only if drug i and drug j appear together in the prescription of the same patient visit. e [i, j] is 1, otherwise it is 0; DDI graph G d Available adjacency matrix A d ∈R |M|×|M| Represents A if and only if there is a drug interaction between drug i and drug j. d [i, j] is 1, otherwise it is 0; DS graph G s Available adjacency matrix A s ∈R |M|×|M| Represents, where a is the number of times drug i and drug j appear in the patient's health record at the same time and cause adverse reactions. s [i,j] is 1, otherwise it is 0.

[0124] The multi-head self-attention mechanism is used to learn diverse feature representations in multiple subspaces and obtain multi-angle drug features, as follows:

[0125]

[0126] Among them, LeakyReLU is a nonlinear activation function; a is the projection vector; the symbol || represents the splicing operation; W k is a learnable parameter matrix; the softmax activation function is used to ensure that the sum of all attention scores is 1, is the normalized adjacency matrix; I represents the identity matrix; D represents the degree matrix, which records the degree of each vertex in the graph; D -1 represents the inverse matrix of D; |M| represents the total number of drugs; h j is the characteristic vector of the jth drug; R α Represents the normalized matrix Embedded representation after the graph attention network layer; head is the number of attention heads; ELU is the activation function; N i Indicates The neighbor nodes of the j-th drug;

[0127] The EHR graph, DDI graph, and DS graph are embedded with the drug co-occurrence relationship R through the above process. e , drug interactions embedded in R d Relationship between drug sensitivity and s , the final drug representation is generated by weighted fusion as follows:

[0128] R g =R e +γR d +βRs ; (16)

[0129] γ and β are learnable dynamic weight parameters. During the learning process, we strive to minimize adverse drug interactions and mutually sensitive drug interactions. Consequently, γ and β are learned as negative values ​​within the range [-1, 0]. By optimizing γ and β, we ensure that the generated drug representations account for drug co-occurrence relationships, drug interactions, and drug sensitivity, improving the personalization, safety, and accuracy of prescription recommendations.

[0130] In step S4, the drug recommendation probability calculated by considering only the patient's current health condition and the generated drug sequence is as follows:

[0131] S41. Generate a drug relationship representation based on the patient's current health status and the drug encoder:

[0132] Use the patient's current diagnosis to represent d' t and the operation represents p′ t As key medical features to match the patient's underlying disease; some drug combinations have been generated Subsequently, with the help of drugs embedded in Table E m ∈R |m|×dim , the generated partial drug combination Projection to the corresponding drug semantic representation With the support of the drug encoder, the drug representation R generated in step S3 is used. g Generate drug relationship representation of the currently generated drug sequence Finally, by combining and Get the complete drug representation M′ t , providing a basis for subsequent drug recommendation predictions:

[0133] S42, using a multi-head self-attention mechanism to represent the drug M' generated in step S41 t Processing is performed to capture the interactions between generated drugs, enhance the model's understanding of drug relationships, and optimize feature representation through layer normalization, as follows:

[0134] M″ t =LayerNorm(M′ t +Multihead(M′ t , M′ t , M′ t )) (17)

[0135] S43, using multi-head self-attention layer and layer normalization to adaptively model undiscovered diseases for the next step of drug generation. Specifically, the patient’s current health status (diagnosis and surgery denoted d′) is t and p′ t ) and the drug representation M in step S42 t The fusion is performed so that the uncovered diseases can be adaptively modeled based on the patient’s current physical condition to generate the next medication recommendation and calculate the drug prediction probability through the multi-layer perceptron (MLP) layer as follows:

[0136]

[0137] Among them, w g and b g is a learnable parameter. g is the probability of all drugs; for The last line of .

[0138] In some embodiments, a historical similarity score is obtained by calculating a medical consultation similarity score and a drug similarity score, and combined with the above-generated drug recommendation probability to calculate a final drug recommendation probability, including: calculating the patient's diagnosis, surgery, and drug similarity scores and fusing the diagnosis, surgery, and drug similarity scores to obtain a historical similarity score and calculating the final drug recommendation probability;

[0139] S44. Encode the patient's diagnosis and surgery sequence using a linear function and tanh and softmax activation functions as aggregation layers, as follows:

[0140]

[0141] in, is a learnable parameter, d j ′ is the diagnosis representation of the jth visit, represents the diagnosis code of the diagnosis sequence in the jth visit after the aggregation layer; p j ′ is the surgical representation of the jth visit, represents the surgical code of the surgical sequence in the jth visit after the aggregation layer;

[0142] S45. Combine the diagnosis code and the surgery code after the aggregation layer in step S44 to obtain the patient visit similarity score, which is as follows:

[0143]

[0144] in, represents the similarity score between the j-th visit (1≤j≤t-1) and the current t-th visit;

[0145] S46. In order to obtain the historical medical records that best match the current prescription, a drug matching similarity score needs to be calculated. in, The calculation is as follows:

[0146]

[0147] Among them, 1≤j≤t-1, m j ′, p represents the pth drug prescribed during the jth visit, Generated for S43 The last line of;

[0148] S47, combined with the medical similarity score and drug similarity scores The predicted probability of each drug after considering the patient's historical visits, that is, the historical similarity score, is obtained as follows:

[0149]

[0150] Among them, 1{m j,k =m i} in m j,k =m i The value is 1 when , otherwise the value is 0. Represents the probability of the i-th drug being recommended. After merging, we get the final probability of all drugs being recommended considering the patient's history of treatment. Where |M| represents the total number of drugs.

[0151] The drug recommendation probability calculated in step S43 is combined with the historical similarity score. In order to learn that some drugs are recommended in advance for "preventive purposes", a relevant bias term is added when calculating the final drug recommendation probability, as follows:

[0152]

[0153] Pr=w p +w g *Pr g +(1-w g -w p )*Pr c (28)

[0154] Among them, W f , b f , w p are all learnable parameters, w pAs the above-mentioned bias item, it can enable the model to recommend targeted drugs for "future disease prevention and control".

[0155] S5. Construct an error correction module based on causal reasoning, as follows:

[0156] S51. Based on the data distribution U in the electronic medical record, set the equivalence score standard S(G,U) as the scoring standard in the Bayesian equivalence class to evaluate the quality of each causal graph G learned from the data U, as follows:

[0157]

[0158] Among them, n represents the total number of variables, X i represents variables including diagnosis, surgery, and medication, Represents the variable X in graph G i The parent variable of X directly affects the structure of the Bayesian network. i The variable set of

[0159] S52. In the causal discovery module, the Greedy Intervention Equivalence Search (GIES) algorithm is used to optimize and obtain an optimized causal graph G′ from the initial causal graph G generated in S51 and the scoring criteria S(), as follows:

[0160] G′=GIES(S,G) (30)

[0161] Among them, GIES() optimizes and learns from the initial graph G and the equivalent score S to obtain the optimized graph G′;

[0162] S53. Use causal inference to analyze the therapeutic effects of drugs on the diseases and surgeries listed in this report. First, treat graph G′ as a binary variable, where diagnosis and surgery are defined as treatment variables, and drug is defined as the outcome variable. Use the Pearson correlation coefficient method to quantify the therapeutic effects of drugs on diseases and surgeries, reveal their co-occurrence frequency in patients' electronic health records, and identify potential associations, as follows:

[0163]

[0164] Among them, r i,j is the Pearson correlation coefficient between variables x and y, n is the number of samples, ∑xy is the sum of the products of the corresponding sample values ​​of x and y, ∑x and ∑y are the sums of all sample values ​​of x and y respectively, ∑x 2 and ∑y 2 are the sum of the squares of all sample values ​​of x and y respectively; finally, the calculated quantitative relationship of each diagnosis, surgery and each drug is constructed into the corresponding causal effect matrix M dm and M pm .

[0165] S54, drug M whose therapeutic effect on a specific disease or surgery is higher than the preset threshold δ1 i , increasing its recommendation probability; conversely, the drug M whose therapeutic effect on a specific disease or surgery is higher than the preset threshold δ2 i , then reduce its recommendation probability, as follows:

[0166]

[0167] Among them, M i represents the i-th drug, and Represented in the causal effect matrix M dm and M pm The therapeutic effect of the i-th drug on the current diagnosis and surgery, σ1 and σ2 represent the variable amplitude of the probability adjustment. δ1 and δ2 are pre-set quantitative effect thresholds, where δ1 represents the upper threshold of the expected effect and δ2 is the lower threshold. i The recommendation probability of drug i is adjusted by this method. Although causal graphs are used in traditional models, the interpretability of the models has not been deeply explored. In the model of this embodiment, the causal relationships in the causal graph are used to analyze the detailed quantitative causal influences between different entities, and then the corresponding probabilities of drug recommendations are adjusted. This aims to reduce the bias that may be introduced by co-occurrence relationships and enhance the interpretability of recommended drugs.

[0168] In this embodiment, the joint loss function optimization model training process is constructed in step S6, which is specifically as follows:

[0169] S61. Construct weighted binary cross entropy loss function Loss BCE Used to measure the accuracy of the model's drug recommendations, as follows:

[0170]

[0171] Among them, in most models, the ordinary binary cross entropy loss function is usually chosen to be used. However, in the task of drug recommendation, the recommended drugs are far less than the non-recommended drugs, which may make the model prone to "predicting as negative class" to reduce the overall loss. Therefore, the weighted binary cross entropy loss function is chosen to avoid this situation. τ is a learnable parameter. The larger τ is, the more likely the model is to find more positive samples, allowing the model to find the optimal τ value during the learning process; |M| represents the total number of drugs, M i Pr represents the true label of the i-th drug, which takes the value 1 when the drug is recommended and takes the value 0 when it is not recommended. i represents the recommendation probability of the i-th drug;

[0172] S62. Construct DDI loss function Loss DDI To reduce potential adverse interactions in recommended drug combinations, as follows:

[0173]

[0174] Here, the symbol · represents the product between scalars;

[0175] S63, using weighted fusion strategy, combined with weighted binary cross entropy loss function Loss BCE And DDI loss function Loss DDI , forming the final joint loss function to balance the recommendation accuracy and medication safety, as follows:

[0176] Loss=ρLoss BCE +(1-ρ)Loss DDI (35)

[0177] Among them, ρ is the weight hyperparameter (value range: 0≤ρ≤1).

[0178] In summary, this embodiment first combines CNN and Transformer models to fully capture the relationship between various medical events in the patient's EHR data, thereby generating a comprehensive patient representation; then, the GAT model is introduced to learn the coexistence relationship, interaction relationship, and drug sensitivity relationship of drugs to achieve a complete drug representation; finally, the model simulates the doctor's step-by-step medication logic in decision-making to generate the final drug recommendation results. During the training process, a bias correction module based on causal reasoning and a joint loss function optimization model including a weighted binary cross entropy loss function and a DDI loss function are used to reduce potential fatal DDIs and improve the accuracy, safety, and interpretability of the drug recommendation task. The experimental results based on the real dataset MIMIC-III show that the present invention has achieved good results in terms of accuracy, safety, and interpretability of drug recommendations.

[0179] like Figure 1 As shown, this embodiment also provides a drug recommendation system based on CNN and Transformer, including: a data processing module, a CAT module, a GAT module and a GAT module; specifically:

[0180] The data processing module is responsible for acquiring EHR data and performing preprocessing to generate data sequences for model training.

[0181] The CAT module is used to learn patient representations. Specifically, the three medical sequences of diagnosis, surgery, and medication in the patient's electronic health record are first converted into embedding vectors and used as inputs to the CNN and Transformer architectures. Subsequently, the CNN model is used to extract local features in the medical sequences and the extracted features are normalized through activation functions to obtain local patterns in the sequences. At the same time, the Transformer architecture is used to capture long-term dependencies in the sequences and extract global features between medical sequences. Finally, the patient representation is generated by fusing local and global features.

[0182] The GAT module is used to model EHR graphs, DDI graphs, and DS graphs, learn the coexistence relationship, interaction relationship, and drug sensitivity information of drugs, and thus generate more expressive drug representations.

[0183] The output module calculates the probability of drug recommendation and ultimately presents the recommendation result. First, the drug recommendation probability is calculated based only on the patient's current health status and the generated drug sequence. Then, the historical similarity score is obtained by calculating the visit similarity score and the drug similarity score. This is combined with the generated drug recommendation probability to calculate the final drug recommendation probability. Simultaneously, a causal graph is constructed based on the electronic medical record data, and the graph structure is optimized using the GIES algorithm. Next, causal inference methods are used to analyze the therapeutic effects of drugs on the diseases and surgeries listed in this report, generating a causal effect matrix. Finally, the drug recommendation probability is adjusted based on the treatment effect threshold to obtain the final drug recommendation probability.

[0184] To verify the effectiveness of the method in this embodiment, experiments were conducted on the MIMIC-III public dataset. To measure the accuracy of recommendations, this embodiment uses the Jaccard similarity coefficient (i.e., the size of the intersection of the real drug and the recommended drug divided by the size of the union), the average F1 value (i.e., the harmonic mean of the precision and recall rate), and the precision-recall curve (PRAUC) as indicators for measuring accuracy; and the drug-drug interaction rate (DDI rate), i.e., the ratio of DDI drugs in the recommended combination drugs, as an indicator for measuring safety.

[0185] Table 1 Model comparison experiment

[0186]

[0187] Experiments show that the model in this embodiment achieves better results than existing models. The comparison of experimental results is shown in Table 1. Among them, this embodiment is compared with seven models. LR is an instance-based classifier equipped with L2 regularization to prevent model overfitting, and is often used to solve binary or multi-classification problems; ECC encodes the patient's diagnosis and treatment process into a multi-hot vector and models the correlation between labels through a series of classifiers. DMNC is a drug combination prediction model based on a deep neural network with enhanced memory; RETAIN is a longitudinal prediction mechanism that combines the reverse temporal attention mechanism with RNN to capture the sequence characteristics in time series data. The interpretation of the prediction results is improved by introducing attention and gating mechanisms; LEAP is a generative model based on an LSTM network that uses continuous diagnostic information to recommend drugs; GAMENet combines a neural network with enhanced memory and a GNN to recommend safe drug combinations based on the patient's historical medical records; COGNet is an innovative drug recommendation model that uses repetition and prediction mechanisms to generate recommended drugs through historical prescriptions or predicted combinations of current medical records.

[0188] Table 2 Ablation experiment

[0189]

[0190]

[0191] Experiments show the effectiveness of the CAT module, GAT module, and loss function combination in this embodiment. The comparison of experimental results is shown in Table 2. Among them, C-PASMR removes the Transformer architecture in the CAT module and retains only CNN to learn patient representation; T-PASMR removes the CNN part in the CAT module and retains only the Transformer architecture to learn patient representation; GCN-CT-PASMR uses traditional GCN to learn EHR graphs and DDI graphs to obtain drug representation; LDDI-CT-PASMR only introduces the DDI loss function in the model training and drug recommendation process; LBCE-CT-PASMR only uses the weighted binary cross entropy loss function in the model training and drug recommendation process.

[0192] In some embodiments, as Figure 2 As shown, in this embodiment, the CNN in the CAT module is first used to extract local features in the medical sequence. And use Transformer to extract long-term dependencies between medical sequences After the two are fused, the patient representation d′, p′, m′ is generated to ensure that the information in the patient's medical sequence is fully utilized. Subsequently, the GAT model is used to model the EHR graph, DDI graph, and DS graph to learn the drug relationship and obtain the drug representation R g , thereby effectively avoiding potential adverse drug reactions and improving drug safety. In the drug recommendation process, the system calculates the drug recommendation probability Pr based on the patient's current health status and the generated drug combination. g , and calculate the historical similarity score Pr by combining historical medical data c , and finally the two are integrated to determine the drug recommendation probability Pr, thereby generating an accurate personalized medication plan. In addition, by constructing a bias correction module based on causal reasoning to adjust the drug recommendation probability to obtain the final drug recommendation probability Pr′, and by constructing a joint loss function of the weighted binary cross entropy loss function and the DDI loss function, the model training process is optimized to improve the accuracy and security of the recommendation results. At the same time, the multi-head self-attention mechanism in the Transformer and GAT models and the causal reasoning method in the bias correction module further enhance the interpretability of the model and make the recommendation results more transparent. The experimental results show that the method proposed in the present invention performs excellently on the medical dataset MIMIC-III, significantly improving the accuracy and safety, security and interpretability of drug recommendations, and fully verifying the effectiveness and practical value of the method and each module of the system of the present invention.

[0193] Example 2:

[0194] This embodiment provides a drug recommendation system based on feature fusion and graph construction, including:

[0195] The data acquisition module is configured to: obtain the patient's diagnosis sequence, operation sequence, and medication sequence;

[0196] The feature fusion module is configured to: perform local feature extraction and global feature extraction on the diagnosis sequence, the surgery sequence, and the medication sequence, respectively, and fuse the local feature extraction and the global feature extraction to obtain the diagnosis representation, the surgery representation, and the medication representation;

[0197] The graph construction module is configured to: establish an electronic health record graph, a drug interaction graph, and a drug sensitivity graph based on an electronic health record dataset, utilize the established electronic health record graph, drug interaction graph, and drug sensitivity graph, and a preset graph attention network to obtain drug representations, and fuse them with the drug representations obtained by feature extraction; wherein the electronic health record graph and the drug interaction graph are respectively represented by adjacency matrices; in the electronic health record graph, the adjacency matrix is ​​1 if and only if two drugs appear in the prescription of the same patient visit, otherwise it is 0; in the drug interaction graph, the adjacency matrix is ​​1 if and only if there is a drug interaction between the two drugs, otherwise it is 0;

[0198] The prediction probability determination module is configured to: obtain a diagnosis similarity score based on the diagnosis representation and the surgery representation through encoding technology; and obtain a drug similarity score based on the fused drug representation; and combine the diagnosis similarity score and the drug similarity score to obtain a predicted probability of the drug after considering the patient's historical visits;

[0199] An error correction module is configured to: perform error correction on the predicted probability and adjust the drug recommendation probability according to the treatment effect threshold;

[0200] The recommendation module is configured to make drug recommendations based on the corrected predicted probability.

[0201] The working method of the system is the same as the drug recommendation method based on feature fusion and graph construction in Example 1, and will not be repeated here.

[0202] Example 3:

[0203] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the drug recommendation method based on feature fusion and graph construction described in Example 1 are implemented.

[0204] Example 4:

[0205] This embodiment provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the steps of the drug recommendation method based on feature fusion and graph construction described in Example 1 are implemented.

[0206] The above description is merely a preferred embodiment of this embodiment and is not intended to limit this embodiment. Those skilled in the art will readily appreciate that this embodiment may be modified and varied in various ways. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of this embodiment shall be within the scope of protection of this embodiment.

Claims

1. A drug recommendation method based on feature fusion and graph construction, characterized in that: include: Obtain the patient's diagnosis sequence, surgical sequence, and medication sequence; For the diagnosis sequence, surgery sequence, and drug sequence, local feature extraction and global feature extraction are performed respectively, and the local feature extraction and global feature extraction are integrated to obtain the diagnosis representation, surgery representation, and drug representation; Based on the electronic health record dataset, an electronic health record graph, a drug interaction graph, and a drug sensitivity graph are established. The established electronic health record graph, drug interaction graph, and drug sensitivity graph, as well as a preset graph attention network, are used to obtain drug representations and fuse them with the drug representations obtained by feature extraction. The electronic health record graph and the drug interaction graph are represented by adjacency matrices, respectively. In the electronic health record graph, the adjacency matrix is ​​1 if and only if two drugs appear in the prescription of the same patient visit, otherwise it is 0; in the drug interaction graph, the adjacency matrix is ​​1 if and only if there is a drug interaction between the two drugs, otherwise it is 0; Through encoding technology, the diagnosis similarity score is obtained based on the diagnosis representation and the operation representation; and the drug similarity score is obtained based on the fused drug representation; the predicted probability of the drug after considering the patient's historical visits is obtained by combining the diagnosis similarity score and the drug similarity score; Correct the predicted probability and adjust the drug recommendation probability according to the treatment effect threshold; Drug recommendations are made based on the corrected predicted probability.

2. The drug recommendation method based on feature fusion and graph construction according to claim 1, characterized in that: When performing local and global feature extraction, the patient's diagnosis sequence, surgery sequence, and medication sequence are converted into embedding vectors through linear functions. Based on the embedding vectors, a convolutional neural network is used to obtain local features in the sequence, and a Transformer architecture is used to learn long-term dependencies in the sequence to obtain global features. The local features and global features are fused to obtain the patient's diagnostic representation, surgery representation, and medication representation.

3. The drug recommendation method based on feature fusion and graph construction according to claim 2, characterized in that: Using a convolutional neural network to obtain local features in the sequence includes: using a one-dimensional convolutional neural network to extract features from the embedded vector to capture the local features in the sequence; after the convolution operation, using the tanh activation function to normalize the extracted features so that the distribution of the output data of each layer is in the same range; The Transformer architecture is used to learn long-term dependencies in sequences and obtain global features, including: projecting the embedding vector into multiple embedding subspaces through multi-head self-attention layers, aggregating information from multiple perspectives, capturing global dependencies in medical events, and using a fully connected feedforward network for nonlinear transformation.

4. The drug recommendation method based on feature fusion and graph construction according to claim 1, characterized in that: Using the established electronic health record graph, drug interaction graph, and drug sensitivity graph, as well as the preset graph attention network, the drug representation is obtained, including: using the graph attention network to learn the drug coexistence information in the electronic health record and the introduced drug interaction knowledge, and fusing these two parts of information to obtain the drug representation; The multi-head self-attention mechanism is used to learn diverse feature representations in multiple subspaces and obtain multi-angle drug features, as follows: Among them, LeakyReLU is a nonlinear activation function; a is the projection vector; the symbol || represents the splicing operation; W k is a learnable parameter matrix; the softmax activation function is used to ensure that the sum of all attention scores is 1, is the normalized adjacency matrix; I represents the identity matrix; D represents the degree matrix, which records the degree of each vertex in the graph; D -1 represents the inverse matrix of D; |M| represents the total number of drugs; h j is the characteristic vector of the jth drug; R α Represents the normalized matrix Embedded representation after the graph attention network layer; head is the number of attention heads; ELU is the activation function; N i Indicates The neighbor nodes of the j-th drug; The electronic health record map, drug interaction map and drug sensitivity map are respectively obtained by obtaining drug co-occurrence relationship embedding, drug interaction embedding R d Relationship between drug sensitivity and s , the final drug representation is generated through weighted fusion as follows: R g =R e +γR d +βR s ; Among them, γ and β are learnable dynamic weight parameters.

5. The drug recommendation method based on feature fusion and graph construction according to claim 4, characterized in that: The calculation of the predicted probability of drugs includes: using the patient's current diagnosis representation and surgery representation as key medical features to match the patient's potential disease; projecting the generated partial drug combination to the corresponding drug semantic representation with the help of the drug embedding table; generating the drug relationship representation of the currently generated drug sequence through the generated drug representation with the support of the drug encoder; combining the drug semantic representation and the drug relationship representation to obtain the complete drug representation M ′ t ; Use multi-head self-attention mechanism to represent the complete drug M ′ t Processing is performed to capture the interactions between generated drugs and optimize feature representation through layer normalization: M ′ t ′ =LayerNorm(M ′ t +Multihead(M ′ t ,M ′ t ,M ′ t )); The patient's current diagnosis and surgery representations are fused with the feature representation optimized through layer normalization to adaptively model uncovered diseases to generate the next medication recommendation. The drug prediction probability is calculated through the multi-layer perceptron layer as follows: Among them, w g and b g is a learnable parameter; Pr g is the probability of all drugs; for The last line of .

6. The drug recommendation method based on feature fusion and graph construction according to claim 1, characterized in that: Calculating the final probability of drug recommendation involves encoding the patient's diagnosis sequence and surgical sequence as follows: in, is a learnable parameter, d j ′ is the diagnosis representation of the jth visit, represents the diagnosis code of the diagnosis sequence in the jth visit after the aggregation layer; p j ′ is the surgical representation of the jth visit, represents the surgical code of the surgical sequence in the jth visit after the aggregation layer; the patient visit similarity score is: in, Represents the similarity score between the jth visit (1≤j≤t-1) and the current tth visit; drug matching similarity score for: Among them, 1≤j≤t-1, m j ′ , p represents the pth drug prescribed during the jth visit, for The last row of ; combined with the visit similarity score and drug similarity scores Get the predicted probability of each drug considering the patient's historical visits, that is, the historical similarity score: Among them, 1{m j,k =m i } in m j,k =m i The value is 1 when the value is 0; otherwise, the value is 0. Represents the probability of the i-th drug being recommended. After merging, we get the final probability of all drugs being recommended considering the patient's history of treatment. Where |M| represents the total number of drugs; Combine the drug recommendation probability with the historical similarity score to obtain the final drug recommendation probability: Pr=w p +w g *Pr g +(1-w g -w p )*Pr c , Among them, W f 、b f and w p are all learnable parameters.

7. The drug recommendation method based on feature fusion and graph construction according to claim 1, characterized in that: It also includes constructing a joint loss function: constructing a binary cross entropy loss function Loss BCE Used to measure the accuracy of the model's drug recommendations, as follows: Among them, τ is a learnable parameter; |M| represents the total number of drugs, M i represents the true label of the i-th drug, which takes the value 1 when the drug is recommended and takes the value 0 when it is not recommended; Pr i Represents the recommendation probability of the i-th drug; constructs the drug interaction loss function Loss DDI To reduce potential adverse interactions in recommended drug combinations, as follows: Here, the symbol · represents the product between scalars; Adopt weighted fusion strategy, combined with binary cross entropy loss function Loss BCE and drug interaction loss function Loss DDI , forming the final joint loss function to balance the recommendation accuracy and medication safety: Loss=ρLoss BCE +(1-ρ)Loss DDI ; Among them, ρ is the weight hyperparameter.

8. The drug recommendation method based on feature fusion and graph construction according to claim 1, characterized in that: Error correction of predicted probabilities includes: constructing a causal graph based on electronic medical record data and optimizing the graph structure using a greedy intervention equivalent search algorithm; using causal reasoning methods and the Pearson correlation coefficient to quantify the therapeutic effects of drugs on diseases and surgeries to generate a causal effect matrix; and adjusting the probability of drug recommendation based on the therapeutic effect threshold.

9. A drug recommendation system based on feature fusion and graph construction, characterized in that: include: The data acquisition module is configured to: obtain the patient's diagnosis sequence, operation sequence, and medication sequence; The feature fusion module is configured to: perform local feature extraction and global feature extraction on the diagnosis sequence, the surgery sequence, and the medication sequence, respectively, and fuse the local feature extraction and the global feature extraction to obtain the diagnosis representation, the surgery representation, and the medication representation; The graph construction module is configured to: establish an electronic health record graph, a drug interaction graph, and a drug sensitivity graph based on an electronic health record dataset, utilize the established electronic health record graph, drug interaction graph, and drug sensitivity graph, and a preset graph attention network to obtain drug representations, and fuse them with the drug representations obtained by feature extraction; wherein the electronic health record graph and the drug interaction graph are respectively represented by adjacency matrices; in the electronic health record graph, the adjacency matrix is ​​1 if and only if two drugs appear in the prescription of the same patient visit, otherwise it is 0; in the drug interaction graph, the adjacency matrix is ​​1 if and only if there is a drug interaction between the two drugs, otherwise it is 0; The prediction probability determination module is configured to: obtain a diagnosis similarity score based on the diagnosis representation and the surgery representation through encoding technology; and obtain a drug similarity score based on the fused drug representation; and combine the diagnosis similarity score and the drug similarity score to obtain a predicted probability of the drug after considering the patient's historical visits; An error correction module is configured to: perform error correction on the predicted probability and adjust the drug recommendation probability according to the treatment effect threshold; The recommendation module is configured to make drug recommendations based on the corrected predicted probability.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that: When the processor executes the program, the steps of the drug recommendation method based on feature fusion and graph construction as described in any one of claims 1 to 8 are implemented.

Citation Information

Cited By

  • Drug recommendation model construction method, drug recommendation method, device and equipment

    CN121075538A

  • Drug recommendation method and system based on drug mapping and diagnosis enhancement

    CN121096523A