A Medical Sampling Method and System Based on Prior Constraints and Diffusion Model
By constructing a differentiable medical constraint rule base and diffusion model, combined with gradient-guided sampling technology, the problem of class imbalance in medical data modeling is solved, virtual samples that conform to medical logic are generated, and the predictive performance and data security of the diagnostic model are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG UNIV
- Filing Date
- 2026-04-28
- Publication Date
- 2026-07-03
Smart Images

Figure CN122136023B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of medical data processing technology, and in particular to a medical sampling method and system based on prior constraints and diffusion models. Background Technology
[0002] In recent years, with the vigorous development of artificial intelligence technology and the continuous deepening of deep learning research, smart healthcare, as an important application scenario of artificial intelligence, has undergone major changes and innovations. Today, it is widely used in various fields of medical and health care, such as assisting medical procedures, disease risk assessment, and drug development. It not only provides doctors with crucial decision support, but also brings more accurate and personalized solutions to patients.
[0003] Especially in the clinical screening and prevention of breast cancer, people often use electronic health records (EHRs) or structured clinical tabular data to build risk prediction models. These structured tabular data cover key features such as age, hormone receptor status, tumor markers, and gene mutation information. Compared with unstructured text or image data, their feature dimensions are clear and their logic is rigorous.
[0004] Due to the unique nature of the medical setting, existing risk prediction modeling processes suffer from severe data distribution defects, namely, the problem of "extreme class imbalance." In real-world screening populations, the number of positive samples (those diagnosed with breast cancer) is far less than the number of negative samples from the healthy population. This data skew causes the model to overemphasize the majority class (healthy samples) during training, while neglecting the key features of the minority class (disease samples). This results in extremely low sensitivity of the model in identifying disease samples, easily leading to missed diagnoses. Summary of the Invention
[0005] To address the aforementioned issues, this application proposes a medical sampling method based on prior constraints and a diffusion model, comprising: preprocessing raw medical data and determining training data based on the preprocessed raw data; constraining predetermined medical knowledge according to a predetermined prior constraint rule base to obtain a constraint loss function, thereby determining the gradient guidance corresponding to the raw data based on the constraint loss function; determining an initial diffusion model, injecting pre-set asymmetric noise into the training data, training the initial diffusion model based on the injected training data to obtain a final diffusion model; performing prediction using the diffusion model to determine prediction noise, determining a medical constraint loss based on the prediction noise and the raw data, determining the gradient of the medical constraint loss in the current data state, adding the gradient to a sampling update formula to determine a sampling trajectory based on the sampling update formula, thereby determining samples based on the sampling trajectory; mixing the samples and the raw data to determine an output dataset, validating the dataset, and determining the final dataset based on the validation results.
[0006] In one example, after determining the samples based on the sampling trajectory, the method further includes: determining a distance matrix between the samples and the original data, and determining a pre-set threshold group; performing sample screening based on the threshold group and the distance matrix to identify overfitted samples and outlier samples in the samples; and removing the overfitted samples and the outlier samples to perform subsequent verification based on the remaining samples after removal.
[0007] In one example, preprocessing the raw medical data specifically includes: cleaning the raw data according to a pre-determined structured dataset; normalizing the cleaned raw data; performing vector transformation on the normalized raw data according to one-hot encoding to convert the raw data into vector form; dividing the vector-transformed raw data to determine a training set and a test set, and using the training set and the test set as the training data.
[0008] In one example, predetermined medical knowledge is constrained according to a pre-determined set of prior constraint rules to obtain a constraint function. The gradient guidance corresponding to the original data is then determined based on the constraint function. Specifically, this includes: determining pre-set medical constraint rules; constructing a differentiable constraint loss function based on the medical constraint rules; calculating the feature values corresponding to the original data based on the constraint loss function; determining a pre-set medical reasonable range; comparing the feature values with the medical reasonable range; if the feature values are within the medical reasonable range, the loss corresponding to the feature values is zero, and no gradient is generated; if the feature values are outside the medical reasonable range, the ReLU function is activated, and the generated gradient is determined to guide the optimization direction based on the gradient.
[0009] In one example, pre-set asymmetric noise is injected into the training data, and the initial diffusion model is trained based on the injected training data to obtain the final diffusion model. Specifically, this includes: adding Gaussian noise to the training data to transform the training data into a pure noise state; optimizing a pre-set denoising network so that the denoising network makes predictions based on noisy data and time steps, wherein the diffusion model is formed based on the denoising network, thereby determining the prediction noise through the diffusion model; using mean squared error as the loss function, and optimizing the loss function based on the Gaussian noise and the prediction noise to fit the score function on the data manifold.
[0010] In one example, the method is characterized by making predictions using the diffusion model to determine prediction noise, determining a medical constraint loss based on the prediction noise and the original data, and determining the gradient of the medical constraint loss relative to the current data state. Specifically, this includes: sampling using a Gaussian distribution to obtain initial noise; iteratively denoising the initial noise, wherein multiple time steps are determined, and predictions are made for each time step using the denoising network to obtain corresponding prediction noise; determining predicted data values based on the prediction noise; inputting the predicted data values into the constraint loss function to calculate a loss value based on the constraint loss function; and determining the current gradient based on the loss value.
[0011] In one example, the gradient is added to the sampling update formula to determine the sampling trajectory according to the sampling update formula, and then the sample is determined according to the sampling trajectory. Specifically, this includes: incorporating the gradient as a correction term into a pre-set sampling update formula to determine the sampling trajectory, wherein the sampling trajectory conforms to the region of a pre-set medical constraint rule; and sampling according to the sampling trajectory to obtain the sampled sample.
[0012] In one example, the sample and the original data are mixed to determine the output dataset, which is then validated. The final dataset is determined based on the validation results. Specifically, this includes: performing denormalization and decoding on the removed samples to restore them to tabular data; mixing the tabular data with the original data to determine the output dataset; inputting the output dataset into a pre-defined classifier for validation to obtain a validation metric; inputting the original data into the classifier to obtain the original validation metric; comparing the validation metric with the original validation metric; and outputting the final dataset if the validation metric is greater than the original validation metric.
[0013] In one example, the method further includes: classifying the final dataset according to pre-set medical features to generate statistical charts of various features; displaying the statistical charts using pre-set visualization tools; obtaining feedback based on the visualization content; returning to the data generation step based on the feedback; adjusting the parameters of the prior constraint rule base and diffusion model; and regenerating the dataset.
[0014] On the other hand, this application also proposes a medical sampling system based on prior constraints and a diffusion model, applicable to the method described in any of the above examples. The system includes: a data preprocessing module for constructing a standardized medical dataset to achieve data cleaning and preprocessing; a medical rule base construction module for constructing a medical prior constraint rule base to transform medical expert knowledge into computable mathematical constraints; a diffusion model training module for building a diffusion model training framework to learn the probability distribution of the original data; a gradient-guided sampling module for performing gradient-guided backsampling and injecting medical rules in real time during the generation process; and a quality screening and output module for performing sample screening and privacy protection assessment, outputting a high-quality augmented dataset, and using the augmented dataset to train a downstream machine learning classifier to verify the augmentation effect.
[0015] On the other hand, this application also proposes a medical sampling device based on a priori constraints and diffusion model, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the medical sampling device based on a priori constraints and diffusion model to perform: the method described in any of the examples above.
[0016] On the other hand, this application also proposes a non-volatile computer storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to be the method described in any of the examples above.
[0017] This application, based on diffusion model technology, proposes a solution to the logical conflict problem in small-sample medical data augmentation. Specifically, guided by medical expert knowledge, this application constructs a differentiable rule base and proposes a gradient-guided sampling correction method to address the issue of generated data violating clinical common sense. To improve data security, a distance metric screening mechanism is introduced. Furthermore, based on the above methods, this application can output high-quality virtual patient data that conforms to both statistical distribution and medical logic, effectively solving the problems of medical data scarcity and imbalance. This application can output virtual samples that conform to both statistical distribution and medical logic, effectively solving the diagnostic model bias problem caused by imbalanced medical data, and outputs the results in a standardized balanced dataset format, significantly improving the predictive performance of downstream clinical auxiliary diagnostic models. Attached Figure Description
[0018] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0019] Figure 1 This is a flowchart illustrating a medical sampling method based on a priori constraints and a diffusion model, as described in an embodiment of this application.
[0020] Figure 2 This is a schematic diagram of the medical constraint loss function in an embodiment of this application;
[0021] Figure 3 This is a flowchart illustrating data filtering and downstream applications in the embodiments of this application;
[0022] Figure 4 This is a schematic diagram of a medical sampling device based on a priori constraints and diffusion model in an embodiment of this application. Detailed Implementation
[0023] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0024] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0025] Existing technologies typically employ oversampling algorithms such as SMOTE or Generative Adversarial Networks (GANs) to augment disease samples. The SMOTE algorithm performs simple linear interpolation based solely on existing samples, resulting in samples that lack diversity and are prone to introducing noise. GANs, on the other hand, are highly susceptible to training instability and "pattern collapse" when the sample size is extremely small (i.e., few-shot), leading to uniform generated samples that fail to cover the true distribution of pathological features.
[0026] Especially for diseases like breast cancer with complex pathological mechanisms, there are strict biological logical connections between their clinical features. For example, menopausal status is strongly correlated with age, and the history of hormone therapy is strongly correlated with receptor status. Existing generation methods often only focus on the statistical distribution of data at the data level, ignoring the constraints of prior knowledge in the medical field. This leads to the generation of samples frequently containing "illusionary" data that violates medical common sense, such as generating samples of 30-year-olds who have naturally reached menopause. If such generated data that does not conform to clinical logic is mixed into the training set, it will inevitably mislead the model's feature learning, destroy the potential correlations between features, and thus further interfere with the accuracy and interpretability of breast cancer risk prediction. Therefore, how to generate high-quality samples that are both statistically diverse and conform to medical rigor when there are very few disease samples is a technical challenge that urgently needs to be solved.
[0027] like Figure 1 As shown, in order to solve the above problems, this application provides a medical sampling method based on prior constraints and diffusion models, which is applied to a medical sampling system based on prior constraints and diffusion models. The system includes: a data preprocessing module, a medical rule construction module, a diffusion model training module, a gradient-guided sampling module, and a quality screening and output module.
[0028] In one embodiment, the data preprocessing module is configured to: read the original medical table data, automatically perform missing value imputation, Min-Max normalization, and One-Hot encoding operations according to the feature type, and convert the heterogeneous table data into standardized tensor data suitable for the diffusion model. The input is the original medical table data; the output is the preprocessed standardized training set.
[0029] The medical rule construction module is configured to: receive user-defined medical common sense constraints, such as age ranges and physiological indicator logic, convert them into a ReLU-based differentiable loss function, and provide a gradient calculation interface. Input: medical constraint logic; output: a differentiable medical constraint loss function.
[0030] The diffusion model training module is configured to: add noise to the data using an asymmetric noise scheduling strategy, train a denoising network to fit the noise distribution, and save the trained model parameters. The input is a standardized training set; the output is the trained denoising network model.
[0031] The gradient-guided sampling module is configured to perform a reverse denoising process. In each sampling step, it uses Tweedie estimation to predict the original data, calculates the medical constraint gradient, and uses this gradient to correct the sampling trajectory, generating virtual samples that conform to medical logic. The inputs are random noise and the medical constraint gradient; the output is a preliminarily generated virtual sample set.
[0032] The quality screening and output module is configured to: calculate the distance matrix between generated samples and real samples; remove unqualified samples based on set privacy and distribution thresholds; and decode the final samples in reverse to output a class-balanced augmented dataset. Inputs are: a pre-generated virtual sample set and a real dataset; output is: a high-quality, class-balanced medical augmented dataset.
[0033] The methods include:
[0034] S101. Preprocess the raw medical data and determine the training data based on the preprocessed raw data.
[0035] To construct a standardized medical dataset and achieve an efficient data cleaning and preprocessing workflow, the system first needs to customize and select raw tabular data covering demographic, reproductive physiological, and pathological characteristics based on the needs of medical research scenarios such as breast cancer clinical data analysis. During the data cleaning phase, a differentiated imputation strategy is adopted to address missing values. For categorical features, mode imputation is used to ensure consistent category distribution, while for numerical features, mean imputation is used to maintain the overall statistical properties of the data. For numerical features such as age and tumor size, Min-Max normalization is used to linearly map them to the [-1, 1] interval, ensuring the data range matches the input requirements of subsequent diffusion models. For categorical features such as menopausal status and tumor stage, one-hot encoding is used to convert them into binary vector form to eliminate magnitude differences between categories. Finally, the cleaned data is divided into training and testing sets in an 8:2 ratio and stored uniformly in PyTorch tensor format, providing standardized data support for subsequent model training.
[0036] S102. Constrain the predetermined medical knowledge according to the predetermined prior constraint rule base to obtain the constraint loss function, and then determine the gradient guidance corresponding to the original data according to the constraint loss function.
[0037] Medical prior constraints are a set of rules about the logical relationships between patient characteristics, extracted from clinical medical knowledge, pathological principles, and treatment guidelines.
[0038] To address the issue of synthetic data generated by traditional generative models violating medical common sense, this system example constructs a differentiable medical prior constraint rule base, transforming medical expert knowledge into computable mathematical constraints. Unlike traditional one-size-fits-all rule filtering methods, the system designs a soft-constraint loss function based on the ReLU mechanism. This function provides smooth gradient guidance during the generation process, ensuring the rationality of the generated data. Specifically, core constraint rules are set based on medical common sense. For example, the age of menarche for women is typically between 10 and 16 years old, so its constraint interval is set to [10, 16]; the age of first childbirth for women is typically between 16 and 45 years old, and must be greater than the age of menarche, so its constraint interval is set to [16, 45].
[0039] Construct a differentiable constrained loss function The formula is:
[0040]
[0041] in, This represents the generated i-th eigenvalue, i.e., the actual value after inverse normalization. and These represent the lower and upper limits of the medically reasonable range corresponding to this feature, respectively. These are the weighting coefficients. This function has a significant characteristic: when the generated data... Within a reasonable range Within this range, the loss value is zero and no gradient is generated; however, once the data exceeds this range, the ReLU function will be activated to generate a gradient pointing to the reasonable range, which will then correct the generated data in subsequent sampling steps.
[0042] S103. Determine the initial diffusion model, inject pre-set asymmetric noise into the training data, and train the initial diffusion model based on the injected training data to obtain the final diffusion model.
[0043] Diffusion models are a class of generative models based on Markov chains. Their core principle is to gradually add noise to the data through a forward process, and then gradually recover the data distribution from the noise through a reverse process.
[0044] The training framework of the diffusion model uses the Denoising Diffusion Probability Model (DDPM) as its basic architecture. During the forward diffusion phase, an asymmetric noise scheduling strategy is used to gradually move the data towards the real data. Injecting Gaussian noise into it eventually degenerates it into a pure noise state. Asymmetric noise scheduling refers to applying different noise variances or scheduling functions to different feature columns based on their importance or sparsity when adding noise to data, rather than applying uniform noise to all features.
[0045] The core of this framework's training lies in optimizing the denoising network. This enables it to be based on the current noisy data state. and time step t Accurately predict the added noise value. Loss function. The mean squared error (MSE) is used, and its expression is:
[0046]
[0047] in, The actual Gaussian noise added. This represents the noise predicted by the model. By minimizing this loss, the model learns a score function on the data manifold.
[0048] S104. Predict using the diffusion model to determine the prediction noise, determine the medical constraint loss based on the prediction noise and the original data, determine the gradient of the medical constraint loss in the current data state, add the gradient to the sampling update formula to determine the sampling trajectory based on the sampling update formula, and then determine the sample based on the sampling trajectory.
[0049] Gradient-guided sampling is a method used in the back-generation process of a diffusion model to correct the generation trajectory using the gradient of a medically constrained loss function, ensuring that the generated samples conform to medical common sense. For example... Figure 2 As shown, gradient-guided backsampling is performed, with medical rules injected in real time during the generation process. At each time step of the backsampling process, the sampling trajectory is dynamically corrected using a pre-built medical rule base. Specifically, the initial noise is sampled from a standard Gaussian distribution. Then, noise reduction is achieved through T-step iterations at each time step. t In the range, the value decreases from T to 1. A denoising network is used to predict noise. and in combination with the current state Use the Tweedie formula to estimate the current "clean" data forecast. The Tweedie formula is a statistical method for estimating the mean of raw data from noisy data. This application utilizes it to estimate the "cleanliness" of the data at intermediate time steps in order to calculate the constraint loss. The formula is:
[0050]
[0051] in, For the original data in The proportion of The smaller the value, the less real evidence is available for reconstruction, and the greater the reconstruction error will be. The estimated value... Substitute the medical constraint loss function from above to calculate the loss value. Then calculate the loss relative to the current state. gradient .
[0052] This gradient is used to modify the sampling update formula, pushing the generated samples towards regions that conform to medical rules. The corrected update formula is:
[0053]
[0054] in, The mean of the model predictions. This refers to the guidance scale. It is random noise. It is with time step t The relevant noise scaling coefficient, a parameter that decreases over time, initially has a larger value, quickly limiting the generated data to the required range. As training progresses and the generated data almost entirely stabilizes within the specified range, this parameter becomes very small, allowing for minor differences between the generated data. In this way, the model is forced to meet medical logic, such as "menarche age between 10 and 16 years old," while generating data, thus avoiding generating illogical samples such as "menarche at age 5" or "first childbirth at age 60."
[0055] S105. Mix the sample and the original data to determine the output dataset, verify the dataset, and determine the final dataset based on the verification results.
[0056] In one embodiment, such as Figure 3As shown, although the above process has significantly improved the logical rationality of the generated data, a post-processing screening mechanism is needed to ensure that the data meets both absolute security and high-quality standards. First, the distance matrix between all generated samples and the original training samples is calculated to assess data reliability by quantifying spatial distribution relationships. Second, a dual screening strategy is implemented: on the one hand, overfitting samples with privacy risks are eliminated, i.e., when the Euclidean distance between a generated sample and any real sample is below a preset threshold... When a sample is identified as a model memorizing real patient data, it is removed. On the other hand, outlier samples that deviate from the true distribution are removed; specifically, when the average distance between a generated sample and all real samples exceeds a threshold... When an outlier is detected, it is considered an outlier and removed. Finally, the high-quality synthetic data after filtering is mixed with the original minority class samples in a certain proportion to construct an augmented dataset with a balanced class distribution. This not only ensures the privacy and security of medical data but also improves the generalization ability of model training.
[0057] In one embodiment, to verify the data augmentation effect, the generated augmented dataset is fed into a downstream machine learning classifier for evaluation, such as XGBoost or Random Forest, for comparative experiments. The results show that the classifier trained with the augmented data exhibits a significant advantage on the test set, with its AUC and F1-score being significantly higher than the model trained only with the original data, and also outperforming the results of traditional oversampling methods such as SMOTE. Especially in association analysis tasks involving reproductive physiological characteristics, the strict adherence to medical prior rules during the generation process effectively avoids the model learning spurious feature associations that violate clinical common sense, thus ensuring the interpretability and reliability of the classification model in clinical auxiliary diagnostic scenarios.
[0058] In one embodiment, the medical data processing and analysis workflow first requires meticulously classifying the final dataset based on pre-defined medical features. These features encompass multiple dimensions, such as disease type and symptom severity, to ensure accurate and comprehensive classification. After classification, professional statistical methods are used to deeply analyze the various feature data, generating diverse statistical charts such as bar charts, line charts, and pie charts. These charts present data features intuitively, such as the distribution of different disease types across age groups and the correlation between symptom severity and treatment effectiveness. Subsequently, pre-defined visualization tools, such as professional medical data analysis software or customized visualization platforms, are used to clearly display the statistical charts. During the presentation, experts, researchers, and practitioners in the medical field are invited to review and evaluate the data, collecting feedback based on their professional knowledge and practical experience. Based on this feedback, the system automatically returns to the data generation step. At this point, the prior constraint rule base is specifically adjusted to optimize the standards and specifications for data generation; simultaneously, the parameters of the diffusion model are fine-tuned to change the way and characteristics of data generation. After these adjustments, the dataset is regenerated, initiating a new cycle of data processing and analysis, thereby continuously improving data quality and the accuracy of analysis results, and providing stronger support for medical research and practice.
[0059] like Figure 4 As shown in the illustration, this application also provides a medical sampling device based on a priori constraints and diffusion model, comprising:
[0060] At least one processor; and,
[0061] A memory that is communicatively connected to at least one processor; wherein,
[0062] The memory stores instructions that can be executed by at least one processor to enable a medical sampling device based on a priori constraints and diffusion models to perform the method as described in any of the embodiments above.
[0063] This application also provides a non-volatile computer storage medium storing computer-executable instructions, which are configured as described in any of the above embodiments.
[0064] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must also be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0065] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0066] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0067] For ease of description, the above devices are described in terms of function, divided into various units. Of course, in implementing this specification, the functions of each unit can be implemented in one or more software and / or hardware components.
[0068] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the device and medium embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the description of the method embodiments.
[0069] The devices and media provided in this application are one-to-one with the methods. Therefore, the devices and media also have similar beneficial technical effects as their corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be repeated here.
[0070] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0071] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0072] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0073] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0074] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0075] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0076] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0077] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0078] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A medical sampling method based on a priori constraints and diffusion model, characterized in that, include: The raw medical data is preprocessed, and training data is determined based on the preprocessed raw data. The predetermined medical knowledge is constrained according to a predetermined set of prior constraint rules to obtain a constraint loss function, and then the gradient guidance corresponding to the original data is determined according to the constraint loss function. Determine pre-set medical constraint rules, construct a differentiable constraint loss function based on the medical constraint rules, and calculate the feature values corresponding to the original data based on the constraint loss function; Determine a pre-set medically reasonable range, and compare the feature value with the medically reasonable range; If the feature value is within the reasonable range of medical conditions, then the loss corresponding to the feature value is zero and no gradient is generated; If the eigenvalue is outside the medically reasonable range, the ReLU function is activated, and the resulting gradient is determined to guide the optimization direction based on the gradient. An initial diffusion model is determined, and pre-set asymmetric noise is injected into the training data. The initial diffusion model is then trained based on the injected training data to obtain the final diffusion model. Prediction is performed using the diffusion model to determine prediction noise. Medical constraint loss is determined based on the prediction noise and the original data. The gradient of the medical constraint loss in the current data state is determined. The gradient is added to the sampling update formula to determine the sampling trajectory based on the sampling update formula, thereby determining the sample based on the sampling trajectory. The sample and the original data are mixed to determine the output dataset, which is then validated, and the final dataset is determined based on the validation results.
2. The method of claim 1, wherein, After determining the sample based on the sampling trajectory, the method further includes: Determine the distance matrix between the sample and the original data, and determine a pre-set threshold group; Samples are filtered based on the threshold group and the distance matrix to identify overfitted samples and outliers in the samples. The overfitted samples and outlier samples are removed so that subsequent verification can be performed based on the remaining samples.
3. The method according to claim 1, characterized in that, Preprocessing of raw medical data includes: The original data is cleaned based on a pre-determined structured dataset, and then normalized. The normalized raw data is vectorized according to one-hot encoding to convert the raw data into vector form; The original data after vector transformation is divided to determine the training set and the test set, and the training set and the test set are used as the training data.
4. The method according to claim 1, characterized in that, Pre-set asymmetric noise is injected into the training data, and the initial diffusion model is trained based on the injected training data to obtain the final diffusion model, specifically including: Gaussian noise is added to the training data to transform it into a pure noise state; The pre-set denoising network is optimized so that it makes predictions based on noisy data and time steps, wherein the diffusion model is formed according to the denoising network, and the predicted noise is determined by the diffusion model. The mean squared error is used as the loss function, and the loss function is optimized based on the Gaussian noise and the prediction noise to fit the score function on the data manifold.
5. The method according to claim 4, characterized in that, Prediction is performed using the diffusion model to determine prediction noise. Based on the prediction noise and the original data, a medical constraint loss is determined. The gradient of the medical constraint loss relative to the current data state is then determined, specifically including: A Gaussian distribution is used for sampling to obtain initial noise. The initial noise is then iteratively denoised. Multiple time steps are determined, and the denoising network is used to predict the corresponding predicted noise for each time step. The predicted data value is determined based on the predicted noise, and the predicted data value is substituted into the constraint loss function to calculate the loss value based on the constraint loss function. The current gradient is then determined based on the loss value.
6. The method according to claim 5, characterized in that, The gradient is added to the sampling update formula to determine the sampling trajectory according to the sampling update formula, and then the sample is determined according to the sampling trajectory. Specifically, this includes: The gradient is included as a correction term in a pre-set sampling update formula to determine the sampling trajectory, wherein the sampling trajectory conforms to the region of a pre-set medical constraint rule; Sampling is performed according to the sampling trajectory to obtain the sampled data.
7. The method according to claim 2, characterized in that, The sample and the original data are mixed to determine the output dataset, which is then validated. The final dataset is determined based on the validation results. Specifically, this includes: The removed samples are subjected to inverse normalization and decoding to restore them to tabular data, and the tabular data is mixed with the original data to determine the output dataset. The output dataset is input into a pre-determined classifier for validation to obtain a result validation metric. The original data is input into the classifier to obtain the original validation index corresponding to the original data, and the result validation index is compared with the original validation index. If the result validation metric is greater than the original validation metric, then the final dataset is output.
8. The method according to claim 1, characterized in that, The method further includes: The final dataset is classified according to pre-set medical features to generate statistical charts for each feature, and the statistical charts are displayed using pre-set visualization tools. Based on the visualization, feedback is obtained, and the process returns to the data generation step to adjust the parameters of the prior constraint rule base and diffusion model, and then the dataset is regenerated.
9. A medical sampling system based on prior constraints and a diffusion model, characterized in that, The system, applicable to the method of any one of claims 1-8, comprises: The data preprocessing module is used to construct standardized medical datasets and to perform data cleaning and preprocessing. The medical rule base construction module is used to build a medical prior constraint rule base, which transforms medical expert knowledge into computable mathematical constraints. The diffusion model training module is used to build a diffusion model training framework and learn the probability distribution of the original data. The gradient-guided sampling module is used to perform gradient-guided backsampling and inject medical rules in real time during the generation process; The quality screening and output module is used to screen samples and assess privacy protection, outputting a high-quality augmented dataset. The augmented dataset is then used to train downstream machine learning classifiers and verify the augmentation effect.