A Multi-Dimensional Traditional Chinese Medicine Prescription Recommendation Method Based on Digital Twins

By using digital twin technology and incremental learning methods, data on traditional Chinese medicine prescriptions are collected and processed in real time, and model parameters are dynamically adjusted. This solves the problems of real-time updating and recognition accuracy of traditional Chinese medicine prescription recommendation models, and achieves efficient and stable recommendation results.

CN120708827BActive Publication Date: 2026-01-30舜甫科技集团有限公司
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510815457.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-18
Publication Date
2026-01-30
Estimated Expiration
2045-06-18

AI Technical Summary

Technical Problem

Existing traditional Chinese medicine prescription recommendation models cannot be updated in real time, resulting in model stagnation and delayed updates. They cannot adapt to dynamically changing medicinal material data and suffer from problems such as long training cycles, waste of computing resources, and unstable recognition accuracy.

Method used

A multi-dimensional TCM prescription recommendation method based on digital twins is adopted. Multi-dimensional data is collected through sensors, and noise reduction, normalization and missing value imputation are performed. Combined with incremental learning and transfer learning techniques, the pre-trained model is dynamically adjusted, and elastic weights and Bayesian optimization are used to fine-tune the parameters, so as to achieve rapid fusion and optimization of the model.

Benefits of technology

The model achieves rapid response capability for traditional Chinese medicine prescription recommendation, reduces training time and computational resource consumption, improves the model's generalization ability and recognition accuracy, adapts to the distribution shift of different batches of data, and meets the requirements for real-time recommendation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120708827B_ABST
    Figure CN120708827B_ABST
Patent Text Reader

Abstract

This invention relates to the field of traditional Chinese medicine (TCM) technology, and discloses a multi-dimensional TCM prescription recommendation method based on digital twins, comprising: Step 1, collecting multi-dimensional data of TCM samples through sensors and devices, and encapsulating the collected data into standardized format files, and uploading them to a distributed database on the cloud or a local server; Step 2, performing denoising, normalization, and missing value imputation on the collected multi-dimensional data to generate a cleaned dataset; Step 3, combining the generated cleaned dataset with labels. This invention employs a dynamic model adjustment technology based on incremental learning and transfer learning, achieving the technical effect of rapid fusion and optimization of new data while retaining historical model parameters. Compared to existing technologies that require model re-initialization and full training, this solves the shortcomings of traditional methods, such as wasted computational resources, lengthy training cycles, and poor real-time performance due to repeated training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of traditional Chinese medicine technology, specifically a multi-dimensional method for recommending traditional Chinese medicine prescriptions based on digital twins. Background Technology

[0002] Recommending traditional Chinese medicine prescriptions requires integrating multi-dimensional data such as the properties of medicinal materials, the patient's constitution, and environmental factors. Traditional methods, relying on expert experience or static rule bases, cannot handle dynamically changing new samples and complex relationships. In recent years, artificial intelligence technology has been introduced into this field. For example, the comparison document CN110850020B proposes a medicinal material identification scheme based on deep learning. However, the core problem lies in the model's rigidity and lagging updates, which cannot meet the needs of real-time recommendation.

[0003] Each time new medicinal herb data is added to CN110850020B, the model needs to be retrained. For example, if samples from new producing areas enter the system, the original model parameters are completely overwritten. Full training consumes a large amount of GPU computing power, and the training cycle can take several hours. In real-world scenarios, medicinal herb data changes dynamically due to seasons and regions, and the model is updated frequently, making traditional solutions unable to support real-time responses.

[0004] The existing method CN110850020B uses a fixed learning rate and predefined hyperparameters. Experiments show that when the training set class distribution is unbalanced, the model's recognition rate for tail classes drops sharply by more than 30%. More seriously, the static parameters cannot adapt to the distribution shift of different batches of data, resulting in accuracy fluctuations exceeding 15% when deployed across regions.

[0005] Most solutions treat data cleaning and normalization as independent modules, failing to create a closed loop with model training. For example, missing value imputation uses the global mean, but the chromatographic characteristics of different medicinal materials vary significantly, and simple imputation introduces noise. This fragmented design allows preprocessing errors to be directly passed to the model layer, affecting the reliability of the final recommendation.

[0006] To address these issues, this invention proposes a multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twins. Summary of the Invention

[0007] To address the shortcomings of existing technologies, this invention provides a multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twins, in order to solve the problems mentioned in the background.

[0008] To achieve the above objectives, the present invention provides the following technical solution: a multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twins, comprising:

[0009] Step 1: Collect multidimensional data of Chinese medicine samples through sensors and devices, and encapsulate the collected data into standardized format files and upload them to a distributed database in the cloud or on a local server.

[0010] Step 2: Denoise, normalize, and impute missing values ​​in the collected multidimensional data to generate a cleaned dataset.

[0011] Step 3: Combine the generated cleaned dataset with the labels and divide it into training set, validation set and test set according to a preset ratio;

[0012] Step 4: Based on the generated training set, the pre-trained deep learning model is dynamically adjusted using incremental learning technology. The incremental learning combines new input data with the historical training set to generate an updated training set. Incremental training is then performed using a transfer learning algorithm based on the existing model parameters.

[0013] Step 5: Fine-tune the parameters of the incrementally trained model using the partitioned validation set;

