Multi-source data adaptive sampling method and device
By introducing a performance feedback mechanism and multi-armed slot machine modeling in cross-domain learning, and using first-order gradient approximation to estimate the contribution of the source domain, and dynamically selecting data sources, the problems of data dependence and high computational overhead in existing technologies are solved, and the efficient, stable adaptation and generalization performance of the model are improved under a limited budget.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-22
- Publication Date
- 2026-03-31
AI Technical Summary
Existing technologies in cross-domain learning suffer from problems such as reliance on a complete data pool, high computational overhead, lack of target domain performance feedback, and insufficient adaptability, making it difficult to improve model generalization performance in situations with limited data budgets or dynamic environments.
By introducing a performance feedback mechanism and multi-armed slot machine modeling, the first-order gradient approximation method is used to estimate the contribution of the source domain. The exponential weighted moving average update sampling strategy is used to dynamically select the data source that contributes the most to the performance of the target domain for training.
It achieves efficient, stable, and interpretable multi-source data selection and domain adaptation under a limited sampling budget, improves the model's generalization performance in the target domain, and reduces computation and storage costs. It is suitable for scenarios such as socio-economic forecasting, traffic flow forecasting, and healthcare analysis.
Smart Images

Figure CN121765376A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of machine learning and data processing, and specifically relates to a multi-source data adaptive sampling method and device, which can be applied to various scenarios such as traffic flow prediction, medical and health analysis, and natural language processing. Background Technology
[0002] With the widespread application of machine learning and deep learning, the generalization ability of models in cross-domain tasks has gradually become a research focus. In real-world scenarios, there are often distributional differences between training data and the target application environment, a phenomenon known as distribution shift, which can lead to a significant performance degradation of the model in the target domain. Taking a cross-hospital lung CT nodule-assisted diagnostic model as an example, a research team trained an automatic lung nodule detection model using chest CT data from Hospital A. Hospital A had relatively fixed CT scanner brands, imaging protocols (slice thickness, reconstruction kernel, dosage), patient demographics, and annotation habits, resulting in excellent model performance in Hospital A tests. However, when the model was deployed to Hospital B, which used equipment from different manufacturers and with different scanning parameters, and also had different patient demographics (age, proportion of underlying diseases), the image contrast, noise texture, and resolution distribution were significantly different from those in Hospital A. This is the distributional difference between the training domain and the target domain. As a result, the model experienced performance degradation in Hospital B, including increased false negatives / false positives and decreased sensitivity, directly impacting clinical usability and safety. This example illustrates that, under the same task, a model can significantly deteriorate in the target domain simply because of changes in data distribution. Therefore, cross-domain learning / domain adaptation is needed to improve the reliability and scalability of cross-hospital deployments.
[0003] To address this issue, academia has proposed various cross-domain learning methods. Existing technologies mainly fall into two categories:
[0004] Domain adaptation methods improve target domain performance by reducing the distributional differences between the source and target domains. These methods typically rely on mechanisms such as domain alignment, feature transformation, or adversarial training. However, they usually require large amounts of labeled data, have high computational complexity, and are difficult to implement when target domain labels are missing or data is limited. Multi-source domain adaptation methods utilize data from multiple source domains to enhance the model's generalization ability. A common approach is to weighted combine or align different source domains to improve the model's performance in the target domain. However, these methods often depend on access to the entire data pool, making them difficult to apply in environments where data acquisition is budget-constrained or dynamically changing.
[0005] To reduce annotation costs, active learning and data sampling methods have been proposed. These methods improve model performance by selecting the most valuable samples. However, traditional active learning often assumes access to the entire candidate sample pool, which doesn't align with many real-world applications (such as distributed data sources and streaming data). Furthermore, these methods are computationally expensive and difficult to apply in real-time. Recent research has also attempted to model sampling as a multi-armed slot machine problem, striking a balance between exploration and exploitation. These methods can cope with dynamic environments to some extent, but most lack direct metrics for performance in the target domain, making it difficult to guarantee that the sampled data truly improves generalization within that domain.
[0006] In summary, existing technologies still have the following shortcomings in solving the problem of multi-source data sampling and domain adaptation:
[0007] 1) It relies on accessing the entire data pool, making it difficult to apply in environments with limited data budgets or dynamic settings;
[0008] 2) The contribution estimation method is complex, resulting in high computational cost and making it difficult to meet the efficiency requirements;
[0009] 3) The lack of an adaptive mechanism based on target domain performance feedback may cause the sampling strategy to get stuck in local optima;
[0010] 4) Insufficient adaptability to real-world application scenarios (such as socio-economic forecasting, traffic forecasting, and healthcare).
[0011] Therefore, there is an urgent need for a multi-source data adaptive sampling method that can dynamically adjust the strategy based on the target domain performance feedback under a limited sampling budget, so as to effectively improve the generalization performance of the model in the target domain. Summary of the Invention
[0012] The purpose of this invention is to overcome the shortcomings of existing technologies and propose a multi-source data adaptive sampling method and apparatus. By introducing a performance feedback mechanism and multi-armed slot machine modeling, this invention can achieve efficient, stable, and interpretable multi-source data selection and domain adaptation under conditions of limited data and dynamic environmental changes, demonstrating significant practical value.
[0013] A first aspect of this invention proposes a multi-source data adaptive sampling method, comprising:
[0014] Based on the target domain model, a target domain validation set and training sets for multiple source domains are constructed respectively.
[0015] After sampling begins, a round of sampling is performed on the training set of each source domain, and the target domain model is trained using the training samples obtained after each round of sampling.
[0016] After one round of sampling is completed in the training set of each source domain, starting from the next sampling round, the source domains participating in the current sampling round are selected based on the historical contribution of each source domain to the training of the target domain model. Then, training samples are sampled from the selected source domains and the target domain model is trained. When the training of the target domain model reaches the preset termination condition, the sampling is completed.
[0017] In one specific embodiment of the present invention, it further includes:
[0018] Let K be the number of source domains. By sampling the training set of K source domains for K rounds, the target domain model completes K rounds of training. Starting from the (K+1)th round of sampling, let t be the current sampling round.
[0019] Before the current sampling round begins, calculate the contribution of each source domain to the training of the target domain model, as shown in the following expression:
[0020]
[0021] in, This represents a sample taken from the training set of the source domain. This represents the approximate contribution of training samples taken from the training set in the source domain to the training of the model in the target domain; This represents the validation samples obtained from the target domain validation set; This represents the gradient operator of the target domain model loss function with respect to the model parameters; This represents the loss gradient of the target domain model on the target domain validation samples; This indicates that the target domain model uses training samples from the source domain. The amount of parameter change that occurs when the model undergoes a single parameter update; Indicates the training samples in the source domain The mathematical expectation.
[0022] In one specific embodiment of the present invention, it further includes:
[0023] When the target domain model is trained using a stochastic gradient descent optimizer, ,in This indicates that the model is trained on samples in the source domain. loss gradient on, Update the step size for the parameters.
[0024] In one specific embodiment of the present invention, it further includes:
[0025] When the target domain model is trained using the Adam optimizer,
[0026]
[0027] in, and These represent the first and second moment estimates of the historical gradient, respectively. and The exponential decay coefficient is... For numerically stable terms, This represents the baseline step size coefficient in the adaptive optimization algorithm; and They represent the first time. In the next iteration, the exponential decay factors of the first and second moments are... Power of 1.
[0028] In one specific embodiment of the present invention, it further includes:
[0029] Based on the contribution of each source domain to the training of the target domain model, the source domain to be sampled in the current sampling round is determined by calculating the upper bound of the contribution of each source domain. The specific steps are as follows:
[0030] 1) Calculate the upper bound of the contribution confidence of each source domain in the current sampling round;
[0031] Among them, any source domain In the The expression for calculating the upper bound of the contribution confidence during round sampling is:
[0032]
[0033] in, Represents the source domain in front Based on historical approximate contribution in the round Contribution estimate obtained through exponentially weighted moving average; Represents the source domain in front The cumulative number of times samples were taken during the round; The exploration coefficient is used to adjust the degree of exploration of the source domain with low sampling times, and is a positive real number. Regarding the rounds The logarithmic term;
[0034] in,
[0035]
[0036] in, Indicates the first Round sampling from the source domain The approximate contribution of the training samples sampled from the training set to the training of the target domain model; Index for historical rounds; This is the exponential decay coefficient, used to control the degree to which historical contribution information is retained. ;
[0037] 2) Select the source domain corresponding to the maximum value of the upper bound of the contribution confidence from the results of step 1) as the source domain to be sampled in the current sampling round;
[0038] If the result of step 1) contains multiple source domains corresponding to the maximum upper bound of the contribution confidence, then one source domain is randomly selected from all the source domains corresponding to the maximum upper bound of the contribution confidence as the source domain to be sampled in the current sampling round.
[0039] A second aspect of the present invention provides a multi-source data adaptive sampling device, comprising:
[0040] The target domain validation set and source domain training set construction module is used to construct the target domain validation set and multiple source domain training sets based on the target domain model.
[0041] The initial sampling module is used to perform one round of sampling on the training set of each source domain after the sampling begins, and to train the target domain model using the training samples obtained after each round of sampling;
[0042] An adaptive sampling module is used to select source domains to participate in the current sampling round based on the historical contribution of each source domain to the training of the target domain model, after completing one round of sampling in the training set of each source domain. Then, training samples are sampled from the selected source domains and the target domain model is trained. Sampling is completed when the training of the target domain model reaches the preset termination condition.
[0043] In one specific embodiment of the present invention, it further includes:
[0044] Let K be the number of source domains. By sampling the training set of K source domains for K rounds, the target domain model completes K rounds of training. Starting from the (K+1)th round of sampling, let t be the current sampling round.
[0045] Before the current sampling round begins, calculate the contribution of each source domain to the training of the target domain model, as shown in the following expression:
[0046]
[0047] in, This represents a sample taken from the training set of the source domain. This represents the approximate contribution of training samples taken from the training set in the source domain to the training of the model in the target domain; This represents the validation samples obtained from the target domain validation set; This represents the gradient operator of the target domain model loss function with respect to the model parameters; This represents the loss gradient of the target domain model on the target domain validation samples; This indicates that the target domain model uses training samples from the source domain. The amount of parameter change that occurs when the model undergoes a single parameter update; Indicates the training samples in the source domain The mathematical expectation.
[0048] In one specific embodiment of the present invention, it further includes:
[0049] When the target domain model is trained using a stochastic gradient descent optimizer, ,in This indicates that the model is trained on samples in the source domain. loss gradient on, Update the step size for the parameters.
[0050] In one specific embodiment of the present invention, it further includes:
[0051] When the target domain model is trained using the Adam optimizer,
[0052]
[0053] in, and These represent the first and second moment estimates of the historical gradient, respectively. and The exponential decay coefficient is... For numerically stable terms, This represents the baseline step size coefficient in the adaptive optimization algorithm; and They represent the first time. In the next iteration, the exponential decay factors of the first and second moments are... Power of 1.
[0054] In one specific embodiment of the present invention, it further includes:
[0055] Based on the contribution of each source domain to the training of the target domain model, the source domain to be sampled in the current sampling round is determined by calculating the upper bound of the contribution of each source domain. The specific steps are as follows:
[0056] 1) Calculate the upper bound of the contribution confidence of each source domain in the current sampling round;
[0057] Among them, any source domain In the The expression for calculating the upper bound of the contribution confidence during round sampling is:
[0058]
[0059] in, Represents the source domain in front Based on historical approximate contribution in the round Contribution estimate obtained through exponentially weighted moving average; Represents the source domain in front The cumulative number of times samples were taken during the round; The exploration coefficient is used to adjust the degree of exploration of the source domain with low sampling times, and is a positive real number. Regarding the rounds The logarithmic term;
[0060] in,
[0061]
[0062] in, Indicates the first Round sampling from the source domain The approximate contribution of the training samples sampled from the training set to the training of the target domain model; Index for historical rounds; This is the exponential decay coefficient, used to control the degree to which historical contribution information is retained. ;
[0063] 2) Select the source domain corresponding to the maximum value of the upper bound of the contribution confidence from the results of step 1) as the source domain to be sampled in the current sampling round;
[0064] If the result of step 1) contains multiple source domains corresponding to the maximum upper bound of the contribution confidence, then one source domain is randomly selected from all the source domains corresponding to the maximum upper bound of the contribution confidence as the source domain to be sampled in the current sampling round.
[0065] A third aspect of the present invention provides an electronic device comprising:
[0066] At least one processor; and a memory communicatively connected to said at least one processor;
[0067] The memory stores instructions that can be executed by the at least one processor, and the instructions are configured to execute the aforementioned multi-source data adaptive sampling method.
[0068] A fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions for causing the computer to execute the aforementioned multi-source data adaptive sampling method.
[0069] The features and beneficial effects of this invention are as follows:
[0070] 1) No need to access the complete data pool: This invention improves model performance by selecting key samples within the budget to train the target domain model through online sampling and performance feedback mechanism, thereby reducing computation and storage costs.
[0071] 2) High efficiency in contribution estimation: This invention uses the first-order gradient approximation method to evaluate contribution, avoiding complex high-order calculations and greatly improving sampling efficiency.
[0072] 3) Strong dynamic adaptability: This invention integrates historical information through an exponential weighting mechanism, enabling the sampling strategy to adapt to the dynamic changes of the target domain model and avoid instability caused by short-term fluctuations.
[0073] 4) Wide Applicability: This invention can be applied to various scenarios such as socioeconomic forecasting, traffic flow prediction, medical and health analysis, and natural language processing, and has strong promotional value. In the field of medical and health analysis (such as cross-hospital disease risk prediction or medical image-assisted diagnosis), the data distribution of various medical institutions varies greatly, and the cost of data access and annotation is high. This invention does not require centralized acquisition of complete data pools from all hospitals. Instead, it prioritizes the data sources that most significantly improve the target diagnostic performance within a limited sampling budget through online sampling and target hospital performance feedback. At the same time, the efficient contribution estimation based on the first-order gradient approximation avoids complex calculations and significantly reduces training and deployment costs. The exponentially weighted dynamic update mechanism enables the sampling strategy to stably adapt to changes in the population structure or equipment conditions of different hospitals, achieving near-optimal data selection under the guarantee of theoretical regret limits, thereby improving the generalization and reliability of the model in real clinical scenarios. In the field of traffic flow prediction (such as cross-city traffic state prediction), different cities differ significantly in road network structure, travel patterns, and sensor distribution, and traffic states have obvious time-varying characteristics. This invention dynamically selects the most valuable historical and external city data for target city prediction within a limited budget, avoiding the introduction of redundant information. Its exponential weighting mechanism smooths out the noise impact of short-term traffic fluctuations, ensuring the stability and responsiveness of the sampling strategy. Combined with theoretical performance guarantees, this method continuously approaches the optimal cross-domain data utilization strategy under resource-constrained conditions, significantly improving the accuracy and robustness of cross-regional traffic prediction.
[0074] In summary, this invention not only effectively improves the generalization performance of the model in the target domain, but also features high efficiency, robustness, and ease of expansion. Attached Figure Description
[0075] Figure 1 This is an overall flowchart of a multi-source data adaptive sampling method according to an embodiment of the present invention. Detailed Implementation
[0076] This invention proposes a multi-source data adaptive sampling method and apparatus, which will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0077] A first aspect of this invention proposes a multi-source data adaptive sampling method, comprising:
[0078] Based on the target domain model, a target domain validation set and training sets for multiple source domains are constructed respectively.
[0079] After sampling begins, a round of sampling is performed on the training set of each source domain, and the target domain model is trained using the training samples obtained after each round of sampling.
[0080] After one round of sampling is completed in the training set of each source domain, starting from the next sampling round, the source domains participating in the current sampling round are selected based on the historical contribution of each source domain to the training of the target domain model. Then, training samples are sampled from the selected source domains and the target domain model is trained. When the training of the target domain model reaches the preset termination condition, the sampling is completed.
[0081] In a specific embodiment of the present invention, the overall process of the multi-source data adaptive sampling method is as follows: Figure 1 As shown, it includes the following steps:
[0082] 1) Construct a target domain validation set based on the target domain model.
[0083] In this embodiment, for the target domain model, a target domain validation set consisting of target domain samples is first constructed. After each sampling and model update, the model's performance is evaluated on this validation set, such as classification accuracy, mean squared error, or other task-related metrics, to guide subsequent sampling decisions. Experiments show that for general tabular data prediction tasks, a target domain validation set consisting of 5 to 50 target domain samples can achieve good sampling results.
[0084] 2) Obtain training sets from multiple source domains that can be used to train the target domain model.
[0085] In this embodiment, there are K different source domains. [K], where This represents the number of source domains available. To ensure the effectiveness and statistical stability of multi-source selection, The value typically ranges from 2 to 100. This is relevant in most engineering applications (such as cross-hospital / cross-city / cross-equipment scenarios). Common values range from 5 to 50, and each source domain should contain at least a minimum number of usable samples (e.g., no less than one batch or several samples) to support stable sampling and model updates. For each source domain, the available training sample data is used to form the training set for that source domain.
[0086] In this embodiment, the sampling process is modeled as a multi-armed slot machine problem (a sequential decision-making problem involving iterative selection from multiple candidate options and progressively favoring the option with higher payoff based on feedback under a limited trial / sampling budget), where each source domain is considered a sampling arm. In each round of sampling, this embodiment selects one sampling arm from among the multiple sampling arms, and then collects training samples from that sampling arm for updating the current model.
[0087] 3) Perform a round of sampling on the training set of each source domain obtained in step 2), and use the sampled training samples to train the target domain model after each round of sampling.
[0088] In this embodiment, the target domain model completes K rounds of training by sampling the training sets of K different source domains. In each of these K rounds of sampling, a source domain that has not previously participated in the target domain model training is selected, and a set of training samples is randomly sampled from the training set of that source domain using a fixed sampling quantity B. B is a pre-defined batch size, typically an integer between 4 and 1024. In this embodiment, the sampling quantity B remains consistent across different rounds to ensure the comparability and stability of the contributions of different source domains to the target domain model training.
[0089] After K rounds of training of the target domain model are completed, proceed to step 4).
[0090] 4) Starting from the K+1th round of sampling, let the current sampling round be t.
[0091] 5) Before the current sampling round begins, calculate the contribution of each source domain to the training of the target domain model.
[0092] In this embodiment, the true performance contribution of each source domain to the target domain model training can be quantified as: the expected decrease in the target domain loss function after training samples z sampled from that source domain are used to train the target domain model. Formally, this contribution can be defined as... ,in, ⋅ This represents the expected loss of the target domain model on the target domain validation set. These are the current model parameters. To use training samples sampled from the source domain Updated model parameters. This represents the validation set from the target domain, used to evaluate the expected loss of the model in the target application environment and as a basis for performance feedback.
[0093] Since directly calculating the expected loss is computationally intensive, the method described in this embodiment approximates the contribution to the true performance in two ways. Firstly, a validation set independently and identically distributed from the target domain is used as a representative of the target domain, and the loss on the validation set is used as an empirical estimate of the loss over the entire target domain. Secondly, this invention employs a first-order gradient approximation to calculate the impact of the source domain training samples on the target domain validation loss. (Source domain training samples) The contribution can be approximated by the similarity between its gradient direction and the gradient direction of the target domain validation set. The final approximate solution for the contribution is as follows:
[0094]
[0095] in, This represents the approximate contribution of training samples taken from the training set in the source domain to the training of the model in the target domain; This represents the validation samples obtained from the target domain validation set; This represents the gradient operator of the target domain model loss function with respect to the model parameters; This represents the loss gradient of the target domain model on the target domain validation samples; This indicates that the target domain model uses training samples from the source domain. The amount of parameter change that occurs when the model undergoes a single parameter update. Indicates the training samples in the source domain The mathematical expectation is the average of the gradient-parameter update inner product caused by different source domain samples under the source domain sample distribution, which is used to characterize the expected contribution of the overall source domain samples to the target domain validation performance.
[0096] The parameter update amount This can be determined based on the specific optimizer used. For example:
[0097] When using the stochastic gradient descent (SGD) optimizer, ,in This indicates that the model is trained on samples in the source domain. loss gradient on, Update the step size for the parameters.
[0098] When using the Adam optimizer , and These represent the first and second moment estimates of the historical gradient, respectively. and The exponential decay coefficient is... It is a numerically stable term; This represents the baseline step size coefficient in the adaptive optimization algorithm, used to scale the overall parameter update magnitude. and They represent the first time. In the next iteration, the exponential decay factors of the first and second moments are... The power is used to perform bias correction on the moment estimate to eliminate the influence of zero-value bias during the initialization phase on parameter updates.
[0099] 6) Based on the results of step 5), determine the source domains to be sampled in the current sampling round by calculating the upper bound of the contribution confidence of each source domain.
[0100] In this embodiment, after obtaining the contribution estimates of different source domains, the sampling probability is updated using the upper confidence bound (UCB) strategy. This strategy selects high-contribution source domains while also retaining a certain probability to explore other source domains, thereby achieving a balance between "utilization" and "exploration" and avoiding getting trapped in local optima. The specific steps are as follows:
[0101] 6-1) Calculate the upper bound of the contribution confidence of each source domain in the current sampling round.
[0102] In this embodiment, any source domain In the The expression for calculating the upper bound of the contribution confidence during round sampling is:
[0103]
[0104] in, Represents the source domain in front Based on historical approximate contribution in the round Contribution estimate obtained through exponentially weighted moving average; Represents the source domain in front The cumulative number of times samples were taken during the round; The exploration coefficient is used to adjust the degree of exploration of the source domain with low sampling times. Its value is a positive real number, usually ranging from 0.1 to 5. In most applications, it can be set to 0.5 to 2 to achieve a balance between exploration and stability. Regarding the rounds The logarithmic term is used to characterize the decay of uncertainty as the number of sampling rounds increases.
[0105] In this embodiment, an exponentially weighted moving average method is used to fuse historical contribution information to improve robustness and stability in dynamic environments. Specifically, the source domain... In the Estimated contribution of the wheel The calculation method is as follows:
[0106]
[0107] in, Indicates the first Round sampling from the source domain The approximate contribution of the training samples sampled from the training set to the training of the target domain model; Index for historical rounds; Indicates the current sampling round; The exponential decay coefficient is used to control the degree to which historical contribution information is retained, and its value satisfies the following conditions: .when Taking a larger value gives higher weight to historical information, which is beneficial for improving the stability of the estimation; when Taking a smaller value gives a greater weight to recent contributions, which is beneficial for quickly adapting to changes in the target domain distribution. In practical applications, It can be dynamically set according to the target environment, and the value range is usually 0.8 to 0.99.
[0108] 6-2) Based on the results of step 6-1), select the source domain to be sampled in the current sampling round.
[0109] In this embodiment, based on the results of step 6-1), during specific sampling, the source domain corresponding to the maximum value of the upper bound of the contribution confidence is selected as the source domain to be sampled in the current sampling round. The selection rule is expressed as follows: If the result of step 6-1) contains multiple source domains corresponding to the maximum value of the upper bound of the contribution confidence, then in this embodiment, a random selection method can be used to randomly select one source domain from all the source domains corresponding to the maximum value of the upper bound of the contribution confidence for sampling.
[0110] It should be noted that, under the condition of a limited sampling budget, this embodiment continuously corrects the sampling decision through target domain performance feedback. When the model's performance metrics (such as loss function value or prediction accuracy) on the target domain validation set are lower than a preset performance threshold, the system automatically increases the exploration intensity. The performance threshold is a reference value preset according to the specific application scenario, used to characterize the minimum acceptable performance level of the model in the target domain. This threshold can be the historical average performance of the target domain, the initial model performance, or a manually set empirical threshold. The automatic increase in exploration intensity is reflected in the calculation of the upper bound of contribution confidence and the selection of the source domain in step 6-1): when the target domain performance does not reach the threshold, the uncertainty compensation term in the upper bound of contribution confidence is used... The function of this method is to give source domains with fewer historical sampling times and insufficient contribution estimates a larger confidence upper bound, thus prioritizing their selection during the source domain selection process in step 6-2), thereby enabling proactive exploration of potential high-value source domains; when the target domain performance steadily improves during training and exceeds the threshold, the contribution estimate value... With the increased dominance of the upper confidence bound, sampling strategies will be more inclined to source domains with verified high contributions, thereby increasing the utilization of effective source domains.
[0111] 7) Randomly sample B training samples from the source domain selected in step 6), and then train the current target domain model to obtain the updated current target domain model.
[0112] 8) Set the current sampling round to t=t+1, and then return to step 5) to perform the next round of sampling.
[0113] In this embodiment, the model's performance in the target domain gradually improves as training iterations proceed. When a preset training termination condition is reached (e.g., the upper limit of training epochs), the target domain model training ends, and the final parameters of the trained model are output. The final trained target domain model can be directly applied to actual prediction tasks.
[0114] The method described in this embodiment will be further explained in detail below, taking into account a specific implementation of an early warning system for sepsis using electronic medical records across hospitals.
[0115] In this embodiment, the multi-source data adaptive sampling method includes the following steps:
[0116] 1) Construct a target domain validation set based on the target domain model.
[0117] In this embodiment, the target domain The distribution of EHR (Electronic Health Record) data for Hospital H0 (the hospital to be deployed) differs from that of other hospitals (e.g., population structure, frequency of laboratory tests, medication routes, etc.). From Independently and identically distributed sample of a target domain validation set (For example, including several confirmed sepsis / non-sepsis cases) for performance feedback and contribution estimation.
[0118] 2) Obtain training sets from multiple source domains that can be used to train the target domain model.
[0119] In this embodiment, the source domain set The data are historical EHR data from 10 other hospitals (H1…H10), with each source domain corresponding to a “sampleable data source / training sample pool”.
[0120] In this embodiment, due to the high costs of cross-departmental data retrieval, desensitization, annotation, and transmission, the total budget is set to be... Round sampling.
[0121] 3) Perform a round of sampling on the training set of each source domain obtained in step 2), and use the sampled training samples to train the target domain model after each round of sampling.
[0122] In this embodiment, the parameters of the sepsis early warning model are initialized before sampling begins. (This model uses a multilayer perceptron model, MLP).
[0123] Setting hyperparameters: exploration coefficient Exponential decay coefficient Learning rate The number of samples per round is B=8.
[0124] For each source hospital Initialize the count Initial contribution estimation .
[0125] In this embodiment, the target domain model completes 10 rounds of training by sequentially sampling the training sets of 10 different source domains. In each of the 10 rounds of sampling, a source domain that has not participated in the training of the target domain model is selected, and a set of training samples is randomly sampled from the training set of the source domain according to the set sampling number (8 samples in this embodiment) for the model training of the current round.
[0126] After 10 rounds of training on the target domain model, proceed to step 4.
[0127] 4) Starting from the 11th round of training of the target domain model, let the current sampling round be t.
[0128] 5) Before the current sampling round begins, calculate the contribution of each source domain to the training of the target domain model.
[0129] ,
[0130] in, This represents the approximate contribution of training samples taken from the training set in the source domain to the training of the model in the target domain; This represents the validation samples obtained from the target domain validation set; This represents the gradient operator of the model loss function with respect to the model parameters; This represents the loss gradient of the model on the target domain validation samples. In this embodiment, it represents "the parameter update direction that improves the prediction performance of the model on the target hospital H0". This indicates that the model uses training samples from the source domain. The amount of parameter change that occurs when a parameter update is performed. Indicates the training samples in the source domain The mathematical expectation.
[0131] 6) Based on the results of step 5), determine the source domains to be sampled in the current sampling round by calculating the upper bound of the contribution confidence of each source domain; the specific steps are as follows:
[0132] 6-1) Calculate the upper bound of the contribution confidence of each source domain in the current sampling round.
[0133] In this embodiment, each source domain In the The expression for calculating the upper bound of the contribution confidence during round sampling is:
[0134]
[0135] In this embodiment, the second term on the right side of the equation represents "exploratory compensation for hospitals with fewer sampling attempts and insufficient understanding".
[0136] source domain in front Based on historical approximate contribution in the round The contribution estimate obtained through exponentially weighted moving average is:
[0137]
[0138] 6-2) Based on the results of step 6-1), select the source domain to be sampled in the current sampling round. In this embodiment, based on the results of step 6-1), during specific sampling, the source domain corresponding to the maximum value of the upper bound of the contribution confidence is selected as the source domain to be sampled in the current sampling round. If there are multiple source domains corresponding to the maximum value of the upper bound of the contribution confidence in the results of step 6-1), this embodiment can use a random selection method to randomly select one source domain from all source domains corresponding to the maximum value of the upper bound of the contribution confidence as the source domain to be sampled in the current sampling round.
[0139] 7) Randomly sample B training samples from the source domain selected in step 6), and then train the current target domain model to obtain the updated current target domain model.
[0140] In this embodiment, the source domain selected in step 6) Eight training samples are sampled (within budget constraints) to form a training batch. This training batch is then used to perform one or more gradient updates on the model, yielding the desired results. .
[0141] Update the cumulative number of samples taken from the source domain. The counts of the remaining source domains remain unchanged.
[0142] 8) Let the current sampling round be t = t + 1, and then return to step 5) to perform the next round of sampling. In this embodiment, sampling ends when the upper limit of the sampling budget is reached (or the target domain performance reaches the preset target and remains stable for several consecutive rounds), and the final parameters of the target domain model after training are output. It was deployed to the target hospital H for early sepsis warning mission.
[0143] To implement the above embodiments, a second aspect of the present invention provides a multi-source data adaptive sampling device, comprising:
[0144] The target domain validation set and source domain training set construction module is used to construct the target domain validation set and multiple source domain training sets based on the target domain model.
[0145] The initial sampling module is used to perform one round of sampling on the training set of each source domain after the sampling begins, and to train the target domain model using the training samples obtained after each round of sampling;
[0146] An adaptive sampling module is used to select source domains to participate in the current sampling round based on the historical contribution of each source domain to the training of the target domain model, after completing one round of sampling in the training set of each source domain. Then, training samples are sampled from the selected source domains and the target domain model is trained. Sampling is completed when the training of the target domain model reaches the preset termination condition.
[0147] In one specific embodiment of the present invention, it further includes:
[0148] Let K be the number of source domains. By sampling the training set of K source domains for K rounds, the target domain model completes K rounds of training. Starting from the (K+1)th round of sampling, let t be the current sampling round.
[0149] Before the current sampling round begins, calculate the contribution of each source domain to the training of the target domain model, as shown in the following expression:
[0150]
[0151] in, This represents a sample taken from the training set of the source domain. This represents the approximate contribution of training samples taken from the training set in the source domain to the training of the model in the target domain; This represents the validation samples obtained from the target domain validation set; This represents the gradient operator of the target domain model loss function with respect to the model parameters; This represents the loss gradient of the target domain model on the target domain validation samples; This indicates that the target domain model uses training samples from the source domain. The amount of parameter change that occurs when the model undergoes a single parameter update; Indicates the training samples in the source domain The mathematical expectation.
[0152] In one specific embodiment of the present invention, it further includes:
[0153] When the target domain model is trained using a stochastic gradient descent optimizer, ,in This indicates that the model is trained on samples in the source domain. loss gradient on, Update the step size for the parameters.
[0154] In one specific embodiment of the present invention, it further includes:
[0155] When the target domain model is trained using the Adam optimizer,
[0156]
[0157] in, and These represent the first and second moment estimates of the historical gradient, respectively. and The exponential decay coefficient is... For numerically stable terms, This represents the baseline step size coefficient in the adaptive optimization algorithm; and They represent the first time. In the next iteration, the exponential decay factors of the first and second moments are... Power of 1.
[0158] In one specific embodiment of the present invention, it further includes:
[0159] Based on the contribution of each source domain to the training of the target domain model, the source domain to be sampled in the current sampling round is determined by calculating the upper bound of the contribution of each source domain. The specific steps are as follows:
[0160] 1) Calculate the upper bound of the contribution confidence of each source domain in the current sampling round;
[0161] Among them, any source domain In the The expression for calculating the upper bound of the contribution confidence during round sampling is:
[0162]
[0163] in, Represents the source domain in front Based on historical approximate contribution in the round Contribution estimate obtained through exponentially weighted moving average; Represents the source domain in front The cumulative number of times samples were taken during the round; The exploration coefficient is used to adjust the degree of exploration of the source domain with low sampling times, and is a positive real number. Regarding the rounds The logarithmic term;
[0164] in,
[0165]
[0166] in, Indicates the first Round sampling from the source domain The approximate contribution of the training samples sampled from the training set to the training of the target domain model; Index for historical rounds; This is the exponential decay coefficient, used to control the degree to which historical contribution information is retained. ;
[0167] 2) Select the source domain corresponding to the maximum value of the upper bound of the contribution confidence from the results of step 1) as the source domain to be sampled in the current sampling round;
[0168] If the result of step 1) contains multiple source domains corresponding to the maximum upper bound of the contribution confidence, then one source domain is randomly selected from all the source domains corresponding to the maximum upper bound of the contribution confidence as the source domain to be sampled in the current sampling round.
[0169] This enables efficient, stable, and interpretable multi-source data selection and domain adaptation under conditions of limited data and dynamic environmental changes by introducing a performance feedback mechanism and multi-armed slot machine modeling, which has significant practical value.
[0170] To implement the above embodiments, a third aspect of the present invention provides an electronic device, comprising:
[0171] At least one processor; and a memory communicatively connected to said at least one processor;
[0172] The memory stores instructions that can be executed by the at least one processor, and the instructions are configured to execute the aforementioned multi-source data adaptive sampling method.
[0173] To implement the above embodiments, a fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions for causing the computer to execute the above-described multi-source data adaptive sampling method.
[0174] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.
[0175] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform a multi-source data adaptive sampling method according to the above embodiments.
[0176] Computer program code for performing the operations of this disclosure can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0177] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0178] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0179] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the function involved, as will be understood by those skilled in the art to which embodiments of this application pertain.
[0180] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which programs can be printed, because programs can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0181] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0182] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0183] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0184] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A multi-source data adaptive sampling method, characterized in that, The method comprises the following steps: Based on the target domain model, a target domain verification set and training sets of multiple source domains are respectively constructed; After the sampling starts, one round of sampling is respectively performed on the training set of each source domain, and after each round of sampling, the training samples obtained by sampling are used to train the target domain model; After one round of sampling is completed on the training set of each source domain, from the next sampling round, based on the historical contribution of each source domain to the training of the target domain model, the source domains participating in the current sampling round are selected, then training samples are sampled from the selected source domains and the current target domain model is trained; when the training of the target domain model reaches a preset end condition, the sampling is completed.
2. The method of claim 1, wherein, Further comprising: Record the number of source domains as K, and perform K rounds of sampling on the training sets of the K source domains, so that the target domain model completes K rounds of training; From the K+1th round of sampling, record the current sampling round as t; Before the current sampling round starts, the contribution of each source domain to the training of the target domain model is calculated, and the expression is as follows: wherein, denotes a sample drawn from the training set of the source domain, denotes an approximate contribution of a training sample drawn from the training set of the source domain to the training of the target domain model; denotes a validation sample drawn from the validation set of the target domain; denotes the gradient operator of the target domain model loss function with respect to the model parameters; denotes the loss gradient of the target domain model on the target domain validation sample; denotes the loss gradient of the target domain model on the source domain training sample as updated by the parameter update; denotes the mathematical expectation with respect to the source domain training sample as updated by the parameter update.
3. The method of claim 2, wherein, Further comprising: When the training of the target domain model employs a stochastic gradient descent optimizer, wherein denotes the loss gradient of the model on the source domain training samples , is the parameter update step size.
4. The method of claim 2, wherein, Further comprising: When the training of the target domain model uses an Adam optimizer, wherein, and denote the first and second moment estimates of the history gradient, respectively, and is an exponential decay coefficient, is a numerical stabilization term, denotes a reference step size coefficient in the adaptive optimization algorithm; and denote the first and second moment exponential decay factors at the th iteration, respectively, th power.
5. The method of claim 2, wherein, Further comprising: Based on the contribution of each source domain to the training of the target domain model, the source domains sampled in the current sampling round are determined by calculating the confidence upper bound of the contribution of each source domain, and the specific steps are as follows: 1) Calculate the confidence upper bound of the contribution of each source domain in the current sampling round; wherein any source domain In the first The calculation expression of the contribution degree confidence upper bound at the wheel sampling time is: wherein, denotes the source domain in the previous round based on the historical approximation contribution degree obtained by the exponentially weighted moving average; denotes the source domain in the previous round sampled cumulative number of times; is an exploration coefficient, used to adjust the degree of exploration of the source domain with low sampling number of times, and is a positive real number; is a logarithmic term about the round ; Wherein, wherein, represents the training sample from the source domain at the i-th round of sampling to the target domain model training; is the historical round index; is an exponential decay coefficient, used to control the retention degree of the historical contribution information, ; 2) From the result of step 1), the source domain corresponding to the maximum value of the confidence upper bound of the contribution is selected as the source domain sampled in the current sampling round; If there are multiple source domains corresponding to the maximum value of the confidence upper bound of the contribution in the result of step 1), a source domain is randomly selected from all the source domains corresponding to the maximum value of the confidence upper bound of the contribution as the source domain sampled in the current sampling round.
6. A multi-source data adaptive sampling apparatus, comprising: The method comprises the following steps: A target domain verification set and source domain training set construction module is used to respectively construct a target domain verification set and training sets of multiple source domains based on a target domain model; An initial sampling module is used to perform one round of sampling on the training set of each source domain after the sampling starts, and after each round of sampling, the training samples obtained by sampling are used to train the target domain model; An adaptive sampling module is used to, after one round of sampling is completed on the training set of each source domain, from the next sampling round, based on the historical contribution of each source domain to the training of the target domain model, select the source domains participating in the current sampling round, then sample training samples from the selected source domains and train the current target domain model; when the training of the target domain model reaches a preset end condition, the sampling is completed.
7. The apparatus of claim 6, wherein, Further comprising: Record the number of source domains as K, and perform K rounds of sampling on the training sets of the K source domains, so that the target domain model completes K rounds of training; From the K+1th round of sampling, record the current sampling round as t; Before the current sampling round starts, the contribution of each source domain to the training of the target domain model is calculated, and the expression is as follows: wherein, denotes a sample drawn from the training set of the source domain, denotes an approximate contribution of a training sample drawn from the training set of the source domain to the training of the target domain model; denotes a validation sample drawn from the validation set of the target domain; denotes the gradient operator of the loss function of the target domain model with respect to the model parameters; denotes the loss gradient of the target domain model on the target domain validation sample; denotes the loss gradient of the target domain model on the target domain validation sample resulting from a parameter update of the model; denotes the mathematical expectation with respect to the source domain training sample .
8. The apparatus of claim 7, wherein, Further comprising: When the training of the target domain model employs a stochastic gradient descent optimizer, wherein denotes the loss gradient of the model on the source domain training samples , is the parameter update step size.
9. The apparatus of claim 7, wherein, Further comprising: When the training of the target domain model uses an Adam optimizer, wherein, and denote the first and second moment estimates of the history gradient, respectively, and is an exponential decay coefficient, is a numerical stabilization term, denotes a reference step size coefficient in the adaptive optimization algorithm; and denote the first and second moment exponential decay factors at the th iteration, respectively, th power.
10. The apparatus of claim 7, wherein, Further comprising: Based on the contribution of each source domain to the training of the target domain model, the source domains sampled in the current sampling round are determined by calculating the confidence upper bound of the contribution of each source domain, and the specific steps are as follows: 1) calculate the contribution confidence upper bound of each source domain in the current sampling round; wherein any source domain In the first The upper bound of the confidence of the contribution degree at the time of the nth sampling is calculated by the following expression: wherein, denotes the source domain in the previous round based on the historical approximation contribution degree obtained by the exponential weighted moving average; denotes the source domain in the previous round sampled cumulative number of times; is an exploration coefficient, used to adjust the degree of exploration of the source domain with low sampling number of times, and is a positive real number; is a logarithmic term about the round ; wherein, wherein, denotes the training sample from the source domain at the i-th round of sampling, and is the index of the historical round; is the exponential decay coefficient for controlling the retention degree of the historical contribution information, ; 2) select the source domain corresponding to the maximum contribution confidence upper bound from the result of step 1) as the sampled source domain in the current sampling round; if there are multiple source domains corresponding to the maximum contribution confidence upper bound in the result of step 1), then randomly select one source domain from all the source domains corresponding to the maximum contribution confidence upper bound as the sampled source domain in the current sampling round.