A traditional chinese medicine prescription recommendation method based on contrast pre-training and hierarchical structure network
By comparing pre-trained and hierarchical network methods, a traditional Chinese medicine prescription recommendation model was constructed. This model addresses the impact of sparse data on recommendation accuracy and improves the accuracy of traditional Chinese medicine prescription recommendations, especially for rare diseases.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUZHOU UNIVERSITY
- Filing Date
- 2024-01-22
- Publication Date
- 2026-05-29
AI Technical Summary
Existing TCM prescription recommendation models suffer from insufficient accuracy when dealing with sparse data, especially for prescriptions for rare diseases. Furthermore, data mining and graph neural network models fail to fully consider the negative impact of data sparsity on recommendation performance.
A method based on contrastive pre-training and hierarchical network structure is adopted. By constructing symptom-TCM association networks, symptom-symptom association networks, and TCM-TCM association networks, contrastive pre-training and perturbation networks are used to obtain node embedding representations. Combined with isomorphic graph neural networks and hierarchical network modules, node features are fused for training to improve the accuracy of the recommendation system.
It effectively solves the problem of insufficient recommendation accuracy caused by data sparsity, ensuring that the recommendation system can still maintain excellent performance with sparse datasets and improving the recommendation accuracy of prescriptions for rare diseases.
Smart Images