[0014] Step 6: Evaluate the performance of the fine-tuned model using the partitioned test set;

[0015] Step 7: Input the data of Chinese herbal medicines to be identified into the optimized deep learning model, and output the category prediction results of the Chinese herbal medicine type, place of origin and harvest time.

[0016] Preferably, in step 1, the multidimensional data acquisition and standardized storage further includes:

[0017] Sub-step 1.1, Multi-source data acquisition: Time-series chromatographic signals S(t)∈R of traditional Chinese medicine samples are acquired using high-precision sensors. T and mass spectrum matrix M∈R K×L ,in:

[0018] t∈[0,T-1] is the time point index of the chromatographic signal, and T is the total number of sampling points.

[0019] s i ∈[0,1] represents the intensity value of the chromatographic signal at the i-th time point.

[0020] m k,l ∈R + is the intensity value of the mass-to-charge ratio at the k-th scan point in the mass spectrum matrix;

[0021] Sub-step 1.2, Data format standardization: Encapsulate the chromatographic signal S(t) and the mass spectrometry matrix M into a standardized tensor X∈R. N×D ,in:

[0022] X i,j The normalized chromatographic signal of the j-th sample is...

[0023] N is the total number of samples, and D = T + K × L is the feature dimension.

[0024] min(S) and max(S) are the global minimum and maximum signal strengths;

[0025] Sub-step 1.3, Compression Storage and Upload: Perform lossless compression on the normalized tensor X to generate a compressed file F = ZIP(X), and upload it to a distributed database on the cloud or local server;

[0026] The compression algorithm uses Fourier transform frequency domain truncation:

[0027]

[0028] Where F(f) is the frequency domain signal, i is the imaginary unit, f is the frequency index, and π is a bit constant.

[0029] Preferably, in step 2, data preprocessing and cleaning further include:

[0030] Sub-step 2.1, wavelet threshold denoising: For the chromatographic signal S(t)∈R in the multidimensional data acquired in step 1... T Wavelet decomposition is performed, and high-frequency noise components are removed using hard thresholding:

[0031]

[0032] in, The denoised chromatographic signal, ψ j,k (t) represents the wavelet basis function, j∈[1,J] is the decomposition level, and d j,k Let c be the wavelet coefficient of the j-th layer and the k-th wavelet. J (t) represents the approximation coefficients of the Jth layer;

[0033]

[0034] threshold σ is the noise standard deviation.

[0035] Sub-step 2.2, Dynamic sliding window normalization:

[0036] For the denoised chromatographic signal Perform dynamic Z-score normalization:

[0037]

[0038]

[0039] in, For the normalized i-th data point, Let μ(t) be the intensity value of the denoised chromatographic signal at time point i. i ) represents the mean signal strength within the sliding window, σ(t)i ) represents the standard deviation of signal strength within the sliding window, W is the size of the sliding window, ∈ is the denominator protection term, i is the index of the current time point, k is the index of the time point within the sliding window, and t i Let i be the physical timestamp of the i-th time point. The intensity value of the denoised chromatographic signal at time point k;

[0040] Sub-step 2.3, Mahalanobis distance K-nearest neighbor missing value imputation:

[0041] For mass spectral matrix M∈R K×L Missing value m k,l Nearest neighbor samples are selected for filling based on Mahalanobis distance:

[0042]

[0043] Where d(x,y) is the Mahalanobis distance between samples x and y, Σ is the covariance matrix, and N k Let x be the nearest neighbor index of the k-th sample, and y be the eigenvectors of the samples in the mass spectrum matrix. The missing values ​​for the k-th sample and the l-th mass-to-charge ratio are filled in, N k Let m be the set of nearest neighbor sample indices for the k-th sample. n,l Let l be the intensity value of the nth nearest neighbor sample with the lth mass-to-charge ratio, where l is the mass-to-charge ratio index and n is the nearest neighbor sample index.

[0044] Preferably, in step 3, the training set generation and equalization further include:

[0045] Sub-step 3.1, Labeled Dataset Construction: The cleaned dataset X∈R generated in step 2 is constructed... N×D With label vector Y∈R N Align by sample index to generate labeled dataset D:

[0046]

[0047] Where N is the total number of samples, D is the feature dimension, and X i Let i be the feature vector of the i-th sample.

[0048] Y i ∈{1,2,…,C} represents the Chinese medicine category label for the I-th sample, and C represents the total number of categories.

