Sample migration method and device based on double sampling strategy, equipment and medium
By generating multiple sub-data sets through a dual sampling strategy, training multiple models, and assigning target weight coefficients to sample points, the problem of negative transfer in transfer learning is solved, thereby improving the classification accuracy and model robustness of the target task.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-19
- Publication Date
- 2026-04-03
AI Technical Summary
In existing transfer learning methods, how to select source domain samples that are beneficial to the target task and avoid negative transfer has become a key issue. In particular, when there are noisy or irrelevant samples in the source domain, traditional weight adjustment strategies may lead to performance degradation.
A dual sampling strategy is adopted, which generates multiple sub-data sets through bagging, trains multiple models, and assigns target weight coefficients to sample points based on the classification results of the target task by the models, thereby selecting sample points that are beneficial to the target task.
It improves the classification accuracy of the target task, reduces the impact of noise, and enhances the robustness and predictive performance of the model.
Smart Images

Figure CN121786530A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the technical field of data processing, specifically relating to a sample migration method, apparatus, device, and medium based on a dual sampling strategy. Background Technology
[0002] Transfer learning is a novel machine learning method that can effectively utilize existing knowledge to learn new knowledge, and it is widely used in fields such as data mining.
[0003] Transfer learning enables the transfer of knowledge gained from a source domain to a target domain, thereby improving performance on tasks in the target domain. Since its inception, transfer learning has been widely used, primarily for applications involving scarce data, reducing training costs in the target domain, and enhancing the predictive performance of target domain models.
[0004] In related technologies, how to select source domain samples that are beneficial to the target task and avoid negative transfer has become a key issue in transfer learning research. Summary of the Invention
[0005] In view of the above problems, a sample transfer method, apparatus, device, and medium based on a dual sampling strategy is proposed to overcome or at least partially solve the above problems, including: A sample transfer method based on a dual sampling strategy, the method comprising: Sample points with replacement are extracted from the source domain dataset to obtain multiple first sub-data sets; the size of each first sub-data set is the same as the size of the source domain dataset. Based on any first sub-data set, train a first classification model and determine the first classification error rate of the first classification model on the target domain training data; Based on the first classification error rate, calculate the target weight coefficient of the sample points in the source domain data set, and based on the target weight coefficient, determine the source domain sample set from the source domain data set; A second sub-data set is determined based on the source domain sample set and the target domain training data.
[0006] Optionally, calculating the target weight coefficients of the sample points in the source domain dataset based on the first classification error rate includes: Based on the first classification error rate, determine the weight value of the sample points in the first sub-data set corresponding to the first classification error rate; The target weight coefficient of the sample point is determined based on the weight value of the sample point in different first sub-data sets.
[0007] Optionally, determining the target weight coefficient of the sample point based on the weight values determined for the sample point in different first sub-data sets includes: The target weight coefficient of the sample points is obtained by weighting the weight values determined in different first sub-data sets.
[0008] Optionally, determining the source domain sample set from the source domain data set based on the target weight coefficient includes: When the target weight coefficient is not less than the weight coefficient threshold, the corresponding sample point is added to the source domain sample set.
[0009] Optionally, determining the second sub-data set based on the source domain sample set and the target domain training data includes: The source domain sample set and the target domain training data are merged to obtain a merged data set; From the merged dataset, sample points are extracted with replacement to obtain multiple third sub-data sets; the size of each third sub-data set is the same as the size of the merged dataset. Based on any third sub-data set, train a second classification model and determine the second classification error rate of the second classification model on the target domain training data; The second sub-data set is determined from the plurality of third sub-data sets based on the second classification error rate.
[0010] Optionally, determining the second sub-data set from the plurality of third sub-data sets based on the second classification error rate includes: Determine the third sub-data set whose second classification error rate is greater than the classification error rate threshold; The third subset of data whose classification error rate is greater than the classification error rate threshold is combined into the second subset of data.
[0011] Optionally, the method further includes: The third classification model is trained based on any second sub-data set; Based on multiple third-class classification models, a target classification model is obtained.
[0012] This application also provides a sample transfer apparatus based on a dual sampling strategy, the apparatus comprising: The first sampling module is used to extract sample points with replacement from the source domain data set to obtain multiple first sub-data sets; the size of each first sub-data set is the same as the size of the source domain data set. The first determining module is used to train a first classification model based on any first sub-data set, and to determine the first classification error rate of the first classification model on the target domain training data. The second determining module is used to calculate the target weight coefficient of the sample points in the source domain data set based on the first classification error rate, and to determine the source domain sample set from the source domain data set based on the target weight coefficient. The second sampling module is used to determine a second sub-data set based on the source domain sample set and the target domain training data.
[0013] Optionally, the second determining module is configured to determine the weight value of the sample point in the first sub-data set corresponding to the first classification error rate based on the first classification error rate; and to determine the target weight coefficient of the sample point based on the weight value determined by the sample point in different first sub-data sets.
[0014] Optionally, the second determining module is used to perform a weighted average of the weight values of the sample points determined in different first sub-data sets to obtain the target weight coefficient of the sample points.
[0015] Optionally, the second determining module is used to add the corresponding sample points to the source domain sample set when the target weight coefficient is not less than the weight coefficient threshold.
[0016] Optionally, the second sampling module is used to merge the source domain sample set and the target domain training data to obtain a merged data set; extract sample points with replacement from the merged data set to obtain multiple third sub-data sets; the size of each third sub-data set is the same as the size of the merged data set; train a second classification model based on any one of the third sub-data sets, and determine the second classification error rate of the second classification model on the target domain training data; determine the second sub-data set from the multiple third sub-data sets based on the second classification error rate.
[0017] Optionally, the second sampling module is used to determine a third sub-data set whose second classification error rate is greater than the classification error rate threshold; and to combine the third sub-data set whose second classification error rate is greater than the classification error rate threshold into the second sub-data set.
[0018] Optionally, the device further includes: The training module is used to train a third classification model based on any second sub-data set; and to obtain a target classification model based on multiple third classification models.
[0019] This application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the sample transfer method based on the dual sampling strategy described above.
[0020] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the sample migration method based on the dual sampling strategy described above.
[0021] The embodiments of this application have the following advantages: In this embodiment, sample points with replacement are extracted from the source domain dataset to obtain multiple first sub-data sets; the size of each first sub-data set is the same as the size of the source domain dataset; a first classification model is trained based on any one of the first sub-data sets, and a first classification error rate of the first classification model on the target domain training data is determined; based on the first classification error rate, the target weight coefficients of the sample points in the source domain dataset are calculated, and a source domain sample set is determined from the source domain dataset based on the target weight coefficients; a second sub-data set is determined based on the source domain sample set and the target domain training data.
[0022] This application generates multiple sub-data sets using the bagging method, trains multiple models, assigns target weight coefficients to sample points in the source domain data set based on the classification results of the target task by the models, and selects sample points that are beneficial to the target task based on the target weight coefficients.
[0023] This application, for the first time, uses the bagging method to collect multiple distinct sub-data sets. The classification error rate of each sub-data set for the target task can be used to determine the classification performance of the selected sub-data set on the target domain training data. Sub-data sets with high accuracy on the target domain training data have a distribution that more closely resembles the target domain distribution, which is more conducive to the classification accuracy of the target task. Sample points in this set should be assigned higher weight values. The bagging method allows each sample point to potentially exist in multiple sub-data sets, and the target weight coefficient can comprehensively reflect the importance of the sample point to the target task, thereby selecting a suitable source domain sample set. Attached Figure Description
[0024] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which: Figure 1 This is a flowchart illustrating the steps of a sample transfer method based on a dual sampling strategy according to an embodiment of this application. Figure 2 This is a flowchart illustrating the steps of another sample transfer method based on a dual sampling strategy according to an embodiment of this application; Figure 3 This is a flowchart illustrating the steps of selecting a source domain data set according to an embodiment of this application; Figure 4 This is a flowchart illustrating the steps of training a target domain model according to an embodiment of this application; Figure 5 This is a schematic diagram of the structure of a sample transfer device based on a dual sampling strategy according to an embodiment of this application. Detailed Implementation
[0025] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0026] Transfer learning methods have evolved to include various classification frameworks, which can be summarized into sample-based transfer, model-based transfer, distribution adaptation, subspace alignment, and other accumulated methods.
[0027] This application is based on instance-based transfer learning. Instance-based transfer learning generally adjusts the weights of samples in the source domain according to weight rules, increasing the weight of samples that correctly classify the target domain and decreasing the weight of misclassified samples, thereby achieving instance transfer. TrAdaBoost is one of the most classic research methods in instance transfer learning. This type of transfer method does not destroy the original information of the data domain and can improve the classification accuracy of the target task to a certain extent.
[0028] While sample transfer learning methods can effectively improve model prediction performance in many ways, the source domain dataset may contain sample points that are detrimental to the performance of the target task. These sample points may lead to negative transfer, further reducing the classification effect on the target task. Negative transfer mainly stems from the differences between the source and target domains, which may make some source domain samples irrelevant or even harmful in the target task.
[0029] Therefore, how to select source domain samples that are beneficial to the target task and avoid negative transfer has become a key issue in transfer learning research.
[0030] Traditional sample transfer methods typically rely on adjusting sample weights, assigning higher weights to correctly classified samples and lower weights to misclassified samples to achieve transfer learning. These methods can improve classification accuracy to some extent, but when there are many noisy or irrelevant samples in the source domain, the weight adjustment strategy may lead to performance degradation. To avoid negative transfer, this application provides a sample transfer method based on a double sampling strategy. Multiple subsets are generated through bagging sampling, and multiple models are trained. The models assign sample weights based on the classification results of the target task, and the weighted sample weights are then calculated to obtain a comprehensive target weight coefficient. This target weight coefficient is compared with a given value to select the samples most beneficial to the target task. The bagging method not only reduces the impact of noise but also improves overall prediction performance through model ensemble.
[0031] This application aims to improve the classification accuracy of a target domain task through double sampling. The first sampling mainly selects source domain data, while the second sampling improves the robustness of the model. The improvement in classification accuracy for the target task is achieved through these two sampling steps.
[0032] Reference Figure 1 The diagram illustrates a step flowchart of a sample migration method based on a dual sampling strategy according to an embodiment of this application, which may include the following steps: Step 101: Extract sample points with replacement from the source domain dataset to obtain multiple first sub-data sets; the size of each first sub-data set is the same as the size of the source domain dataset.
[0033] In this context, the source domain can refer to a center with knowledge (data, model parameters, model, etc.), while the target domain is a center that needs to learn new knowledge. The sample transfer in the technical solution of this application is to acquire the existing knowledge in the source domain and improve the prediction performance of the target center.
[0034] The source domain dataset can refer to the dataset collected from the source domain, which may include multiple sample points; in some embodiments, the bagging method can be used to obtain multiple first sub-data sets from the source domain dataset.
[0035] Among them, the bagging method is a method that generates multiple subsets by repeatedly sampling the original dataset. Multiple models can be trained using multiple subsets to evaluate performance stability, which can enhance the robustness of the model and its resistance to data fluctuations.
[0036] Specifically, a sample point can be randomly selected from the source dataset and added to a sub-dataset. Then, this selected sample point is returned to the source dataset, and another sample point is randomly selected from the source dataset and added to the sub-dataset. This process continues until the size of the sub-dataset is the same as the size of the source dataset, meaning the number of sample points in the sub-dataset is the same as the number of sample points in the source dataset. This yields a first sub-dataset. Multiple first sub-datasets can be obtained by repeating this process.
[0037] Step 102: Train a first classification model based on any first sub-data set, and determine the first classification error rate of the first classification model on the target domain training data.
[0038] After obtaining multiple first sub-data sets, one of the first sub-data sets can be used sequentially to train a first classification model; for example, the first classification model can be a weak classification model.
[0039] After obtaining the first classification model corresponding to each first sub-data set, the first classification error rate of each first classification model on the target domain training data can be determined respectively; wherein, the target domain training data can refer to the training data of the model pointing to the target domain; it can include model input data and model output data.
[0040] The primary classification error rate (PCR) can be used to characterize the accuracy of the primary classification model's predictions for the target domain. The higher the PCR, the less suitable the classification model is for the target domain; correspondingly, the sub-data set used to train the classification model is also unsuitable for transfer to the target domain.
[0041] In some embodiments, after obtaining the first classification model, the model input data in the target domain training data can be input into the first classification model; then, the output result of the first classification model can be compared with the model output result in the target domain training data to generate the first classification error rate.
[0042] Step 103: Calculate the target weight coefficients of the sample points in the source domain dataset based on the first classification error rate, and determine the source domain sample set from the source domain dataset based on the target weight coefficients.
[0043] After obtaining the first classification error rate, the target weight coefficient of each sample point in the source domain dataset can be calculated based on the first classification error rate; the target weight coefficient can be used to evaluate the matching degree between the sample point and the target task for the target domain.
[0044] After obtaining the target weight coefficient of each sample point in the source domain dataset, a second sampling can be performed from the source domain dataset based on the target weight coefficient to extract sample points, thereby obtaining the source domain sample set, which is used to complete the sample transfer.
[0045] Step 104: Determine the second sub-data set based on the source domain sample set and the target domain training data.
[0046] In some embodiments, after obtaining the source domain sample set, a second sub-data set can be generated based on the source domain sample set and the target domain training data, thereby completing the sample transfer.
[0047] In this embodiment, sample points with replacement are extracted from the source domain dataset to obtain multiple first sub-data sets; the size of each first sub-data set is the same as the size of the source domain dataset; a first classification model is trained based on any one of the first sub-data sets, and a first classification error rate of the first classification model on the target domain training data is determined; based on the first classification error rate, the target weight coefficients of the sample points in the source domain dataset are calculated, and a source domain sample set is determined from the source domain dataset based on the target weight coefficients; a second sub-data set is determined based on the source domain sample set and the target domain training data.
[0048] This application generates multiple sub-data sets using the bagging method, trains multiple models, assigns target weight coefficients to sample points in the source domain data set based on the classification results of the target task by the models, and selects sample points that are beneficial to the target task based on the target weight coefficients.
[0049] This application, for the first time, uses the bagging method to collect multiple distinct sub-data sets. The classification error rate of each sub-data set for the target task can be used to determine the classification performance of the selected sub-data set on the target domain training data. Sub-data sets with high accuracy on the target domain training data have a distribution that more closely resembles the target domain distribution, which is more conducive to the classification accuracy of the target task. Sample points in this set should be assigned higher weight values. The bagging method allows each sample point to potentially exist in multiple sub-data sets, and the target weight coefficient can comprehensively reflect the importance of the sample point to the target task, thereby selecting a suitable source domain sample set.
[0050] Reference Figure 2 The diagram illustrates a flowchart of another sample migration method based on a dual sampling strategy according to an embodiment of this application, which may include the following steps: Step 201: Extract sample points with replacement from the source domain dataset to obtain multiple first sub-data sets.
[0051] In some embodiments, a sample point is randomly selected from the source dataset and added to a sub-dataset.
[0052] Then, after the extracted sample point is put back into the source domain data set, a sample point is randomly selected from the source domain data set and added to the aforementioned sub-data set until the size of the sub-data set is the same as the size of the source domain data set, that is, the number of sample points included in the sub-data set is the same as the number of sample points included in the source domain data set.
[0053] This gives us a first sub-data set. By analogy, we can obtain multiple first sub-data sets.
[0054] Step 202: Train a first classification model based on any first sub-data set, and determine the first classification error rate of the first classification model on the target domain training data.
[0055] After obtaining multiple first sub-data sets, one of the first sub-data sets can be used sequentially to train the first classification model.
[0056] After obtaining the first classification model corresponding to each first sub-data set, the first classification error rate of each first classification model on the target domain training data can be determined.
[0057] In some embodiments, after obtaining the first classification model, the model input data from the target domain training data can be input into the first classification model.
[0058] Then, the output of the first classification model can be compared with the output of the model in the training data of the target domain to generate the first classification error rate.
[0059] Step 203: Determine the weight values of the sample points in the first sub-data set corresponding to the first classification error rate, based on the first classification error rate.
[0060] In some embodiments, after determining the first classification error rate, the weight values of sample points in the corresponding first sub-data set can be determined based on the first classification error rate. For example, the weight value can be calculated using the following formula: = ; in, Let x be the weight value of the x-th sample point in the i-th first sub-data set; Let be the first classification error rate corresponding to the i-th first sub-data set.
[0061] Step 204: Determine the target weight coefficient of the sample points based on the weight values determined for the sample points in different first sub-data sets.
[0062] After obtaining the weights of the sample points in each first sub-data set, due to the bagging method, a sample point may exist in multiple first sub-data sets at the same time, so a sample point may correspond to multiple weight values; in this embodiment, the target weight coefficient of a sample point can be determined based on the weight values determined for a sample point in different first sub-data sets.
[0063] In one embodiment of this application, step 204 can be implemented through the following sub-steps: Sub-step 11: Perform a weighted average of the weight values of the sample points determined in different first sub-data sets to obtain the target weight coefficient of the sample points.
[0064] In some embodiments, after obtaining the weight values of sample points in different first sub-data sets in the source domain data set, a weighted average of these multiple weight values can be performed to obtain the target weight coefficient of the sample point.
[0065] Step 205: When the target weight coefficient is not less than the weight coefficient threshold, add the corresponding sample points to the source domain sample set.
[0066] In some embodiments, after determining the target weight coefficient of the sample points, the source domain sample set can be determined based on the target weight coefficient and a preset weight coefficient threshold.
[0067] For example, if the target weight coefficient is not less than the weight coefficient threshold, it can be determined that the sample point has a high degree of matching with the target task; at this time, the sample point can be added to the source domain sample set.
[0068] Conversely, if the target weight coefficient is less than the weight coefficient threshold, it can be determined that the sample point has a low matching degree with the target task; in this case, the sample point can be discarded.
[0069] For each sample point in the source domain dataset, its relationship with the weight coefficient threshold can be determined, thereby selecting sample points with a high degree of matching with the target task from the source domain dataset, and thus obtaining the source domain sample set.
[0070] Step 206: Merge the source domain sample set and the target domain training data to obtain a merged data set.
[0071] In some embodiments, after obtaining the source domain sample set, a second sub-data set can be generated based on the source domain sample set and the target domain training data, thereby completing the sample transfer.
[0072] For example, after obtaining the source domain sample set, the source domain sample set can be merged with the target domain training data to obtain a merged data set.
[0073] Step 207: Extract sample points with replacement from the merged dataset to obtain multiple third sub-data sets; the size of each third sub-data set is the same as the size of the merged dataset.
[0074] After obtaining the merged data set, the bagging method can be used to obtain multiple third sub-data sets from the merged data set.
[0075] For example, a sample point can be randomly selected from the merged dataset and added to a sub-dataset.
[0076] Then, after the extracted sample point is put back into the merged data set, another sample point is randomly selected from the merged data set and added to the aforementioned sub-data set, until the size of the sub-data set is the same as the size of the merged data set, that is, the number of sample points included in the sub-data set is the same as the number of sample points included in the merged data set.
[0077] Thus, we obtain a third sub-data set. By analogy, we can obtain multiple third sub-data sets.
[0078] Step 208: Train a second classification model based on any third sub-data set, and determine the second classification error rate of the second classification model on the target domain training data.
[0079] After obtaining multiple third sub-data sets, one of the third sub-data sets can be used sequentially to train a second classification model; for example, the second classification model can be a weak classification model.
[0080] After obtaining the second classification model corresponding to each third sub-data set, the second classification error rate of each second classification model on the target domain training data can be determined.
[0081] The second classification error rate can be used to characterize the accuracy of the prediction results of the second classification model for the target domain. The higher the second classification error rate, the less suitable the classification model is for the target domain; correspondingly, the sub-data set used to train the classification model is also not suitable for transfer to the target domain.
[0082] In some embodiments, after obtaining the second classification model, the model input data in the target domain training data can be input into the second classification model; then, the output result of the second classification model can be compared with the model output result in the target domain training data to generate the second classification error rate.
[0083] Step 209: Determine the second sub-data set from multiple third sub-data sets based on the second classification error rate.
[0084] After obtaining the second classification error rate, the second sub-data set can be determined from multiple third sub-data sets based on the second classification error rate to complete the sample transfer.
[0085] In one embodiment of this application, step 209 can be implemented through the following sub-steps: Sub-step 21: Determine the third sub-data set where the second classification error rate is greater than the classification error rate threshold.
[0086] After obtaining the second classification error rate, the relationship between the second classification error rate and the preset classification error rate threshold can be determined.
[0087] In some embodiments, a third sub-data set whose second classification error rate is greater than a classification error rate threshold can be determined from all third sub-data sets.
[0088] Sub-step 22: Combine the third subset of data whose second classification error rate is greater than the classification error rate threshold into a second subset of data.
[0089] After determining the third sub-data set whose second classification error rate is greater than the classification error rate threshold, the third sub-data set whose second classification error rate is greater than the classification error rate threshold can be used as the second sub-data set.
[0090] In one embodiment of this application, the above method may further include the following steps: A third classification model is trained based on any one of the second sub-data sets; a target classification model is obtained based on multiple third classification models.
[0091] In some embodiments, after obtaining the second sub-data set, a third classification model can be trained based on each of the second sub-data sets; the third classification model is similar to the second classification model, and can be a weak classification model.
[0092] After obtaining the third classification model corresponding to each second sub-data set, the target classification model can be obtained based on multiple third classification models; specifically, the target classification model can be obtained by weighting multiple third classification models.
[0093] In this embodiment, sample points with replacement are extracted from the source domain dataset to obtain multiple first sub-data sets; a first classification model is trained based on any one of the first sub-data sets, and a first classification error rate of the first classification model on the target domain training data is determined; based on the first classification error rate, the weight value of the sample point in the first sub-data set corresponding to the first classification error rate is determined; based on the weight values determined for the sample point in different first sub-data sets, a target weight coefficient of the sample point is determined; when the target weight coefficient is not less than the weight coefficient threshold, the corresponding sample point is added to the source domain sample set; the source domain sample set and the target domain training data are merged to obtain a merged data set; sample points with replacement are extracted from the merged data set to obtain multiple third sub-data sets; the size of each third sub-data set is the same as the size of the merged data set; a second classification model is trained based on any one of the third sub-data sets, and a second classification error rate of the second classification model on the target domain training data is determined; based on the second classification error rate, a second sub-data set is determined from the multiple third sub-data sets. This application merges the selected source domain sample set into the target domain training dataset to obtain a merged dataset. Then, it uses the bagging method again to select multiple subsets of data, trains multiple weak classification models, and weights them to obtain the final model. By combining the selected source domain sample set with the target domain training data and using the bagging method again to extract multiple subsets, training multiple weak classifiers, and weighting them to obtain the final classification model, the stability and predictive performance of the model are improved. The sample subset selected by the first bagging method already contains samples with a high degree of matching to the target domain classification task; the second bagging targets the data in the target domain. The bagging method and weighting mechanism can improve stability and predictive performance.
[0094] Reference Figure 3 The following is a flowchart illustrating the steps of selecting a source domain data set according to an embodiment of this application: Input: Source domain dataset Target domain training data Number of iterations N, parameters ; Output: Set of samples from the source domain ; for i in N: Using the bagging method to extract data from the source domain dataset In the middle, a group of size is drawn with replacement. First sub-data set ; Using the first sub-data set The first classification model was obtained through training. ; Calculate the first classification model Training data in the target domain The first classification error rate : ; in, Let x be the classification result of the j-th sample point output by the first classification model based on the target domain training data. j For the j-th sample point in the training data of the target domain, c(x) j ) represents the true classification result of the j-th sample point in the training data of the target domain.
[0095] Obtain the first sub-data set The weight value of each sample point: = , where i is the i-th iteration and x is the x-th sample point in the current iteration.
[0096] Through N rounds of iteration, N sets of sample weight values are obtained. The target weight coefficient for each sample point is obtained by weighted averaging these weight values.
[0097] in, The weight coefficient of the x-th sample point in the source domain sample points. Here, n represents the weight value of this sample point in the i-th iteration, and n is the number of counts. if ≥ Then it is added to the source domain sample set. middle.
[0098] Add the qualified sample points in the source domain to the source domain sample set, where xi and yi represent the i-th sample point.
[0099] Reference Figure 4 The following is a flowchart illustrating the steps of training a target domain model according to an embodiment of this application: Input: Source domain data selection results `, target domain training data The number of iterations is N; Output: Target classification model:
[0100] for i in N: Merge source domain sample set and target domain training data Multiple sets of third-sub-data sets were obtained by bagging method. This is used to train the second classifier. ` Calculate the second classification model Training data in the target domain The second classification error rate:
[0101] in, This represents the number of training samples in the target domain. This represents the sample weight of the j-th sample (usually 1 / number of samples). Indicates whether the j-th sample is correctly classified; if If the percentage is greater than 50%, it is considered that the sample point differs significantly from the target domain training data, and the third sub-data set is directly discarded.
[0102] N weak classification models h1~h2 are obtained through N sets of training. n The final classification model is obtained by weighted averaging:
[0103] in, =1- represents the weights of the current classifier, where i corresponds to the classification model trained on the i-th extracted second sub-data set. Let i be the i-th classification model.
[0104] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of this application.
[0105] Reference Figure 5 The diagram illustrates a sample transfer device based on a dual sampling strategy according to an embodiment of this application, which may include the following modules: The first sampling module 501 is used to extract sample points with replacement from the source domain data set to obtain multiple first sub-data sets; the size of each first sub-data set is the same as the size of the source domain data set. The first determining module 502 is used to train a first classification model based on any first sub-data set, and to determine the first classification error rate of the first classification model on the target domain training data. The second determining module 503 is used to calculate the target weight coefficient of the sample points in the source domain data set based on the first classification error rate, and to determine the source domain sample set from the source domain data set based on the target weight coefficient. The second sampling module 504 is used to determine the second sub-data set based on the source domain sample set and the target domain training data.
[0106] In some embodiments of this application, the second determining module 503 is used to determine the weight value of the sample point in the first sub-data set corresponding to the first classification error rate based on the first classification error rate; and to determine the target weight coefficient of the sample point based on the weight value determined by the sample point in different first sub-data sets.
[0107] In some embodiments of this application, the second determining module 503 is used to perform a weighted average of the weight values of the sample points determined in different first sub-data sets to obtain the target weight coefficient of the sample points.
[0108] In some embodiments of this application, the second determining module 503 is used to add the corresponding sample points to the source domain sample set when the target weight coefficient is not less than the weight coefficient threshold.
[0109] In some embodiments of this application, the second sampling module 504 is used to merge the source domain sample set and the target domain training data to obtain a merged data set; extract sample points with replacement from the merged data set to obtain multiple third sub-data sets; the size of each third sub-data set is the same as the size of the merged data set; train a second classification model based on any one of the third sub-data sets, and determine the second classification error rate of the second classification model on the target domain training data; determine a second sub-data set from the multiple third sub-data sets based on the second classification error rate.
[0110] In some embodiments of this application, the second sampling module 504 is used to determine a third sub-data set whose second classification error rate is greater than the classification error rate threshold; and to combine the third sub-data set whose second classification error rate is greater than the classification error rate threshold into a second sub-data set.
[0111] In some embodiments of this application, the apparatus further includes: The training module is used to train a third classification model based on any second sub-data set; and to obtain a target classification model based on multiple third classification models.
[0112] In this embodiment, sample points with replacement are extracted from the source domain dataset to obtain multiple first sub-data sets; the size of each first sub-data set is the same as the size of the source domain dataset; a first classification model is trained based on any one of the first sub-data sets, and a first classification error rate of the first classification model on the target domain training data is determined; based on the first classification error rate, the target weight coefficients of the sample points in the source domain dataset are calculated, and a source domain sample set is determined from the source domain dataset based on the target weight coefficients; a second sub-data set is determined based on the source domain sample set and the target domain training data.
[0113] This application generates multiple sub-data sets using the bagging method, trains multiple models, assigns target weight coefficients to sample points in the source domain data set based on the classification results of the target task by the models, and selects sample points that are beneficial to the target task based on the target weight coefficients.
[0114] This application, for the first time, uses the bagging method to collect multiple distinct sub-data sets. The classification error rate of each sub-data set for the target task can be used to determine the classification performance of the selected sub-data set on the target domain training data. Sub-data sets with high accuracy on the target domain training data have a distribution that more closely resembles the target domain distribution, which is more conducive to the classification accuracy of the target task. Sample points in this set should be assigned higher weight values. The bagging method allows each sample point to potentially exist in multiple sub-data sets, and the target weight coefficient can comprehensively reflect the importance of the sample point to the target task, thereby selecting a suitable source domain sample set.
[0115] This application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, it implements the sample transfer method based on the dual sampling strategy described above.
[0116] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the sample migration method based on the dual sampling strategy described above.
[0117] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0118] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0119] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented 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.
[0120] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should 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 terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0121] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate 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.
[0122] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal 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.
[0123] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0124] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0125] The above provides a detailed description of a sample migration method, apparatus, device, and medium based on a dual sampling strategy. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A sample transfer method based on a dual sampling strategy, characterized in that, The method includes: Sample points with replacement are extracted from the source domain dataset to obtain multiple first sub-data sets; the size of each first sub-data set is the same as the size of the source domain dataset. Based on any first sub-data set, train a first classification model and determine the first classification error rate of the first classification model on the target domain training data; Based on the first classification error rate, calculate the target weight coefficient of the sample points in the source domain data set, and based on the target weight coefficient, determine the source domain sample set from the source domain data set; A second sub-data set is determined based on the source domain sample set and the target domain training data.
2. The method according to claim 1, characterized in that, The step of calculating the target weight coefficients of sample points in the source domain dataset based on the first classification error rate includes: Based on the first classification error rate, determine the weight value of the sample points in the first sub-data set corresponding to the first classification error rate; The target weight coefficient of the sample point is determined based on the weight value of the sample point in different first sub-data sets.
3. The method according to claim 2, characterized in that, The step of determining the target weight coefficient of the sample point based on the weight value determined by the sample point in different first sub-data sets includes: The target weight coefficient of the sample points is obtained by weighting the weight values determined in different first sub-data sets.
4. The method according to claim 1, characterized in that, The step of determining the source domain sample set from the source domain data set based on the target weight coefficient includes: When the target weight coefficient is not less than the weight coefficient threshold, the corresponding sample point is added to the source domain sample set.
5. The method according to claim 1, characterized in that, The step of determining the second sub-data set based on the source domain sample set and the target domain training data includes: The source domain sample set and the target domain training data are merged to obtain a merged data set; From the merged dataset, sample points are extracted with replacement to obtain multiple third sub-data sets; the size of each third sub-data set is the same as the size of the merged dataset. Based on any third sub-data set, train a second classification model and determine the second classification error rate of the second classification model on the target domain training data; The second sub-data set is determined from the plurality of third sub-data sets based on the second classification error rate.
6. The method according to claim 5, characterized in that, The step of determining the second sub-data set from the plurality of third sub-data sets based on the second classification error rate includes: Determine the third sub-data set whose second classification error rate is greater than the classification error rate threshold; The third subset of data whose classification error rate is greater than the classification error rate threshold is combined into the second subset of data.
7. The method according to claim 1, characterized in that, The method further includes: The third classification model is trained based on any second sub-data set; Based on multiple third-class classification models, a target classification model is obtained.
8. A sample transfer device based on a dual sampling strategy, characterized in that, The device includes: The first sampling module is used to extract sample points with replacement from the source domain data set to obtain multiple first sub-data sets; the size of each first sub-data set is the same as the size of the source domain data set. The first determining module is used to train a first classification model based on any first sub-data set, and to determine the first classification error rate of the first classification model on the target domain training data. The second determining module is used to calculate the target weight coefficient of the sample points in the source domain data set based on the first classification error rate, and to determine the source domain sample set from the source domain data set based on the target weight coefficient. The second sampling module is used to determine a second sub-data set based on the source domain sample set and the target domain training data.
9. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the sample migration method based on a dual sampling strategy as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the sample migration method based on a dual sampling strategy as described in any one of claims 1 to 7.