Figure CN122117432A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of drug recommendation technology, and more specifically, to a method for recommending traditional Chinese medicine prescriptions based on contrastive pre-training and hierarchical network structures. Background Technology
[0002] Traditional Chinese medicine (TCM) prescriptions are treatment plans devised by TCM practitioners based on a patient's constitution and disease characteristics, combined with TCM theory and experience. These prescriptions aim to harmonize the body's Yin-Yang balance, promoting the body's self-regulation and healing. Integrating TCM principles, TCM prescriptions are characterized by personalized treatment, syndrome differentiation and treatment, comprehensive efficacy, support from TCM theory, and natural medicinal sources. TCM practitioners select herbs according to each patient's specific condition, emphasizing individual differences. Furthermore, TCM prescriptions typically contain multiple medicinal herbs that work synergistically to achieve a comprehensive therapeutic effect.
[0003] However, the core processes of diagnosis and prescription of traditional Chinese medicine still largely rely on the experience of individual doctors. This method is highly subjective and lacks standardized criteria, thus hindering the development of the field of traditional Chinese medicine to some extent. With the rise of AI technology, machine learning and deep learning have provided core technologies for intelligent assisted diagnosis and treatment based on the mining of knowledge about traditional Chinese medicine and Chinese herbal medicine.
[0004] Currently, there is some work related to the recommendation of traditional Chinese medicine prescriptions, mainly using data mining, topic modeling, and neural network models.
[0005] Most existing data mining methods target only a single specific symptom and cannot provide personalized recommendations for a wide range of symptoms. Furthermore, the effectiveness of data mining largely depends on the quality and completeness of the data, which is often difficult to obtain. Medical research records for many herbs are incomplete and suffer from inconsistent and non-standardized data recording, all of which affect the accuracy and reliability of data mining.
[0006] Some existing works have used topic models to explore the generation process of traditional Chinese medicine prescriptions and uncover their potential patterns. However, topic models are typical bag-of-words models, which have significant limitations for short text data of traditional Chinese medicine prescriptions and make it difficult to understand the complex correlation between symptoms and herbs.
[0007] The application of Graph Neural Networks (GNNs) in traditional Chinese medicine (TCM) prescription recommendation systems leverages their efficient processing capabilities for graph-structured data. TCM prescription recommendation can be viewed as a graph-structured problem, where elements such as medicinal herbs, symptoms, and diseases constitute nodes, and their interactions and matching relationships form edges. By learning the complex relationships between these nodes and edges, GNNs can capture the interactions between different medicinal herbs and their therapeutic effects on specific diseases or symptoms. However, current models have not fully considered the negative impact of data sparsity on recommendation performance. In these models, nodes with higher popularity often receive more recommendation opportunities, leading to misleading prescriptions for rare diseases. This phenomenon allows some common herbs or treatments to dominate in TCM prescription recommendation systems, while neglecting herbs effective for rare diseases, affecting the comprehensiveness and accuracy of the recommendation system.
[0008] In summary, existing TCM prescription recommendation models still need improvement. Therefore, this invention designs a TCM prescription recommendation method based on contrastive pre-training and hierarchical network structures, which can deeply mine the potential correlations in sparse data and improve the accuracy of prescription recommendations. Summary of the Invention
[0009] To address the shortcomings of existing technologies, the present invention aims to provide a traditional Chinese medicine prescription recommendation method based on contrastive pre-training and hierarchical network structure. This method can significantly improve the model's learning ability when processing sparse data, thereby improving the performance of the recommendation system and ensuring the accuracy and practicality of the recommendation results.
[0010] To achieve the above objectives, the present invention provides the following technical solution: a method for recommending traditional Chinese medicine prescriptions based on contrastive pre-training and hierarchical network structures, comprising:
[0011] S1, Obtain the prescription dataset;
[0012] S2, construct symptom-Chinese medicine association networks, symptom-symptom association networks, and Chinese medicine-Chinese medicine association networks based on the prescription dataset;
[0013] S3. Construct two perturbation association networks based on the symptom-TCM association network. Through comparative training of the two perturbation association networks, obtain the initial embedding representation of the nodes as Z. s and Z h ;
[0014] S4, construct the isomorphic graph neural network module, and use Z s and Z h As initial input, node features are learned from the symptom isomorphism graph and the traditional Chinese medicine isomorphism graph, denoted as G. ss and G hh ;
[0015] S5, construct a hierarchical network module, and integrate Z s and Z h As the initial input, node features are learned from the symptom-TCM association network, denoted as G. s and G h ;
[0016] S6, Z s G ss G s and Z h G hh G h The symptom representation and the traditional Chinese medicine representation are fused together and input into the recommendation module for training to obtain a trained graph neural network. The trained graph neural network is then used to derive the recommended prescription.
[0017] The present invention is further configured such that step S1 specifically includes:
[0018] S101, the prescription dataset P = <s_set, h_set> represents a total of |P| prescription data, where each prescription contains a symptom set s_set = {s1, s2, ..., s...} i} and a set of Chinese herbal medicines h_set={h1,h2,…,h j}, where |s_set|>0, |h_set|>0;
[0019] S102, divide the above training data into 80% training set for training the model and 20% test set for testing the recommendation effect.
[0020] The present invention is further configured such that step S2 specifically includes:
[0021] S201, establish pairwise connections between symptoms and Chinese medicines in the same prescription to obtain the symptom-Chinese medicine association network SH-graph;
[0022] S202, the symptom set in prescription p represents multiple symptoms that may appear in the patient, and there are interaction or co-occurrence relationships between the symptoms, resulting in the symptom-symptom association network SS-graph;
[0023] S203, the set of Chinese medicines in prescription p represents the combination of Chinese medicines that can enhance the therapeutic effect. There are interaction relationships or co-occurrence relationships between Chinese medicines, resulting in the Chinese medicine-Chinese medicine association network HH-graph;
[0024] S204. Obtain the symptom-symptom similarity matrix and the traditional Chinese medicine-traditional Chinese medicine similarity matrix based on SH-graph from SH-graph. The calculation formula is as follows:
[0025]
[0026] in, Rx(s) represents the similarity between symptom i and symptom k. i Rx(s) represents the set of Chinese herbal medicines associated with symptom i in the SH graph. k ) represents the set of Chinese medicines associated with symptom k, and N represents the number of Chinese medicines;
[0027] S205. Symptom-symptom similarity and traditional Chinese medicine-traditional Chinese medicine similarity are obtained from SS-graph and HH-graph, and calculated using the Jaccard similarity coefficient. The calculation formula is as follows:
[0028]
[0029] in, Rx(s) represents the similarity between symptom i and symptom k. i Rx(s) represents the set of Chinese herbal medicines in the SS-graph that are associated with symptom i. k () represents the set of Chinese medicines associated with symptom k;
[0030] S206, The symptom similarity matrix and the symptom-symptom adjacency matrix obtained above are fused, and the result is expressed by the following mathematical formula:
[0031] A′ SS =A SS Sim_ss
[0032] A′ HH =A HH Sim_hh
[0033]
[0034]
[0035] Where λ1 is a hyperparameter, and Sim_ss and Sim_hh are the final similarity matrices.
[0036] The present invention is further configured such that step S3 specifically includes:
[0037] S301, a perturbation correlation network Net1 is constructed by SVD matrix decomposition;
[0038] S302, by performing Dropout operation on the edges, a perturbation-related network Net2 is constructed;
[0039] S303 uses the GCN encoder to encode Net1 and Net2. After performing two-layer neighbor aggregation on the two networks respectively, the difference between the two networks is calculated using the InfoNCE loss function to obtain the embedding representation of symptoms and the embedding representation of traditional Chinese medicine.
[0040] The present invention is further configured such that step S4 specifically includes:
[0041] S401, in the isomorphic neural network module, A′ SS and A′ HH As input to the model, the GCN model is used to aggregate one layer of neighbor information for the symptom isomorphism graph and the traditional Chinese medicine isomorphism graph, respectively.
[0042] S402, obtain the embedded representation of aggregated neighbor information as input to the MLP to obtain the symptom embedding G. ss And traditional Chinese medicine embedded representation G hh .
[0043] The present invention is further configured such that step S5 specifically includes:
[0044] S501 is a hierarchical network that aggregates neighbors of different levels for nodes at different levels.
[0045] S502 performs aggregation operations of different levels on nodes at different levels to obtain the node features after the hierarchical module, denoted as G. s and G h .
[0046] The present invention is further configured such that step S6 specifically includes:
[0047] S601 aggregates the node features of the three modules, with the specific formula as follows:
[0048]
[0049]
[0050] S602, predict prescriptions in the test set and calculate the recommendation loss, using the following formula:
[0051] Z s_set =RELU(avg_pool(P s ·Q s ))
[0052] y pre =σ(Z) s_set ·Q h )
[0053] Among them, P sIt is a one-hot encoded matrix representing a prescription p s,i It contains a set of symptoms, Q s It is the ultimate characteristic representation of all symptoms, Q h This is the final feature representation of all Chinese herbal medicines. `avg_pool(·)` is the average pooling layer, and `ReLU(·)` is the corrected linear unit. Then, the comprehensive embedding of the symptom set is interacted with the embedding representation of all herbs using matrix multiplication. Finally, the value is transformed into a probability, y. pre This is the Chinese medicine score matrix for all prescriptions;
[0054] L pre =L(y pre ,y)
[0055] L(·) uses BCEWithLogitsLoss loss, and y is the actual Chinese medicine prescription. The error between the predicted prescription and the actual prescription is calculated using this loss, and the model parameters are trained.
[0056] S603, based on the characteristics of the recommendation task, uses the common BPR loss to maximize the similarity between symptoms and positive sample Chinese medicines, and minimize the similarity with negative sample Chinese medicines. The specific formula is as follows:
[0057]
[0058] Among them, y i,j Indicates positive samples for symptoms s i Similarity score h with positive sample Chinese medicine j y i,q Indicates negative sample values for symptom s i Compared with negative sample Chinese medicine h q The similarity score is given by σ(·), which represents the activation function. The sigmoid function is selected as the activation function.
[0059] S604, the final loss is obtained by fusing the two losses, and the specific formula is as follows:
[0060] Loss=λ2L BPR +λ3L pre
[0061] Where λ2 and λ3 are hyperparameters.
[0062] In summary, this invention offers the following advantages: it employs a comparative pre-training method to obtain more reliable initial node features, which are then applied to isomorphic and hierarchical network modules. This approach fully considers the impact of dataset sparsity on recommendation performance, effectively addressing the problem of insufficient recommendation accuracy caused by data sparsity. This innovative step ensures that the recommendation system still exhibits excellent performance when faced with sparse datasets. Attached Figure Description
[0063] Figure 1 This is a flowchart illustrating a method for recommending traditional Chinese medicine prescriptions based on comparative pre-training and hierarchical network structures, as proposed in this invention patent.
[0064] Figure 2 This is a model architecture diagram of the traditional Chinese medicine prescription recommendation method based on contrastive pre-training and hierarchical network proposed in this invention patent. Detailed Implementation
[0065] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0066] Reference Figure 1 and Figure 2 As shown, Figure 1 As shown, a method for recommending traditional Chinese medicine prescriptions based on contrastive pre-training and hierarchical network structure includes the following steps:
[0067] S1. Prescription data is extracted from the "Dictionary of Chinese Materia Medica Prescriptions" and the symptoms and Chinese medicine names are filtered and unified through "Differential Diagnosis of Symptoms in Traditional Chinese Medicine" and "Thesaurus of Traditional Chinese Medicine". Then, it is sorted and summarized with existing Chinese medicine prescription literature to construct the dataset used in this invention. The dataset is encoded using the one-hot encoding method to process and analyze the data more effectively.
[0068] S2, construct symptom-TCM association networks, symptom-symptom association networks, and TCM-TCM association networks based on the prescription dataset.
[0069] S3. Construct two perturbation association networks based on the symptom-TCM association network. Obtain the initial embedding representation Z of the nodes by comparing and training the two perturbation association networks. s and Z h .
[0070] S4, construct the isomorphic graph neural network module, and use Z s and Z h As initial input, node features are learned from the symptom isomorphism graph and the traditional Chinese medicine isomorphism graph, denoted as G. ss and G hh .
[0071] S5, construct a hierarchical network module, and integrate Z s and Z hAs the initial input, node features are learned from the original symptom-TCM association network, denoted as G. s and G h .
[0072] S6, fuses all feature representations of symptoms and traditional Chinese medicine respectively to obtain the final symptom representation and traditional Chinese medicine representation, and inputs them into the recommendation module for training to obtain a trained graph neural network. Then, the trained graph neural network is used to derive the recommended prescription.
[0073] This invention employs a comparative pre-training method to obtain more reliable initial node features, which are then applied to homogeneous and hierarchical network modules. This approach fully considers the impact of dataset sparsity on recommendation performance, effectively addressing the problem of insufficient recommendation accuracy caused by data sparsity. This innovative step ensures that the recommendation system still exhibits excellent performance when faced with sparse datasets.
[0074] Example 2
[0075] Specifically, such as Figure 2 As shown, the specific steps of the entire model architecture are as follows:
[0076] In step S1, the data provided in the literature on traditional Chinese medicine prescriptions is collected, organized, and summarized. The specific steps are as follows:
[0077] S101, the prescription dataset P = <s_set, h_set> represents a total of |P| prescription data, where each prescription contains a symptom set s_set = {s1, s2, ..., s...} i} and a set of Chinese herbal medicines h_set={h1,h2,…,h j}, where |s_set|>0, |h_set|>0. In the given Chinese medicine prescription data, there are a total of M symptoms and N Chinese medicines. All M symptoms form a total symptom set, and all N Chinese medicines form a total Chinese medicine set.
[0078] S102, divide the above training data into 80% training set for training the model and 20% test set for testing the recommendation effect.
[0079] In step S2, the specific steps for constructing the symptom-TCM association network SH-graph, the symptom-symptom association network SS-graph, and the TCM-TCM association network HH-graph from the prescription dataset are as follows:
[0080] S201, each prescription p contains a symptom set and a set of traditional Chinese medicines (TCMs), indicating that the combination of TCMs can treat multiple co-occurring symptoms. Therefore, pairwise connections are established between symptoms and TCMs in the same prescription to obtain a symptom-TCM association network graph. For example, for prescription p1=<s_set,h_set>, where s_se=t{s1,s2,s3} and h_set={h1,h2,h3}, the edge set of the SH-graph is {(s1,h1),(s1,h2),(s1,h3),...,(s3,h3)}. If there is an edge between two nodes, it is set to 1; otherwise, it is set to 0. Therefore, the SH-graph is defined as follows:
[0081]
[0082] S202, the symptom set in prescription p represents multiple symptoms that may occur in a patient, and these symptoms have interaction or co-occurrence relationships. For example, during COVID-19 infection, accompanying symptoms such as fever, cough, and headache often occur. Therefore, fever, headache, and cough are paired and connected. Thus, for prescription p1, the edge set of the SS-graph is {(s1,s2),(s1,s3),(s2,s3)}. If there is an edge between two nodes, it is set to 1; otherwise, it is set to 0. Therefore, the SS-graph is defined as follows:
[0083]
[0084] S203, the set of Chinese herbs in prescription p represents the combination of Chinese herbs that enhances the therapeutic effect. These herbs interact or co-occur with each other. Therefore, for prescription p1, the edge set of the HH-graph is {(h1,h2),(h1,h3),(h2,h3)}. If there is an edge between two nodes, it is set to 1; otherwise, it is set to 0. Therefore, the HH-graph is defined as follows:
[0085]
[0086] S204. Obtain the symptom-symptom similarity matrix and the traditional Chinese medicine-traditional Chinese medicine similarity matrix based on SH-graph from SH-graph. The calculation formula is as follows:
[0087]
[0088] in, Rx(s) represents the similarity between symptom i and symptom k. i Rx(s) represents the set of Chinese herbal medicines associated with symptom i in the SH graph. k () represents the set of Chinese herbal medicines associated with symptom k, and N represents the number of Chinese herbal medicines. Chinese herbal medicine-Chinese herbal medicine similarity. and The calculation methods are similar.
[0089] S205. Symptom-symptom similarity and traditional Chinese medicine-traditional Chinese medicine similarity are obtained from SS-graph and HH-graph, and calculated using the Jaccard similarity coefficient. The calculation formula is as follows:
[0090]
[0091] in, Rx(s) represents the similarity between symptom i and symptom k. i Rx(s) represents the set of Chinese herbal medicines in the SS-graph that are associated with symptom i. k This represents the set of Chinese herbal medicines (TCMs) associated with symptom k. (TCM-TCM similarity) and The calculation method is the same.
[0092] S206, the symptom similarity matrix and the symptom-symptom adjacency matrix obtained above are fused. The fusion method is to perform a dot product between the elements of the similarity matrix and the elements of the adjacency matrix. This adds extra information to the edge information of related edges and distinguishes edges that are not related. This can be expressed mathematically as:
[0093] A′ SS =A SS Sim_ss
[0094] A′ HH =A HH Sim_hh
[0095]
[0096]
[0097] Where λ1 is a hyperparameter, and Sim_ss and Sim_hh are the final similarity matrices.
[0098] In step S3, two perturbation association networks are constructed based on the symptom-TCM association network. By comparing and training the two perturbation association networks, the initial embedding representation Z of the nodes is obtained. s and Z h The specific steps are as follows:
[0099] S301, the perturbation correlation network Net1 is constructed through SVD matrix factorization. The formula for SVD matrix factorization is as follows:
[0100] A = USV T
[0101] Where, U∈R M×MIt is an orthogonal left singular matrix, S∈R M×N It is a diagonal matrix, and the elements on the diagonal are called singular values, usually arranged in descending order, V T ∈R N×N It is an orthogonal right singular matrix. Reconstruct the adjacency matrix A by taking the first r singular values through a truncation value r. SH ∈R M×N The truncated singular value decomposition formula is shown below:
[0102]
[0103] Among them, U r ∈R M×r The matrix is the first r columns of U in the complete singular value decomposition, V r ∈R r×N The matrix is the first r columns of V in the complete singular value decomposition, S r ∈R r×r These are the first r diagonal elements of S. The reconstructed A is a lower-rank approximate matrix than A.
[0104] S302 constructs a perturbation-based relational network Net2 by performing Dropout operations on edges. Dropout is a data augmentation method that creates an enhanced perturbation view by randomly discarding some edges, which can increase the model's ability to handle different data variations and help the model learn more robust feature representations.
[0105] S303: After obtaining two different perturbation networks from S301 and S302, the GCN encoder is used to encode the two perturbation networks. After performing two-layer neighbor aggregation on each network, the InfoNCE loss function is used to calculate the difference between the two networks. As training progresses, the difference becomes smaller and smaller. When the difference tends to stabilize, the pre-training module is completed, and the embedding representations of symptoms and traditional Chinese medicine are obtained. The specific steps are as follows:
[0106] (1) Initialize all symptom and traditional Chinese medicine nodes using the Xavier initializer. Input the initial node features into the GCN network for training. During model training, first aggregate neighbor information, then transmit the neighbor node information to the target node and update the target node's information. Symptoms i and traditional Chinese medicine j The aggregation of higher-order neighbor information can be expressed mathematically as follows:
[0107]
[0108]
[0109] in, and Let N represent the feature representation of symptom s after aggregating the information of its neighbors at the l-th layer, and the feature representation of traditional Chinese medicine h after aggregating the information of its neighbors at the l-th layer, respectively. s N represents the set of Chinese medicinal herbs that interact with s in the SH-graph. h This represents the set of symptoms that interact with h in the SH-graph.
[0110] (2) After aggregating the neighbor information, update the target node information using the following formula:
[0111]
[0112]
[0113] (3) After obtaining two perturbation networks that aggregate the neighbor information of the two layers, the two perturbation networks are trained comparatively to reduce the distance between positive sample pairs and increase the distance between negative sample pairs, thus obtaining the comparative loss. The specific formula is as follows:
[0114]
[0115] in, This represents the feature representation of the i-th symptom in Net1 at layer l. Let f(·) represent the feature representation of the i-th symptom in the l-th layer of Net2, where f(·) is the similarity calculation function. In the experiment, the dot product is used to calculate the similarity between two symptoms, and τ is the temperature coefficient. h Obtained using the same method. Therefore, the total contrast loss is:
[0116] L cl =λ3(L s +L h )
[0117] (4) As training progresses, L cl The loss will gradually decrease, and when it converges, the pre-training is complete, ultimately yielding the symptom embedding representation Z. s Embedded representation of traditional Chinese medicine Z h .
[0118] In step S4, an isomorphic graph neural network module is constructed, which integrates Z... s and Z h As initial input, node features are learned from the symptom isomorphism graph and the traditional Chinese medicine isomorphism graph, denoted as G. ss and G hh The specific steps are as follows:
[0119] S401, in the isomorphic neural network module, the A′ obtained in S206 is... SS and A′ HHAs input to the model, the GCN model is first used to aggregate a layer of neighbor information for the symptom isomorphism graph and the traditional Chinese medicine isomorphism graph, respectively. The specific formula is as follows:
[0120] (1) Aggregating neighbor information
[0121]
[0122]
[0123] in, These represent the isomorphisms of aggregated symptoms and the isomorphisms of traditional Chinese medicine, respectively. Figure 1 Feature representation after order neighbor, z s,i Z represents s The symptom vector with index i in the middle, z h,i Z represents h The vector of Chinese medicine with index i.
[0124] (2) Update target node information
[0125]
[0126]
[0127] S402, the embedded representation of aggregated neighbor information is obtained as input to the MLP. In the MLP, the data undergoes dimensionality transformation through two layers of neurons, and then the linear input is transformed into a non-linear output through an activation function. While capturing the core features of the input data, redundant information is ignored, and finally, the symptom embedding G is obtained. ss And traditional Chinese medicine embedded representation G hh The specific formula is as follows:
[0128] G ss =σ(W l σ(W l-1 E s +b l-1 )+b l )
[0129] G hh =σ(W l σ(W l-1 E h +b l-1 )+b l )
[0130] Where W is the weight matrix, b is the bias vector, and σ(·) is a non-linear activation function used to enhance the model's learning ability.
[0131] In step S5, a hierarchical network module is constructed, which includes Z... s and Z hAs the initial input, node features are learned from the original symptom-TCM association network, denoted as G. s and G h The specific steps are as follows:
[0132] S501, firstly, since the frequency of symptoms and traditional Chinese medicine (TCM) nodes in the training set exhibits a long-tail distribution, TCMs with high prevalence also show higher preference during model training. Therefore, these types of TCMs are more likely to be recommended, thus narrowing the recommendation range. This is very disadvantageous for some rare TCMs that specifically treat rare diseases, so it is necessary to strengthen the learning of rare nodes. Therefore, a hierarchical network structure is adopted, aggregating neighbors of different levels for nodes at different levels to enrich the representation of edge nodes. The specific steps of node hierarchicalization are as follows:
[0133] (1) Obtain the occurrence count of all symptoms and traditional Chinese medicine nodes in the training set.
[0134] (2) Based on frequency, use KMeans clustering and set the number of clusters to 3.
[0135] (3) Label all nodes and determine the level to which the label belongs based on the cluster center.
[0136] S502, after layering all nodes, they form a pyramid distribution. The top of the pyramid represents the nodes with the highest popularity, followed by intermediate and lower popularity levels. Different levels of aggregation are performed on nodes at different levels: first-level nodes aggregate one level of neighbors, middle-level nodes aggregate two levels of neighbors, and bottom-level nodes aggregate three levels of neighbors. This yields the node features processed by the layering module, denoted as G. s and G h .
[0137] In step S6, all feature representations of symptoms and traditional Chinese medicine are fused to obtain the final symptom and traditional Chinese medicine representations, which are then input into the recommendation module for training to obtain a trained graph neural network. Subsequently, a recommended prescription is derived based on the trained graph neural network. The specific steps are as follows:
[0138] S601 aggregates the node features of the three modules, with the specific formula as follows:
[0139]
[0140]
[0141] S602, predict prescriptions in the test set and calculate the recommendation loss, using the following formula:
[0142] Z s_set =RELU(avg_pool(P s ·Qs ))
[0143] y pre =σ(Z) s_set ·Q h )
[0144] Among them, P s It is a one-hot encoded matrix representing a prescription p s,i It contains a set of symptoms, Q s It is the ultimate characteristic representation of all symptoms, Q h This represents the final feature representation of all Chinese herbal medicines. `avg_pool(·)` is the average pooling layer, and `ReLU(·)` is the corrected linear unit, which is an activation function. The comprehensive embedding of the symptom set is then interacted with the embedding representation of all herbs using matrix multiplication, and the values are then transformed into a probability, y. pre This is the Chinese medicine score matrix for predicting all prescriptions.
[0145] L pre =L(y pre ,y)
[0146] L(·) uses BCEWithLogitsLoss loss, y is the real Chinese medicine prescription, and the error between the predicted prescription and the real prescription is calculated by BCEWithLogitsLoss loss to train the model parameters.
[0147] S603, based on the characteristics of the recommendation task, uses the common BPR loss to maximize the similarity between symptoms and positive sample Chinese medicines, and minimize the similarity with negative sample Chinese medicines. The specific formula is as follows:
[0148]
[0149] Among them, y i,j Indicates positive samples for symptoms s i Similarity score h with positive sample Chinese medicine j y i,q Indicates negative sample values for symptom s i Compared with negative sample Chinese medicine h q The similarity score is calculated, where σ(·) represents the activation function, and sigmoid is chosen as the activation function.
[0150] S604, therefore, the two losses are fused to obtain the final loss, the specific formula of which is:
[0151] Loss=λ2L BPR +λ3L pre
[0152] Where λ2 and λ3 are hyperparameters.
[0153] In this embodiment, default parameter configurations were used to test the proposed method and five existing methods on a public traditional Chinese medicine prescription dataset. To comprehensively evaluate the performance of each method, Precision, Recall, and F1-score were selected as key performance indicators. Simultaneously, the top@5, top@10, and top@20 performance metrics under these three evaluation criteria were calculated to measure the model's accuracy. In these evaluation metrics, higher values indicate higher model accuracy.
[0154] The verification results are shown in the table below. The method used in this invention is represented by TCMRGCL. It can be seen that the method used in this invention is superior to other methods in all indicators. Therefore, the accuracy of this invention is superior to other existing methods.
[0155] Methods P@5 P@10 P@20 R@5 R@10 R@20 F1@5 F1@10 F1@20 HC-KGETM 0.2783 0.2197 0.1626 0.1959 0.3072 0.4523 0.2299 0.2562 0.2392 GC-MC 0.2788 0.2223 0.1647 0.1933 0.3102 0.4553 0.2283 0.2590 0.2419 PinSage 0.2841 0.2236 0.1647 0.1995 0.3135 0.4567 0.2344 0.2610 0.2421 NGCF 0.2787 0.2219 0.1634 0.1933 0.3085 0.4505 0.2283 0.2581 0.2398 HeteGCN 0.2864 0.2268 0.1676 0.2018 0.3192 0.4667 0.2368 0.2651 0.2466 TCMRGCL 0.2879 0.2318 0.1702 0.2072 0.3291 0.4751 0.2409 0.2720 0.2506
[0156] To explicitly examine the recommendation results of TCMRGCL, the actual prescriptions corresponding to the symptom sets and the recommended prescriptions given by the model are shown based on the specific test set. It can be seen that the actual prescription in the given case consists of 18 kinds of Chinese medicines. Therefore, 18 kinds of Chinese medicines are also recommended based on the actual prescription. The results show that there are 14 overlapping Chinese medicines recommended, with an accuracy rate of 77.8%, as shown in the table below.
[0157]
[0158] In summary, the traditional Chinese medicine prescription recommendation method designed in this invention, based on contrastive pre-training and hierarchical network structure, can deeply explore the potential correlations in sparse data and has significant application potential in traditional Chinese medicine prescription recommendation, contributing important technological innovations to the development of modern traditional Chinese medicine.
[0159] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A method for recommending traditional Chinese medicine prescriptions based on contrastive pre-training and hierarchical network structures, characterized in that, Including: S1, Obtain the prescription dataset; S2, construct symptom-Chinese medicine association networks, symptom-symptom association networks, and Chinese medicine-Chinese medicine association networks based on the prescription dataset; S3. Construct two perturbation association networks based on the symptom-TCM association network. Through comparative training of the two perturbation association networks, obtain the initial embedding representation of the nodes as Z. s and Z h ; S4, construct the isomorphic graph neural network module, and use Z s and Z h As initial input, node features are learned from the symptom isomorphism graph and the traditional Chinese medicine isomorphism graph, denoted as G. ss and G hh ; S5, construct a hierarchical network module, and integrate Z s and Z h As the initial input, node features are learned from the symptom-TCM association network, denoted as G. s and G h ; S6, Z s G ss G s and Z h G hh G h The symptom representation and the traditional Chinese medicine representation are fused together and input into the recommendation module for training to obtain a trained graph neural network. The trained graph neural network is then used to derive the recommended prescription.
2. The method for recommending traditional Chinese medicine prescriptions based on contrastive pre-training and hierarchical network structure according to claim 1, characterized in that: Step S1 specifically includes: S101, the prescription dataset P = <s_set, h_set> represents a total of |P| prescription data, where each prescription contains a symptom set s_set = {s1, s2, ..., s...} i } and a set of Chinese herbal medicines h_set={h1,h2,...,h j }, where |s_set|>0, |h_set|>0; S102, divide the above training data into 80% training set for training the model and 20% test set for testing the recommendation effect.
3. The method for recommending traditional Chinese medicine prescriptions based on contrastive pre-training and hierarchical network structure according to claim 2, characterized in that: Step S2 specifically includes: S201, establish pairwise connections between symptoms and Chinese medicines in the same prescription to obtain the symptom-Chinese medicine association network SH-graph; S202, Prescription The symptom set represents the multiple symptoms that may appear in a patient, and there are interaction or co-occurrence relationships between the symptoms, resulting in the symptom-symptom association network SS-graph; S203, Prescription The Chinese herbal medicine (TCM) set indicates that the combination of Chinese herbal medicines can enhance the therapeutic effect, and that there are interaction or co-occurrence relationships between Chinese herbal medicines, resulting in the Chinese herbal medicine-TCM association network HH-graph; S204. Obtain the symptom-symptom similarity matrix and the traditional Chinese medicine-traditional Chinese medicine similarity matrix based on SH-graph from SH-graph. The calculation formula is as follows: , in, Indicates symptoms and symptoms Similarity, The SH chart indicates the relationship between symptoms. A collection of related Chinese medicinal herbs. Indicates symptoms A collection of related Chinese medicinal herbs. Represents the quantity of Chinese medicinal herbs; S205. Symptom-symptom similarity and traditional Chinese medicine-traditional Chinese medicine similarity are obtained from SS-graph and HH-graph, and calculated using the Jaccard similarity coefficient. The calculation formula is as follows: , in, Indicates symptoms and symptoms Similarity, Indicates symptoms in SS-graph A collection of related Chinese medicinal herbs. Indicates symptoms A collection of related Chinese medicinal herbs; S206, The symptom similarity matrix and the symptom-symptom adjacency matrix obtained above are fused, and the result is expressed by the following mathematical formula: , , , , in, For hyperparameters, and This is the final similarity matrix.
4. The method for recommending traditional Chinese medicine prescriptions based on contrastive pre-training and hierarchical network structure according to claim 3, characterized in that: Step S3 specifically includes: S301, a perturbation correlation network Net1 is constructed by SVD matrix decomposition; S302, by performing Dropout operation on the edges, a perturbation-related network Net2 is constructed; S303 uses the GCN encoder to encode Net1 and Net2. After performing two-layer neighbor aggregation on the two networks respectively, the difference between the two networks is calculated using the InfoNCE loss function to obtain the embedding representation of symptoms and the embedding representation of traditional Chinese medicine.
5. The method for recommending traditional Chinese medicine prescriptions based on contrastive pre-training and hierarchical network structure according to claim 4, characterized in that: Step S4 specifically includes: S401, in the isomorphic neural network module, A′ SS and A′ HH As input to the model, the GCN model is used to aggregate one layer of neighbor information for the symptom isomorphism graph and the traditional Chinese medicine isomorphism graph, respectively. S402, obtain the embedded representation of aggregated neighbor information as input to the MLP to obtain the symptom embedding G. ss And traditional Chinese medicine embedded representation G hh .
6. The method for recommending traditional Chinese medicine prescriptions based on contrastive pre-training and hierarchical network structure according to claim 5, characterized in that: Step S5 specifically includes: S501 is a hierarchical network that aggregates neighbors of different levels for nodes at different levels. S502 performs aggregation operations of different levels on nodes at different levels to obtain the node features after the hierarchical module, denoted as G. s and G h .
7. The method for recommending traditional Chinese medicine prescriptions based on contrastive pre-training and hierarchical network structure according to claim 6, characterized in that: Step S6 specifically includes: S601 aggregates the node features of the three modules, with the specific formula as follows: S602, predict prescriptions in the test set and calculate the recommendation loss, using the following formula: WITH s_set =RELU(avg_pool(P s ·Q s )) y pre =σ(Z s_set ·Q h ) Among them, P s It is a one-hot encoded matrix representing a prescription p s,i It contains a set of symptoms, Q s It is the ultimate characteristic representation of all symptoms, Q h This is the final feature representation of all Chinese herbal medicines. `avg_pool(·)` is the average pooling layer, and `ReLU(·)` is the corrected linear unit. Then, the comprehensive embedding of the symptom set is interacted with the embedding representation of all herbs using matrix multiplication. Finally, the value is transformed into a probability, y. pre This is the Chinese medicine score matrix for all prescriptions; L pre L(y) pre ,y) L(·) uses BCEWithLogitsLoss loss, y is the real Chinese medicine prescription, and the error between the predicted prescription and the real prescription is calculated through this loss to train the model parameters; S603, based on the characteristics of the recommendation task, uses the common BPR loss to maximize the similarity between symptoms and positive sample Chinese medicines, and minimize the similarity with negative sample Chinese medicines. The specific formula is as follows: Among them, y i,j Indicates positive samples for symptoms s i Similarity score h with positive sample Chinese medicine j y i,q Indicates negative sample values for symptom s i Compared with negative sample Chinese medicine h q The similarity score is given by σ(·), which represents the activation function. The sigmoid function is selected as the activation function. S604, therefore, the fusion of the two losses yields the final loss, as shown in the following formula: Loss=λ2L BPR +λ3L pre Where λ2 and λ3 are hyperparameters.