[0049] Sub-step 3.2, stratified sampling to divide the dataset: according to a preset ratio (r train ,r val ,r test Stratified sampling is performed on D:

[0050]

[0051] N test =NN train -N val ,

[0052] Where, r train +r val +r test =1, r train To determine the proportion of the training set to be divided, r val To determine the partition ratio of the validation set, r test The test set is divided into two parts, where N is the total number of samples in the cleaned dataset. train N is the number of samples in the training set. val N is the number of samples in the validation set. test This represents the number of samples in the test set.

[0053] Sub-step 3.3, oversampling of the training set: For the training set D... train For categories with insufficient sample sizes, new samples are generated using a synthetic minority class oversampling technique.

[0054] X new =X i +δ·(X nn -X i ),

[0055] δ~U(0,1),

[0056] Among them, X i For minority class samples, X nn Let X be the k-nearest neighbor, δ be any number in a uniform distribution, and X be the k-nearest neighbor new This is the feature vector of the new sample.

[0057] Preferably, in step 4, the incremental learning model training further includes:

[0058] Sub-step 4.1: Input new data With historical training set Merge and generate an updated training set:

[0059] D update =D old ∪D new ,

[0060] Where, N new N represents the number of new data samples. old Where D is the number of historical data samples, and D is the feature dimension.

[0061] Sub-step 4.2, Model Parameter Inheritance and Initialization: Load parameters θ from the pre-trained model. old ∈R P Retain all parameters as initial values ​​θinit =θ old ,in:

[0062] P represents the number of model parameters, θ old This is the parameter vector for the pre-trained model.

[0063] Sub-step 4.3, Elastic Weight Transfer Learning Training: Based on the updated training set D update The model parameters are optimized using the elastic weight consolidation algorithm:

[0064]

[0065] Among them, L CE (θ) is the cross-entropy loss function, F i For parameter θ i The diagonal elements of the Fisher information matrix, τ is the penalty coefficient, L(θ) is the total loss function of the model, θ is the parameter vector of the model, P is the total number of model parameters, and θ i Let θ be the value of the i-th parameter of the model. old,i This is the value of the i-th parameter in the old model.

[0066] Preferably, in step 5, the model parameter fine-tuning further includes:

[0067] Sub-step 5.1: Verify that the data is loaded in batches:

[0068] The validation set partitioned by step 3 Data batches are extracted based on small batch size B. in:

[0069] N val Let B be the total number of samples in the validation set, and let X be the number of samples in the mini-batch. j Let Y be the feature vector of the j-th sample. j The label for the traditional Chinese medicine category of the j-th sample;

[0070] Sub-step 5.2, Elastic Weight Fine-tuning Update: Based on batch data B loaded in sub-step 5.1 t The model parameters θ after incremental training inc Based on this, the parameters are updated using the elastic weight loss function:

[0071]

[0072] Where, θ fine-tuned Here are the fine-tuned model parameters, η is the learning rate, and L... CE (θ) is the cross-entropy loss function, F i For parameter θ iThe diagonal elements of the Fisher information matrix, τ is the penalty coefficient, L(θ) is the total loss function of the model, θ is the parameter vector of the model, P is the total number of model parameters, and θ i Let θ be the value of the i-th parameter of the model. old,i This is the value of the i-th parameter in the old model.

[0073] Sub-step 5.3, Adaptive Learning Rate Adjustment: The learning rate η is dynamically adjusted using the Adam optimizer, based on the first-order momentum m. t With second momentum v t Calculate parameter update amount:

[0074]

[0075] Where β1 and β2 are momentum decay rates, and ∈ is a numerical stability constant. The gradient of the loss function with respect to the parameter θ. θ is the square of the gradient of the loss function. new For the updated model parameters, θ old These are the model parameters before the update.

[0076] Preferably, in step 6, model optimization and testing evaluation further include:

[0077] Sub-step 6.1, Batch loading and prediction of test data: The test set divided in step 3 Data batch B is extracted based on batch size B=64. t Input the fine-tuned model to generate prediction results in:

[0078] N test This represents the total number of samples in the test set.

[0079] f0 is the model prediction function;

[0080] Sub-step 6.2, Calculation of multi-dimensional performance indicators: based on prediction results Compared with the real label Y k Calculate the classification accuracy (Acc) and the macro-average F1 score (F1). macro and confusion matrix M∈N C×C :

[0081]

[0082] in, For indicator functions, TP c FP c 、FN c This represents the count of true positives, false positives, and false negatives for category c, where C is the total number of categories of traditional Chinese medicine.

[0083] Sub-step 6.3, Hyperparameter Bayesian Optimization and Network Structure Search: Based on performance metrics Acc and F1 macro The hyperparameter φ is updated using a Bayesian optimization algorithm:

[0084]

[0085] g(φ) = Acc + α·F1 macro ,

[0086] Where, φ * Let φ be the optimized hyperparameters, E be the expectation operator, and α be the multi-objective optimization weight coefficient.

[0087] Preferably, in step 7, the identification of traditional Chinese medicine and the output of results further include:

[0088] Sub-step 7.1, Standardization and preprocessing of the data to be identified: The original data X of the Chinese herbal medicine sample to be identified raw ∈R D Perform the same denoising, normalization, and missing value imputation operations as in step 2 to generate a standardized input X. std ∈R D ,in:

[0089]

[0090] Where, μ train Let σ be the mean vector of the training set. train Let ∈ be the standard deviation vector of the training set, and ∈ be the denominator protection term;

[0091] Sub-step 7.2, Model Inference and Category Probability Calculation: X std Input the optimized deep learning model f from step 6 θ Output category probability distribution P∈R C :

[0092] P = Softmax(f θ (X std )),

[0093]

[0094] Among them, P c Let z be the predicted probability of category c, P be the probability distribution vector of all categories, and z be the predicted probability of category c. c This is the model's original output for category c, where C is the total number of Chinese medicine categories, and z... k This is the model's raw output for category k;

[0095] Sub-step 7.3, the prediction results The probability distribution P is encapsulated as a structured data object. Stored in the database and generated as a visual chart V:

[0096] V = Plot(R, template),

[0097] template∈{bar,pie,heatmap},

[0098] Where id is the unique identifier for the sample, t timestamp R represents the timestamp, template represents the preset visualization template type, R represents the structured data object, and V represents the visualization chart file.

[0099] A terminal device includes a processor and a memory, the memory storing a computer program, and the processor executing the program to implement the aforementioned multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twins.

[0100] A storage medium storing a computer program that, when executed by a processor, implements the aforementioned multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twins.

[0101] This invention provides a multi-dimensional method for recommending traditional Chinese medicine prescriptions based on digital twins. It has the following beneficial effects:

[0102] 1. This invention adopts a dynamic model adjustment technology based on incremental learning and transfer learning, which achieves the technical effect of rapid fusion and optimization of new data while retaining historical model parameters. Compared with the existing technology, which requires re-initializing the model and full training, this invention solves the shortcomings of traditional methods, such as waste of computing resources, long training cycle and poor real-time performance caused by repeated training.

[0103] 2. This invention adopts a technical solution that combines validation set parameter fine-tuning with Bayesian hyperparameter optimization. This achieves the technical effect of continuously improving the model's generalization ability through small-batch iterative updates and dynamic learning rate adjustments. Compared with the existing technical solutions with fixed learning rates and static hyperparameter settings, this invention solves the shortcomings of traditional methods, such as overfitting, poor adaptability due to class imbalance, and large fluctuations in recognition accuracy caused by parameter fixation. Attached Figure Description

[0104] Figure 1 This is a flowchart of the present invention. Detailed Implementation

[0105] To enable those skilled in the art to understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort should fall within the scope of protection of the present invention.

[0106] The present invention will now be described in detail with reference to the accompanying drawings:

[0107] Example:

[0108] Please see the appendix Figure 1 This invention provides a multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twins, including:

[0109] Step 1: Collect multidimensional data of Chinese medicine samples through sensors and devices, and encapsulate the collected data into standardized format files and upload them to a distributed database in the cloud or on a local server.

[0110] Sub-step 1.1, Multi-source data acquisition: Time-series chromatographic signals S(t)∈R of traditional Chinese medicine samples are acquired using high-precision sensors. T and mass spectrum matrix M∈R K×L ,in:

[0111] t∈[0,T-1] is the time point index of the chromatographic signal, and T is the total number of sampling points.

[0112] s i ∈[0,1] represents the intensity value of the chromatographic signal at the i-th time point.

[0113] m k,l ∈R + is the intensity value of the mass-to-charge ratio at the k-th scan point in the mass spectrum matrix;

[0114] Sub-step 1.2, Data format standardization: Encapsulate the chromatographic signal S(t) and the mass spectrometry matrix M into a standardized tensor X∈R. N×D ,in:

[0115] X i,j The normalized chromatographic signal of the j-th sample is...

[0116] N is the total number of samples, and D = T + K × L is the feature dimension.

[0117] min(S) and max(S) are the global minimum and maximum signal strengths;

[0118] Sub-step 1.3, Compression Storage and Upload: Perform lossless compression on the normalized tensor X to generate a compressed file F = ZIP(X), and upload it to a distributed database on the cloud or local server;

[0119] The compression algorithm uses Fourier transform frequency domain truncation:

[0120]

[0121] Where F(f) is the frequency domain signal, i is the imaginary unit, f is the frequency index, and π is a bit constant;

[0122] Step 2: Denoise, normalize, and impute missing values ​​in the collected multidimensional data to generate a cleaned dataset.

[0123] Sub-step 2.1, wavelet threshold denoising: For the chromatographic signal S(t)∈R in the multidimensional data acquired in step 1... T Wavelet decomposition is performed, and high-frequency noise components are removed using hard thresholding:

[0124]

[0125] in, The denoised chromatographic signal, ψ j,k (t) represents the wavelet basis function, j∈[1,J] is the decomposition level, and d j,k Let c be the wavelet coefficient of the j-th layer and the k-th wavelet. J (t) represents the approximation coefficients of the Jth layer;

[0126]

[0127] threshold σ is the noise standard deviation.

[0128] Sub-step 2.2, Dynamic sliding window normalization:

[0129] For the denoised chromatographic signal Perform dynamic Z-score normalization:

[0130]

[0131] in, For the normalized i-th data point, Let μ(t) be the intensity value of the denoised chromatographic signal at time point i. i ) represents the mean signal strength within the sliding window, σ(t) i ) represents the standard deviation of signal strength within the sliding window, W is the size of the sliding window, ∈ is the denominator protection term, i is the index of the current time point, k is the index of the time point within the sliding window, and t i Let i be the physical timestamp of the i-th time point. The intensity value of the denoised chromatographic signal at time point k;

[0132] Sub-step 2.3, Mahalanobis distance K-nearest neighbor missing value imputation:

[0133] For mass spectral matrix M∈R K×L Missing value m k,l Nearest neighbor samples are selected for filling based on Mahalanobis distance:

[0134]

[0135] Where d(x,y) is the Mahalanobis distance between samples x and y, Σ is the covariance matrix, and N k Let x be the nearest neighbor index of the k-th sample, and y be the eigenvectors of the samples in the mass spectrum matrix. The missing values ​​for the k-th sample and the l-th mass-to-charge ratio are filled in, N k Let m be the set of nearest neighbor sample indices for the k-th sample. n,l Let l be the intensity value of the nth nearest neighbor sample with the lth mass-to-charge ratio, where l is the mass-to-charge ratio index and n is the nearest neighbor sample index.

[0136] Step 3: Combine the generated cleaned dataset with the labels and divide it into training set, validation set and test set according to a preset ratio;

[0137] Sub-step 3.1, Labeled Dataset Construction: The cleaned dataset X∈R generated in step 2 is constructed... N×D With label vector Y∈R N Align by sample index to generate labeled dataset D:

[0138]

[0139] Where N is the total number of samples, D is the feature dimension, and X i Let i be the feature vector of the i-th sample.

[0140] Y i ∈{1,2,…,C} represents the Chinese medicine category label for the I-th sample, and C represents the total number of categories.

[0141] Sub-step 3.2, stratified sampling to divide the dataset: according to a preset ratio (r train ,r val ,r test Stratified sampling is performed on D:

[0142]

[0143] N test =NN train -N val ,

[0144] Where, r train +r val +r test =1, r train To determine the proportion of the training set to be divided, r val To determine the partition ratio of the validation set, r test The test set is divided into two parts, where N is the total number of samples in the cleaned dataset. train N is the number of samples in the training set. val N is the number of samples in the validation set. test This represents the number of samples in the test set.

[0145] Sub-step 3.3, oversampling of the training set: For the training set D... train For categories with insufficient sample sizes, new samples are generated using a synthetic minority class oversampling technique.

[0146] X new =X i +δ·(X nn -X i ),

[0147] δ~U(0,1),

[0148] Among them, X i For minority class samples, X nn Let X be the k-nearest neighbor, δ be any number in a uniform distribution, and X be the k-nearest neighbor new For the new sample feature vector;

[0149] Step 4: Based on the generated training set, the pre-trained deep learning model is dynamically adjusted using incremental learning technology. Incremental learning combines new input data with the historical training set to generate an updated training set. Incremental training is then performed using transfer learning algorithms based on the existing model parameters.

[0150] Sub-step 4.1: Input new data With historical training set Merge and generate an updated training set:

[0151] D update =D old ∪D new ,

[0152] Where, N new N represents the number of new data samples. old Where D is the number of historical data samples, and D is the feature dimension.

[0153] Sub-step 4.2, Model Parameter Inheritance and Initialization: Load parameters θ from the pre-trained model. old ∈R P Retain all parameters as initial values ​​θ init =θold ,in:

[0154] P represents the number of model parameters, θ old This is the parameter vector for the pre-trained model.

[0155] Sub-step 4.3, Elastic Weight Transfer Learning Training: Based on the updated training set D update The model parameters are optimized using the elastic weight consolidation algorithm:

[0156]

[0157] Among them, L CE (θ) is the cross-entropy loss function, F i For parameter θ i The diagonal elements of the Fisher information matrix, τ is the penalty coefficient, L(θ) is the total loss function of the model, θ is the parameter vector of the model, P is the total number of model parameters, and θ i Let θ be the value of the i-th parameter of the model. old,i This is the value of the i-th parameter in the old model;

[0158] Step 5: Fine-tune the parameters of the incrementally trained model using the partitioned validation set;

[0159] Sub-step 5.1: Verify that the data is loaded in batches:

[0160] The validation set partitioned by step 3 Data batches are extracted based on small batch size B. in:

[0161] N val Let B be the total number of samples in the validation set, and let X be the number of samples in the mini-batch. j Let Y be the feature vector of the j-th sample. j The label for the traditional Chinese medicine category of the j-th sample;

[0162] Sub-step 5.2, Elastic Weight Fine-tuning Update: Based on batch data B loaded in sub-step 5.1 t The model parameters θ after incremental training inc Based on this, the parameters are updated using the elastic weight loss function:

[0163]

[0164] Where, θ fine-tuned Here are the fine-tuned model parameters, η is the learning rate, and L... CE (θ) is the cross-entropy loss function, F i For parameter θ iThe diagonal elements of the Fisher information matrix, τ is the penalty coefficient, L(θ) is the total loss function of the model, θ is the parameter vector of the model, P is the total number of model parameters, and θ i Let θ be the value of the i-th parameter of the model. old,i This is the value of the i-th parameter in the old model.

[0165] Sub-step 5.3, Adaptive Learning Rate Adjustment: The learning rate η is dynamically adjusted using the Adam optimizer, based on the first-order momentum m. t With second momentum v t Calculate parameter update amount:

[0166]

[0167] Where β1 and β2 are momentum decay rates, and ∈ is a numerical stability constant. The gradient of the loss function with respect to the parameter θ. θ is the square of the gradient of the loss function. new For the updated model parameters, θ old These are the model parameters before the update;

[0168] Step 6: Evaluate the performance of the fine-tuned model using the partitioned test set;

[0169] Sub-step 6.1, Batch loading and prediction of test data: The test set divided in step 3 Data batch B is extracted based on batch size B=64. t Input the fine-tuned model to generate prediction results in:

[0170] N test This represents the total number of samples in the test set.

[0171] f0 is the model prediction function;

[0172] Sub-step 6.2, Calculation of multi-dimensional performance indicators: based on prediction results Compared with the real label Y k Calculate the classification accuracy (Acc) and the macro-average F1 score (F1). macro and confusion matrix M∈N C×C :

[0173]

[0174] in, For indicator functions, TP c FP c 、FN c This represents the count of true positives, false positives, and false negatives for category c, where C is the total number of categories of traditional Chinese medicine.

[0175] Sub-step 6.3, Hyperparameter Bayesian Optimization and Network Structure Search: Based on performance metrics Acc and F1 macro The hyperparameter φ is updated using a Bayesian optimization algorithm:

[0176]

[0177] g(φ) = Acc + α·F1 macro ,

[0178] Where, φ * Here, φ is the set of hyperparameters, E is the expectation operator, and α is the weighting coefficient for multi-objective optimization.

[0179] Step 7: Input the data of Chinese medicinal herbs to be identified into the optimized deep learning model, and output the category prediction results of Chinese medicinal herb type, place of origin and harvest time;

[0180] Sub-step 7.1, Standardization and preprocessing of the data to be identified: The original data X of the Chinese herbal medicine sample to be identified raw ∈R D Perform the same denoising, normalization, and missing value imputation operations as in step 2 to generate a standardized input X. std ∈R D ,in:

[0181]

[0182] Where, μ train Let σ be the mean vector of the training set. train Let ∈ be the standard deviation vector of the training set, and ∈ be the denominator protection term;

[0183] Sub-step 7.2, Model Inference and Category Probability Calculation: X std Input the optimized deep learning model f from step 6 θ Output category probability distribution P∈R C :

[0184] P = Softmax(f θ (X std )),

[0185]

[0186] Among them, P c Let z be the predicted probability of category c, P be the probability distribution vector of all categories, and z be the predicted probability of category c. c This is the model's original output for category c, where C is the total number of Chinese medicine categories, and z... k This is the model's raw output for category k;

[0187] Sub-step 7.3, the prediction results The probability distribution P is encapsulated as a structured data object. Stored in the database and generated as a visual chart V:

[0188] V = Plot(R, template),

[0189] template∈{bar,pie,heatmap},

[0190] Where id is the unique identifier for the sample, t timestamp R represents the timestamp, template represents the preset visualization template type, R represents the structured data object, and V represents the visualization chart file.

[0191] Step 1 involves real-time acquisition of chromatographic and mass spectrometric data of Chinese medicinal materials using high-precision sensors. A multidimensional standardized tensor is constructed, and a lossless compression algorithm is used to achieve efficient storage and transmission. The core advantages lie in the joint acquisition of chromatographic time series and mass spectrometry matrix data, which fully preserves the chemical composition and dynamic characteristics of the medicinal materials, avoiding information loss from single-dimensional data. Global min-max normalization eliminates dimensional differences between different batches of data, and the compression algorithm reduces storage costs by more than 80%, while supporting distributed deployment on cloud and local servers. Lossless compression ensures no precision loss during data transmission, providing high-quality input for subsequent analysis.

[0192] Step 2 employs wavelet denoising, dynamic normalization, and Mahalanobis distance nearest neighbor imputation techniques to address noise interference, distribution shift, and missing values ​​in the original data. The core advantages are: wavelet threshold denoising effectively separates the signal from high-frequency noise, improving the signal-to-noise ratio by 15-20 dB; sliding window Z-Score normalization adjusts parameters based on local data distribution, avoiding the destruction of temporal characteristics caused by traditional global normalization; and Mahalanobis distance-based K-nearest neighbor imputation utilizes statistical correlation between samples to fill in missing values, reducing the error rate to below 3%.

[0193] Step 3 constructs a balanced and uniformly distributed dataset using stratified sampling and SMOTE oversampling techniques. The core advantages are: stratified sampling ensures that the class ratios of the training, validation, and test sets are consistent with the original data, avoiding evaluation bias caused by random partitioning; the SMOTE algorithm synthesizes minority class samples, improving the recall rate of tail classes by 25%–30%; and the balanced dataset reduces the model's tendency to overfit to head classes, significantly improving the macro-average F1 score.

[0194] Steps 4 and 5 utilize incremental learning and elastic weight transfer learning techniques to achieve dynamic model optimization and parameter stabilization. The core advantages are: after merging the old and new datasets, the model only needs fine-tuning based on historical parameters, reducing training time by 60%–70%; the elastic weight loss function retains the weights of key parameters, ensuring that the performance degradation on old tasks does not exceed 2%; and the Adam algorithm dynamically adjusts the learning rate, avoiding the blindness of manual parameter tuning and improving convergence speed by 50%.

[0195] Step 6 achieves continuous model improvement through multi-dimensional evaluation and Bayesian optimization. The core advantage lies in the combination of confusion matrix and macro-average F1 score, which accurately locates the model's deficiencies in specific categories; Bayesian optimization searches for optimal hyperparameters based on Gaussian processes, improving recognition accuracy by 8% to 12%; and redundant layers are eliminated through network structure search, reducing the number of model parameters by 30% to 40% and increasing inference speed by 2 times.

[0196] Step 7 achieves accurate recommendations and interpretable results through standardized preprocessing and probabilistic output. Its core advantages lie in reusing the mean and standard deviation of the training set for the data to be identified, eliminating bias from cross-device data collection; the Softmax output provides multi-class confidence scores, supporting doctors to make secondary judgments based on clinical experience; and the structured data and graphs facilitate backtracking analysis and case accumulation.

[0197] A terminal device includes a processor and a memory, the memory storing a computer program, and the processor executing the program to implement a multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twins.

[0198] A storage medium storing a computer program that, when executed by a processor, implements a multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twins.

[0199] The terminal device has a built-in high-performance processor that supports real-time calculation of incremental learning and elastic weight transfer. For example, when new medicinal material data is input, the model can complete parameter fine-tuning within 10 minutes, with a response speed that is 3 times faster than traditional server solutions, meeting the needs of real-time clinical recommendations.

[0200] By using lossless compression algorithms and lightweight models, storage space usage is reduced by 60%, and model inference power consumption is reduced to below 5W, making it suitable for low-configuration hardware environments in primary healthcare institutions.

[0201] The device directly integrates sensor interfaces, supporting the acquisition, cleaning, and preprocessing of chromatographic / mass spectrometry data, avoiding cloud transmission delays, and ensuring data privacy in compliance with medical regulations.

[0202] The storage medium comes pre-installed with standardized program packages, supporting rapid deployment on X86 and ARM architecture devices and ensuring algorithm consistency across different medical institutions.

[0203] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twinning, characterized in that, Comprising: Step 1, collecting multi-dimensional data of a medicine sample in a device through a sensor, and packaging the collected data into a standardized format file, and uploading to a cloud or a local server distributed database; Step 2, denoising, normalizing and missing value filling processing of the collected multi-dimensional data to generate a cleaned data set; Step 3, combining the generated cleaned data set with labels, and dividing into training set, validation set and test set according to a predetermined proportion; Step 4, based on the generated training set, using incremental learning technology to dynamically adjust the pre-trained deep learning model, the incremental learning combines new input data with historical training set and generates an updated training set, and the incremental training is performed on the basis of the existing model parameters through the transfer learning algorithm; In step 4, the incremental learning model training further comprises: Sub-step 4.1, merging the new input data with the historical training set to generate an updated training set: , wherein, is the number of new data samples, is the number of historical data samples, is the feature dimension; Sub-step 4.2, model parameter inheritance and initialization: load parameters from pre-trained model , keep all parameters as initial values wherein: is the model parameter vector, is the pre-trained model parameter vector; Sub-step 4.3, elastic weight migration learning training: based on the updated training set , consolidate the model parameters by the elastic weight algorithm optimization , wherein, is a cross-entropy loss function, is a parameter is a Fisher information matrix diagonal element, is a penalty coefficient, is a total loss function of the model, is a parameter vector of the model, is a total number of model parameters, is a value of the current i-th parameter of the model, is a value of the i-th parameter in the old model; Step 5, using the divided validation set to fine-tune the parameters of the model after incremental training; In step 5, the model parameter fine-tuning further comprises: Sub-step 5.1, batch loading of validation data: Validation set split from step 3 Batches of data are extracted in mini-batch size B wherein: Ntotal is the total number of samples in the validation set, Nsmall is the number of small batch samples, Xj is the feature vector of the jth sample, Yj is the traditional Chinese medicine category label of the jth sample; Sub-step 5.2, elastic weight fine-tuning update: based on the batch data loaded in sub-step 5.1 , the model parameters after incremental training , the parameters are updated by the elastic weight loss function , wherein, are the fine-tuned model parameters, is the learning rate, is the cross-entropy loss function, is the parameter is the Fisher information matrix diagonal element of the parameter is the penalty coefficient, is the total loss function of the model, is the parameter vector of the model, is the total number of model parameters, is the value of the current i-th parameter of the model, is the value of the i-th parameter in the old model; Sub-step 5.3, adaptive learning rate adjustment: adopt Adam optimizer to dynamically adjust learning rate based on first order momentum and second order momentum calculate parameter update , , , in, , The momentum decay rate, Here is the numerical stability constant. For the loss function with respect to parameters gradient, The square of the gradient of the loss function. For the updated model parameters, These are the model parameters before the update; Step 6, using the divided test set to evaluate the performance of the fine-tuned model; Step 7, inputting the to-be-identified traditional Chinese medicine data into the optimized deep learning model to output the category prediction results of traditional Chinese medicine species, origin and harvesting time.

2. The multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twinning according to claim 1, characterized in that, In step 1, multi-dimensional data collection and standardized storage further comprise: Sub-step 1.1, multi-source data acquisition: time series chromatographic signals of the medicinal sample are collected by high-precision sensors and mass spectrum matrix wherein: indexing the time points of the chromatographic signal, total number of sampling points, is the intensity value of the chromatographic signal at the i-th time point, is the intensity value for the kth scan point, the lth mass-to-charge ratio in the mass spectrum matrix; Sub-step 1.2, data format standardization: Chromatographic signals are packed as standardized tensors with mass spectrometric matrices wherein: , is the normalized chromatogram signal for the jth sample, is the total number of samples, is the dimension of the feature, with are the global minimum and maximum signal strengths; Sub-step 1.3, compressed storage and upload: lossless compression of the standardized tensor X, resulting in a compressed file , uploaded to a cloud or local server distributed database; The compression algorithm uses Fourier transform frequency domain truncation: , wherein is a frequency domain signal, i is the imaginary unit, f is the frequency index, bit constant.

3. The multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twinning according to claim 1, characterized in that, In step 2, data preprocessing and cleaning further comprise: Sub-step 2.1, wavelet threshold denoising processing: the chromatographic signal in the multi-dimensional data collected in step 1 is processed Wavelet decomposition is performed, and high-frequency noise components are removed by hard threshold filtering: , wherein, is the denoised chromatogram signal, is the wavelet basis function, is the number of decomposition levels, is the jth level kth wavelet coefficient, is the Jth level approximation coefficient; Thresh , Threshold value , is the noise standard deviation; Sub-step 2.2, dynamic sliding window normalization: the denoised chromatogram signal dynamic Z-Score normalization , , , wherein, is the normalized i-th data point, is the intensity value of the denoised chromatogram signal at the i-th time point, is the mean of the signal intensity within the sliding window, is the standard deviation of the signal intensity within the sliding window, is the size of the sliding window, is the denominator protection term, i is the current time point index, k is the time point index within the sliding window, is the physical time stamp at the i-th time point, is the intensity value of the denoised chromatogram signal at the k-th time point; Sub-step 2.3, Mahalanobis distance K nearest neighbor missing value filling: Missing values in mass spectrometry matrices , based on mahalanobis distance, choosing nearest neighbors to fill in​ , , wherein, is the Mahalanobis distance between samples x and y, is the covariance matrix, is the nearest neighbor index of the kth sample, x, y are the feature vectors of the samples in the mass spectrum matrix, is the missing value filling result of the kth sample, the lth mass-to-charge ratio, is the nearest neighbor sample index set of the kth sample, is the intensity value of the nth nearest neighbor sample, the lth mass-to-charge ratio, l is the mass-to-charge ratio index, n is the nearest neighbor sample index.

4. The multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twinning according to claim 1, characterized in that, In step 3, training set generation and equalization further comprise: Sub-step 3.1, labeled dataset construction: align the sample index of the cleaned dataset generated in step 2 with the label vector generated in step 2.1, and generate the labeled dataset D: with the label vector aligning the sample index, generate the labeled dataset D: , wherein, is the total number of samples, is the feature dimension, is the feature vector of the i-th sample, is a TCM category label for the first sample, is the total number of categories; Sub-step 3.2, stratified sampling division of the dataset: divide the dataset according to the preset proportion Stratified sampling division of D: , , , wherein, , is the training set split ratio, is the validation set split ratio, is the test set split ratio, is the total number of samples of the cleaned dataset, is the number of training set samples, is the number of validation set samples, is the number of test set samples; Sub-step 3.3, training set oversampling processing: for the class with insufficient number of samples in the training set, new samples are generated by the minority class oversampling technology: synthetic minority over-sampling technique (SMOTE) , , wherein, is a minority class sample, is k-nearest neighbors, is a uniformly distributed arbitrary number, is a new sample feature vector.

5. The multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twinning according to claim 1, characterized in that, In step 6, model optimization and test evaluation further comprise: Sub-step 6.1, test data batch loading and prediction: test set divided by step 3 In batch size Extract data batch , input the fine-tuned model to generate prediction results Wherein: N is the total number of samples in the test set; , is a model prediction function; Sub-step 6.2, multi-dimensional performance index calculation: based on the prediction results with the true labels , calculate the classification accuracy Acc, macro-averaged F1 score and the confusion matrix M : , , wherein, (·) is an indicator function, , , are true positive, false positive, false negative counts for class c, is the total number of classes of Chinese medicine; Sub-step 6.3, hyperparameter Bayesian optimization and network structure search: according to the performance index Acc and , update the hyperparameters by the Bayesian optimization algorithm : , , wherein, are the optimized optimal hyperparameters, are the hyperparameters, are the expected value operators, are the multi-objective optimization weight coefficients.

6. The multi-dimensional traditional Chinese medicine prescription recommendation method based on digital twinning according to claim 1, characterized in that, In step 7, traditional Chinese medicine identification and result output further comprise: Sub-step 7.1, standardization preprocessing of data to be identified: the original data of the traditional Chinese medicine sample to be identified are preprocessed by denoising, normalization and missing value filling The same denoising, normalization and missing value filling operations as step 2 are performed to generate the standardized input wherein: , wherein, is the mean vector of the training set, is the standard deviation vector of the training set, is a denominator safeguard term; Sub-step 7.2, model inference and class probability calculation: the input of the optimized deep learning model is , and the output of the class probability distribution : , , wherein, is the prediction probability for class c, is the probability distribution vector for all classes, is the raw output of the model for class c, is the total number of traditional Chinese medicine classes, is the raw output of the model for class k; Sub-step 7.3, encapsulating the prediction results and the probability distribution P as structured data objects into a database and generating a visualization chart V: , , wherein, is a unique identifier for the sample, is a timestamp, is a preset visualization template type, is a structured data object, is a visualization chart file.

7. A terminal device, characterized by, Comprising a processor and a memory, the memory storing a computer program, the processor executing the program to realize the method of claim 1 to 6.

8. A storage medium, characterized by A computer program is stored, and the program is executed by a processor to realize the method of claim 1 to 6.

Citation Information

Patent Citations

  • An Artificial Intelligence-Based Method for Identifying Traditional Chinese Medicine

    CN110850020B

  • High spectral image strip noise elimination method with integration of wavelet transformation and local interpolation

    CN106504214A

  • Circulating pump bearing fault detection method and system

    CN113158364A