Data sampling method, device, electronic device and storage medium

By grouping and hierarchically sampling negative samples, the problem of high computing resources consumption of data sampling algorithms in the prior art is solved, efficient data processing and model training are realized, and prediction accuracy is improved.

CN114444576BActive Publication Date: 2025-01-03BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111665473.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-01-03
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

The existing data sampling algorithms are costly and time-consuming when processing large data volumes, resulting in excessive consumption of computing resources and difficulty in effectively processing the ‘gray zone’ in complex data, resulting in the model’s learning and prediction effects failure.

Method used

By grouping negative samples, calculate the difference between the characteristic value of each group and the positive sample, divide the groups into difficult groups and non-hard groups, perform hierarchical sampling, and only the samples of non-hard groups are retained. Reduce computing resource consumption.

Benefits of technology

It effectively reduces the consumption of computing resources and time, improves the training efficiency of the model, avoids processing of the entire amount of data, and improves the prediction accuracy of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114444576B_ABST
    Figure CN114444576B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a data sampling method, device, electronic device and storage medium, including: obtaining raw data, wherein each raw data includes an index value and at least one characteristic value, the raw data is divided into positive samples and negative samples, the index value of the positive sample is greater than a preset threshold, and the index value of the negative sample is not greater than the preset threshold; according to the index value of the negative sample, the negative sample is divided into multiple groups; the difference between the characteristic value of the negative sample and the characteristic value of the positive sample in each group is calculated; according to the difference value, the group is divided into a difficult group and a non-difficult group; stratified sampling is performed on the non-difficult group to obtain a non-difficult sample, and the positive sample, the negative sample in the difficult group and the non-difficult sample are used as the sampling result of the raw data. In this way, in the sampling process, it is not necessary to process the full amount of raw data, so less computing resources are consumed and less time is consumed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing, and in particular to a data sampling method, device, electronic device and storage medium. Background Art

[0002] In some scenarios, it is often necessary to sample the original data according to a certain rule to obtain positive samples and negative samples, and then use the positive samples and negative samples to train and verify the model. In this way, the trained model can be used to classify the indicator values ​​of the data to be analyzed, that is, to predict whether the indicator values ​​of the data to be analyzed can reach a certain threshold, for example, predicting whether a video can reach a predetermined number of views, and so on.

[0003] In some cases, due to the complexity of the original data, there is no clear boundary between positive and negative samples. There are a lot of "gray area" data that are difficult to distinguish near the positive and negative samples. These data will lead to biased learning of the model, making the model's prediction effect invalid on a small number of samples.

[0004] In the prior art, a variety of algorithms can be used to downsample the original data to avoid biased learning of the model. For example, a data-level sampling method can be used to downsample the original data based on the distance-based N-nearest neighbor algorithm; or, a cost-sensitive learning-based method can be used to provide higher weights for positive and negative samples, so that the numerical calculation of the final cost is biased in a specific direction; in addition, an integrated learning algorithm method can be used to combine a data-level or algorithm-level method with integrated learning to obtain a powerful integrated classifier, and so on.

[0005] However, these algorithms all need to process the entire amount of raw data. In actual application scenarios, due to the large amount of raw data, the computational cost of these algorithms will be too high, time-consuming, and consume a lot of computing resources. Summary of the invention

[0006] The present disclosure provides a data sampling method, device, electronic device and storage medium to at least solve the problems of high computing cost, long time consumption and large consumption of computing resources in related technologies. The technical solution of the present disclosure is as follows:

[0007] According to a first aspect of an embodiment of the present disclosure, a data sampling method is provided, including:

[0008] Acquire original data, wherein each original data includes an index value and at least one characteristic value, the original data is divided into positive samples and negative samples, the index value of the positive sample is greater than a preset threshold, and the index value of the negative sample is not greater than the preset threshold;

[0009] According to the index values ​​of the negative samples, the negative samples are divided into multiple groups;

[0010] Calculate the difference between the characteristic value of the negative sample and the characteristic value of the positive sample in each group;

[0011] According to the difference value, the group is divided into a difficult group and a non-difficult group;

[0012] The non-difficult group is subjected to stratified sampling to obtain non-difficult samples, and the positive samples, the negative samples in the difficult group and the non-difficult samples are used as sampling results of the original data.

[0013] Optionally, dividing the negative samples into a plurality of groups according to the index values ​​of the negative samples includes:

[0014] According to the index values ​​of the negative samples and the preset grouping rules, the negative samples are divided into a plurality of groups; or,

[0015] According to the index value of the negative sample, the negative sample is segmented into equal value segments, and the negative sample is divided into a preset number of groups.

[0016] Optionally, calculating the difference between the characteristic value of the negative sample in each group and the characteristic value of the positive sample includes:

[0017] Calculate a first statistical parameter of any characteristic value of each negative sample in any group;

[0018] Calculating a second statistical parameter of any one of the eigenvalues ​​of the positive sample;

[0019] Calculating the Euclidean distance between the first statistical parameter and the second statistical parameter to obtain a target difference value between the any characteristic value of the any group and the any characteristic value of the positive sample;

[0020] The target difference values ​​are averaged, and the average result is normalized to obtain the difference value between the characteristic value of the negative sample in any group and the characteristic value of the positive sample.

[0021] Optionally, the first statistical parameter and the second statistical parameter include any one or more of the following:

[0022] Mean, variance, 25th, 50th, and 75th quantiles.

[0023] Optionally, averaging the target difference values ​​and normalizing the average result to obtain the difference value between the characteristic value of the negative sample in any group and the characteristic value of the positive sample includes:

[0024] According to the preset weight of each eigenvalue, the target difference value is weighted and averaged, and the average result is normalized to obtain the difference value between the eigenvalue of the negative sample in any group and the eigenvalue of the positive sample.

[0025] Optionally, dividing the group into a difficult group and a non-difficult group according to the difference value includes:

[0026] Sorting the groups according to the order of the difference values ​​from large to small, and drawing a second-order difference curve of the groups based on the sorting result;

[0027] The difference value of the group corresponding to the first peak point of the second-order difference curve in reverse order is used as the screening threshold;

[0028] The group whose difference value is less than the screening threshold is regarded as a difficult group, and the group whose difference value is not less than the screening threshold is regarded as a non-difficult group.

[0029] Optionally, performing stratified sampling on the non-difficult group to obtain a non-difficult sample includes:

[0030] Calculate the number of samples of any non-difficult group according to the difference value of any non-difficult group and the number of negative samples in any non-difficult group;

[0031] According to the sampling quantity of the non-difficult group, the non-difficult group is sampled to obtain a non-difficult sample.

[0032] Optionally, calculating the number of samples of any non-difficult group according to the difference value of any non-difficult group and the number of negative samples in any non-difficult group includes:

[0033] When the difference value of any non-difficult group is not 1, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the number of samples of any non-difficult group;

[0034] When the difference value of any non-difficult group is 1, the difference value of any non-difficult group is set to a preset value or the maximum value of the difference values ​​of each non-difficult group, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the sampling number of any non-difficult group.

[0035] Optionally, after performing stratified sampling on the non-difficult group to obtain a non-difficult sample, the method further includes:

[0036] If the number of the non-difficult samples is less than the number of the positive samples, the non-difficult group is resampled according to the number of the positive samples so that the number of the obtained non-difficult samples is the same as the number of the positive samples.

[0037] Optionally, after performing stratified sampling on the non-difficult group to obtain non-difficult samples, and taking the positive samples, the negative samples in the difficult group, and the non-difficult samples as sampling results of the original data, the method further includes:

[0038] Using the sampling results to perform model training to obtain a target model;

[0039] The target model is used to process the test sample, and if the accuracy of the processing result reaches a preset accuracy threshold, it is determined that the sampling result meets the requirements.

[0040] According to a second aspect of an embodiment of the present disclosure, there is provided a data sampling device, comprising:

[0041] An acquisition unit is configured to acquire original data, wherein each original data includes an index value and at least one characteristic value, and the original data is divided into positive samples and negative samples, the index value of the positive sample is greater than a preset threshold, and the index value of the negative sample is not greater than the preset threshold;

[0042] A grouping unit, configured to divide the negative samples into a plurality of groups according to the index values ​​of the negative samples;

[0043] A calculation unit, configured to calculate a difference between a feature value of a negative sample in each group and a feature value of the positive sample;

[0044] a screening unit configured to divide the group into a difficult group and a non-difficult group according to the difference value;

[0045] The sampling unit is configured to perform stratified sampling on the non-difficult group to obtain non-difficult samples, and use the positive samples, the negative samples in the difficult group and the non-difficult samples as sampling results of the original data.

[0046] Optionally, the grouping unit is further configured to execute:

[0047] According to the index values ​​of the negative samples and the preset grouping rules, the negative samples are divided into a plurality of groups; or,

[0048] According to the index value of the negative sample, the negative sample is segmented into equal value segments, and the negative sample is divided into a preset number of groups.

[0049] Optionally, the computing unit is further configured to execute:

[0050] Calculate a first statistical parameter of any characteristic value of each negative sample in any group;

[0051] Calculating a second statistical parameter of any one of the eigenvalues ​​of the positive sample;

[0052] Calculating the Euclidean distance between the first statistical parameter and the second statistical parameter to obtain a target difference value between the any characteristic value of the any group and the any characteristic value of the positive sample;

[0053] The target difference values ​​are averaged, and the average result is normalized to obtain the difference value between the characteristic value of the negative sample in any group and the characteristic value of the positive sample.

[0054] Optionally, the first statistical parameter and the second statistical parameter include any one or more of the following:

[0055] Mean, variance, 25th, 50th, and 75th quantiles.

[0056] Optionally, the computing unit is further configured to execute:

[0057] According to the preset weight of each eigenvalue, the target difference value is weighted and averaged, and the average result is normalized to obtain the difference value between the eigenvalue of the negative sample in any group and the eigenvalue of the positive sample.

[0058] Optionally, the screening unit is configured to execute:

[0059] Sorting the groups according to the order of the difference values ​​from large to small, and drawing a second-order difference curve of the groups based on the sorting result;

[0060] The difference value of the group corresponding to the first peak point of the second-order difference curve in reverse order is used as the screening threshold;

[0061] The group whose difference value is less than the screening threshold is regarded as a difficult group, and the group whose difference value is not less than the screening threshold is regarded as a non-difficult group.

[0062] Optionally, the sampling unit is configured to execute:

[0063] Calculate the number of samples of any non-difficult group according to the difference value of any non-difficult group and the number of negative samples in any non-difficult group;

[0064] According to the sampling quantity of the non-difficult group, the non-difficult group is sampled to obtain a non-difficult sample.

[0065] Optionally, the sampling unit is further configured to execute:

[0066] When the difference value of any non-difficult group is not 1, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the number of samples of any non-difficult group;

[0067] When the difference value of any non-difficult group is 1, the difference value of any non-difficult group is set to a preset value or the maximum value of the difference values ​​of each non-difficult group, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the sampling number of any non-difficult group.

[0068] Optionally, the sampling unit is further configured to execute:

[0069] If the number of the non-difficult samples is less than the number of the positive samples, the non-difficult group is resampled according to the number of the positive samples so that the number of the obtained non-difficult samples is the same as the number of the positive samples.

[0070] Optionally, the device further comprises:

[0071] The verification unit is also configured to perform model training using the sampling results to obtain a target model; use the target model to process the test sample, and if the accuracy of the processing result reaches a preset accuracy threshold, it is determined that the sampling result meets the requirements.

[0072] According to a third aspect of an embodiment of the present disclosure, there is provided a data sampling electronic device, comprising:

[0073] processor;

[0074] a memory for storing instructions executable by the processor;

[0075] The processor is configured to execute the instructions to implement any of the data sampling methods described above.

[0076] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of a data sampling electronic device, the data sampling electronic device can execute any of the data sampling methods described above.

[0077] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising a computer program / instruction, wherein when the computer program / instruction is executed by a processor, the data sampling method described in any one of the above items is implemented.

[0078] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects:

[0079] Obtaining original data, wherein each original data includes an index value and at least one characteristic value, and the original data is divided into positive samples and negative samples, the index value of the positive sample is greater than a preset threshold, and the index value of the negative sample is not greater than the preset threshold; dividing the negative samples into multiple groups according to the index value of the negative sample; calculating the difference between the characteristic value of the negative sample and the characteristic value of the positive sample in each group; dividing the groups into difficult groups and non-difficult groups according to the difference value; performing stratified sampling on the non-difficult group to obtain non-difficult samples, and taking the positive samples, the negative samples in the difficult group, and the non-difficult samples as the sampling results of the original data.

[0080] In this way, by grouping the original data, the negative samples are divided into difficult groups and non-difficult groups. The difference between the difficult group and the positive samples is small, and it is difficult to distinguish them, so all of them are retained. The difference between the non-difficult group and the positive samples is large, so stratified sampling can be performed, and only a part of them needs to be retained. During the sampling process, it is not necessary to process the entire amount of original data, so less computing resources are consumed and less time is consumed.

[0081] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0082] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0083] Figure 1 The figure is a flow chart of a data sampling method according to an exemplary embodiment.

[0084] Figure 2 The figure is a difference value curve diagram drawn in descending order according to an exemplary embodiment.

[0085] Figure 3 According to an exemplary embodiment, a method based on Figure 2 The difference value graph shown is a first order difference graph.

[0086] Figure 4 According to an exemplary embodiment, a method based on Figure 3 The second-order difference graph is plotted from the first-order difference graph shown.

[0087] Figure 5 It is a block diagram of a data sampling device according to an exemplary embodiment.

[0088] Figure 6 It is a block diagram of an electronic device for data sampling according to an exemplary embodiment.

[0089] Figure 7 It is a block diagram of a device for data sampling according to an exemplary embodiment. DETAILED DESCRIPTION

[0090] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0091] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0092] Figure 1 is a flow chart of a data sampling method according to an exemplary embodiment. Figure 1 As shown, the data sampling method includes the following steps.

[0093] In step S11, original data is obtained, wherein each original data includes an index value and at least one characteristic value, and the original data is divided into positive samples and negative samples. The index value of the positive sample is greater than a preset threshold, and the index value of the negative sample is not greater than the preset threshold.

[0094] In the present disclosure, raw data is data used to train the model to be trained, and each raw data includes multiple data items, wherein the data item corresponding to the business indicator of the model to be trained can be called an indicator value, and the data item input into the model to be trained for predicting the indicator value can be called a feature value. The feature value can be one or more items, and there is no specific limitation.

[0095] According to the size of the index value, the original data can be divided into positive samples and negative samples, where the index value greater than the preset threshold is a positive sample, and the index value not greater than the preset threshold is a negative sample. The preset threshold can be determined according to the business indicator of the model to be trained.

[0096] For example, if the task of the model to be trained is to predict whether the number of views of the video can reach 1 million based on the input video features, then the video features are the feature values, the number of video views is the indicator value, and the preset threshold is 1 million.

[0097] In step S12, the negative samples are divided into a plurality of groups according to the index values ​​of the negative samples.

[0098] In this step, negative samples are divided into multiple groups according to the index values ​​of negative samples. Specifically, the negative samples can be divided into multiple groups according to the index values ​​of negative samples and preset grouping rules. Among them, the preset grouping rules can be determined according to the business experience of the model to be trained. For example, continuing the above example, for negative samples with a playback volume of less than 1 million, they can be divided into 4 groups according to 0-100,000, 100,000-500,000, 500,000-800,000 and 800,000-1 million. In this way, the grouping of negative samples is more reasonable, and can be adjusted according to the task indicators of the model to be trained, which is more targeted and the subsequent model training efficiency is also higher.

[0099] Alternatively, in another implementation, negative samples are divided into multiple groups according to their index values, or they can be divided into a preset number of groups by equally segmenting the negative samples according to their index values. Continuing with the above example, for video data with a playback volume of less than 1 million, it can be divided into ten equal parts to obtain ten groups of 0-100,000, 100,000-200,000, 200,000-300,000, 300,000-400,000, 400,000-500,000, 500,000-600,000, 600,000-700,000, 700,000-800,000, 800,000-900,000, and 900,000-1 million. In this way, the dependence on business experience can be reduced, and data sampling for new businesses and new indicators can be achieved.

[0100] In step S13, the difference between the feature values ​​of the negative samples and the feature values ​​of the positive samples in each group is calculated.

[0101] Each group includes at least one negative sample, and each negative sample has at least one eigenvalue. For each eigenvalue, the difference between the positive sample and the negative sample in each group can be calculated, and then the difference value between the positive sample and each group can be calculated based on the difference between the positive sample and each group for different eigenvalues.

[0102] Specifically, first, a first statistical parameter of any characteristic value of each negative sample in any group can be calculated, and a second statistical parameter of any characteristic value of the positive sample can be calculated. For example, the first statistical parameter and the second statistical parameter include any one or more of the following: mean, variance, 25th quantile, 50th quantile and 75th quantile, wherein the negative samples in the group are arranged from small to large according to the characteristic value and divided into four equal parts, and the characteristic values ​​of the negative samples at the three split points are the 25th quantile, 50th quantile and 75th quantile respectively.

[0103] In the present disclosure, the first statistical parameters can be respectively expressed as: first mean avg_group, first variance std_group, first 25th quantile 25_group, first 50th quantile 50_group and first 75th quantile 75_grou, and the second statistical parameters can be respectively expressed as: second mean avg_top, second variance std_top, second 25th quantile 25_top, second 50th quantile 50_top and second 75th quantile 75_top.

[0104] Then, the Euclidean distance between the first statistical parameter and the second statistical parameter is calculated to obtain a target difference value between any characteristic value of any group and any characteristic value of the positive sample.

[0105] For example, the following formula may be used to calculate the Euclidean distance between the first statistical parameter and the second statistical parameter:

[0106] diff_n=sqrt((avg_top-avg_group) 2 +(std_top - std_group) 2 +(25_top-25_group) 2 +(50_top-50_group) 2 +(75_top-75_group) 2 )

[0107] Among them, diff_n represents the target difference value between the group and the positive sample for the feature value n, and each feature value has its corresponding target difference value.

[0108] Then, the target difference values ​​are averaged and the average result is normalized to obtain the difference between the characteristic values ​​of the negative samples and the characteristic values ​​of the positive samples in any group.

[0109] Among them, the following formula can be used to calculate the average of the target difference value, and then the mean results of each group are normalized. In the normalization process, the difference value of the group with the largest mean result is set to 1, and the difference value of the group with the smallest mean result is set to 0, to obtain the difference value of each group:

[0110] diff_scale_i=(diff_1+diff_2+...+diff_n) / n

[0111] Among them, diff_scale_i represents the difference value between the group and the positive sample, diff_1, diff_2, ..., diff_n represent the target difference value of eigenvalue 1, the target difference value of eigenvalue 2, ..., the target difference value of eigenvalue n, respectively, and n represents the number of eigenvalues.

[0112] Alternatively, in another implementation, the target difference value may be weighted and averaged according to the preset weight of each eigenvalue, and then the average result may be normalized to obtain the difference value between the eigenvalue of the negative sample and the eigenvalue of the positive sample in any group.

[0113] In this way, data sampling can be adjusted according to the business needs of the model to be trained. If there is a strong need for a certain feature value, the preset weight of the feature value can be appropriately increased, so that data sampling is more reasonable and the effect of model training is further improved. For example, continuing the above example, it can be understood that the number of fans of the video author is highly correlated with the number of video views, so a larger preset weight can be set for the feature value of the number of fans of the video author.

[0114] In step S14 , the groups are divided into a difficult group and a non-difficult group according to the difference value.

[0115] In this step, based on the preset difference value threshold, for the group whose difference value is greater than the difference value threshold, it can be considered that the difference between the negative samples and the positive samples in the group is large, and they are negative samples that are easy to distinguish. Therefore, this group can be used as a non-difficult group. For the group whose difference value is not greater than the difference value threshold, it can be considered that the difference between the negative samples and the positive samples in the group is small, and they are negative samples that are not easy to distinguish. Therefore, this group can be used as a difficult group.

[0116] Alternatively, in another implementation, the following steps may be taken to divide the group into a difficult group and a non-difficult group:

[0117] First, the groups are sorted in descending order according to the difference values, and the second-order difference curve of the groups is drawn based on the sorting results; then, the difference value of the group corresponding to the first peak point of the second-order difference curve in reverse order is used as the screening threshold; further, the group with a difference value less than the screening threshold is regarded as a difficult group, and the group with a difference value not less than the screening threshold is regarded as a non-difficult group.

[0118] Among them, if a group corresponds to the peak point of the second-order difference curve, it means that the difference value of the next group of the group has undergone a mutation compared with the group. Since the difference values ​​are sorted from large to small, that is, the difference value of the next group of the group suddenly becomes smaller, and the smaller the difference value is, the smaller the difference between the positive sample and the negative sample in the group is, and the greater the difficulty of distinction. Therefore, the difference value of the group can be used as a screening threshold, and the group with a difference value less than the screening threshold is regarded as a difficult group. In other words, the group sorted after the group is regarded as a difficult group.

[0119] For example, Figure 2 As shown in FIG. 1 , a difference value curve is drawn according to the order of difference values ​​from large to small. The difference value curve is formed by connecting 10 points. The ten points 1-10 represent 10 groups whose difference values ​​are sorted from large to small, namely group 1, group 2, ..., group 10. The vertical axis is the difference value corresponding to each group. Figure 3 As shown, based on Figure 2 The difference value curve graph shown is a first-order difference curve graph. The first point is a null value, and the ordinate of the second point is based on Figure 2 The difference between the ordinates of the second point and the first point in is determined, that is, the first-order difference corresponding to group 1, and so on, the ordinate is the first-order difference value. Figure 4 As shown, based on Figure 3 The second-order difference curve plotted from the first-order difference curve shown in the figure shows that the first and second points both represent null values, and the third point is based on Figure 3 The difference between the ordinate of the third point in and the ordinate of the second point is determined, that is, the second-order difference corresponding to group 1, and so on. The ordinate is the second-order difference value.

[0120] exist Figure 4 In the reverse order, the first peak point is the seventh point. Figure 3 In the figure, corresponding to the sixth point, Figure 2 The corresponding group is Figure 2 Therefore, the difference value of group 5 is the screening threshold, and the groups with difference values ​​less than group 5 are regarded as difficult groups, that is, Figure 2 As shown, starting from group 6, the groups ranked after that are all difficult groups.

[0121] In step S15, stratified sampling is performed on the non-difficult group to obtain non-difficult samples, and the positive samples, negative samples in the difficult group and the non-difficult samples are used as the sampling results of the original data.

[0122] In this step, stratified sampling is performed on the non-difficult groups, and the same number of negative samples can be collected from each non-difficult group, or the number of samples corresponding to each non-difficult group can be determined according to the difference values ​​of each non-difficult group. In each non-difficult group, random sampling can be performed, or negative samples in the group can be screened before sampling, and there is no specific limitation.

[0123] In one implementation, performing stratified sampling on the non-difficulty group to obtain a non-difficulty sample may include the following steps:

[0124] First, the number of samples of any non-difficult group is calculated according to the difference value of any non-difficult group and the number of negative samples in any non-difficult group.

[0125] For example, the following formula can be used to calculate the number of samples for the non-difficult group:

[0126] sample_cnt_i=cnt_i*(1-diff_scale_i)

[0127] Among them, sample_cnt_i represents the number of samples of non-difficult group i, diff_scale_i represents the difference value of the group, and cnt_i represents the number of negative samples in the group.

[0128] It can be understood that in the process of determining the difference values ​​of each group, the difference value of the group with the largest mean result is set to 1 during normalization. Therefore, there is a group with a difference value of 1 in the non-difficult group. In this case, the difference value of this group can be adjusted.

[0129] Specifically, when the difference value of any non-difficult group is 1, the difference value of the non-difficult group can be set to a preset value or the maximum value of the difference values ​​of each non-difficult group. For example, the difference value of the group can be adjusted to 0.9, or the difference value of another group whose difference value is second only to that of the group can be used as the difference value of the group. Then, the above formula is used to calculate the number of samples of the group, that is, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the number of samples of any non-difficult group.

[0130] For the groups in the non-difficulty group whose difference value is not 1, the difference value may not be adjusted. The above formula is used to calculate the difference between 1 and the difference value of any non-difficulty group, and the product of the difference and the number of negative samples in any non-difficulty group is calculated as the sampling number of any non-difficulty group.

[0131] Then, according to the sampling quantity of the non-difficult group, the non-difficult group is sampled to obtain the non-difficult samples. In this way, the sampling results of the original data can be obtained, including positive samples, negative samples in the difficult group and non-difficult samples.

[0132] From the above, it can be seen that positive samples and non-difficult samples with large difference values ​​from positive samples are all easy-to-distinguish samples, among which the number of positive samples is often relatively small, and negative samples in the difficult group with small difference values ​​from positive samples are samples that are not easy to distinguish. All positive samples, all negative samples in the difficult group, and non-difficult samples obtained by sampling the non-difficult group are taken as sampling results. On the one hand, for samples that are difficult to distinguish, their training intensity is retained, and on the other hand, the total number of samples can be reduced.

[0133] In one implementation, after stratified sampling is performed on the non-difficult group to obtain non-difficult samples, the number of non-difficult samples can be further adjusted. Specifically, if the number of non-difficult samples is less than the number of positive samples, the non-difficult group is resampled according to the number of positive samples so that the number of non-difficult samples obtained is the same as the number of positive samples. Alternatively, the number of non-difficult samples can be adjusted to a preset sample threshold. In this way, it can be avoided that the number of non-difficult samples is too small, resulting in the failure of the training of the model to be trained on negative samples.

[0134] The resampling of the non-difficulty group may be to take the same number of samples from each non-difficulty group, or may be to determine the number of resamples corresponding to each non-difficulty group based on the difference value between the positive sample and each non-difficulty group, without specific limitation.

[0135] In the present disclosure, after obtaining the sampling results of the original data, the sampling results can be further used for model training to obtain a target model; the target model is used to process the test sample, and if the accuracy of the processing result reaches a preset accuracy threshold, the sampling result is judged to meet the requirements, thereby realizing the verification of the sampling result.

[0136] From the above, it can be seen that the technical solution provided by the embodiment of the present disclosure divides negative samples into difficult groups and non-difficult groups by grouping the original data. The difference between the difficult group and the positive samples is small and the distinction is difficult, so all of them are retained. The difference between the non-difficult group and the positive samples is large, so stratified sampling can be performed, and only a part of them needs to be retained. During the sampling process, it is not necessary to process the entire amount of original data, so less computing resources are consumed and less time is consumed.

[0137] Figure 5 is a block diagram of a data sampling device according to an exemplary embodiment, the device comprising:

[0138] The acquisition unit 201 is configured to acquire original data, wherein each original data includes an index value and at least one characteristic value, and the original data is divided into positive samples and negative samples, the index value of the positive sample is greater than a preset threshold, and the index value of the negative sample is not greater than the preset threshold;

[0139] A grouping unit 202 is configured to divide the negative samples into a plurality of groups according to the index values ​​of the negative samples;

[0140] A calculation unit 203 is configured to calculate a difference between a feature value of a negative sample in each group and a feature value of the positive sample;

[0141] A screening unit 204 is configured to divide the group into a difficult group and a non-difficult group according to the difference value;

[0142] The sampling unit 205 is configured to perform stratified sampling on the non-difficult group to obtain non-difficult samples, and use the positive samples, the negative samples in the difficult group and the non-difficult samples as sampling results of the original data.

[0143] In one implementation, the grouping unit 202 is further configured to execute:

[0144] According to the index values ​​of the negative samples and the preset grouping rules, the negative samples are divided into a plurality of groups; or,

[0145] According to the index value of the negative sample, the negative sample is segmented into equal value segments, and the negative sample is divided into a preset number of groups.

[0146] In one implementation, the computing unit 203 is further configured to execute:

[0147] Calculate a first statistical parameter of any characteristic value of each negative sample in any group;

[0148] Calculating a second statistical parameter of any one of the eigenvalues ​​of the positive sample;

[0149] Calculating the Euclidean distance between the first statistical parameter and the second statistical parameter to obtain a target difference value between the any characteristic value of the any group and the any characteristic value of the positive sample;

[0150] The target difference values ​​are normalized and averaged to obtain the difference values ​​between the characteristic values ​​of the negative samples in any group and the characteristic values ​​of the positive samples.

[0151] In one implementation, the first statistical parameter and the second statistical parameter include any one or more of the following:

[0152] Mean, variance, 25th, 50th, and 75th quantiles.

[0153] In one implementation, the computing unit 203 is further configured to execute:

[0154] Normalizing the target difference value to obtain a normalized target difference value;

[0155] According to the preset weight of each eigenvalue, the normalized target difference value is weighted and averaged to obtain the difference value between the eigenvalue of the negative sample in any group and the eigenvalue of the positive sample.

[0156] In one implementation, the screening unit 204 is configured to perform:

[0157] Sorting the groups according to the order of the difference values ​​from large to small, and drawing a second-order difference curve of the groups based on the sorting result;

[0158] The difference value of the group corresponding to the first peak point of the second-order difference curve in reverse order is used as the screening threshold;

[0159] The group whose difference value is less than the screening threshold is regarded as a difficult group, and the group whose difference value is not less than the screening threshold is regarded as a non-difficult group.

[0160] In one implementation, the sampling unit 205 is configured to execute:

[0161] Calculate the number of samples of any non-difficult group according to the difference value of any non-difficult group and the number of negative samples in any non-difficult group;

[0162] According to the sampling quantity of the non-difficult group, the non-difficult group is sampled to obtain a non-difficult sample.

[0163] In one implementation, the sampling unit 205 is further configured to execute:

[0164] When the difference value of any non-difficult group is not 1, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the number of samples of any non-difficult group;

[0165] When the difference value of any non-difficult group is 1, the difference value of any non-difficult group is set to a preset value or the maximum value of the difference values ​​of each non-difficult group, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the sampling number of any non-difficult group.

[0166] In one implementation, the sampling unit 205 is further configured to execute:

[0167] If the number of the non-difficult samples is less than the number of the positive samples, the non-difficult group is resampled according to the number of the positive samples so that the number of the obtained non-difficult samples is the same as the number of the positive samples.

[0168] In one implementation, the device further includes:

[0169] The verification unit is also configured to perform model training using the sampling results to obtain a target model; use the target model to process the test sample, and if the accuracy of the processing result reaches a preset accuracy threshold, it is determined that the sampling result meets the requirements.

[0170] From the above, it can be seen that the technical solution provided by the embodiment of the present disclosure divides negative samples into difficult groups and non-difficult groups by grouping the original data. The difference between the difficult group and the positive samples is small and the distinction is difficult, so all of them are retained. The difference between the non-difficult group and the positive samples is large, so stratified sampling can be performed, and only a part of them needs to be retained. During the sampling process, it is not necessary to process the entire amount of original data, so less computing resources are consumed and less time is consumed.

[0171] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0172] Figure 6 It is a block diagram of an electronic device for data sampling according to an exemplary embodiment.

[0173] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory including instructions, and the above instructions can be executed by a processor of an electronic device to perform the above method. Optionally, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0174] In an exemplary embodiment, a computer program product is also provided. When the computer program product is executed on a computer, the computer implements the above data sampling method.

[0175] From the above, it can be seen that the technical solution provided by the embodiment of the present disclosure divides negative samples into difficult groups and non-difficult groups by grouping the original data. The difference between the difficult group and the positive samples is small and the distinction is difficult, so all of them are retained. The difference between the non-difficult group and the positive samples is large, so stratified sampling can be performed, and only a part of them needs to be retained. During the sampling process, it is not necessary to process the entire amount of original data, so less computing resources are consumed and less time is consumed.

[0176] Figure 7 is a block diagram of a device 800 for data sampling according to an exemplary embodiment.

[0177] For example, apparatus 800 may be a mobile phone, a computer, a digital broadcast electronic device, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0178] Reference Figure 7 , the device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .

[0179] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0180] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0181] The power supply component 807 provides power to the various components of the device 800. The power supply component 807 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.

[0182] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0183] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the device 800 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.

[0184] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0185] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the device 800, and the sensor assembly 814 can also detect the position change of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0186] The communication component 816 is configured to facilitate wired or wireless communication between the device 800 and other devices. The device 800 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0187] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to execute the methods described in the first and second aspects.

[0188] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by the processor 820 of the device 800 to complete the above method. Optionally, for example, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0189] In an exemplary embodiment, a computer program product including instructions is also provided. When the computer program product is run on a computer, the computer is enabled to execute the data sampling method described in any one of the above embodiments.

[0190] From the above, it can be seen that the technical solution provided by the embodiment of the present disclosure divides negative samples into difficult groups and non-difficult groups by grouping the original data. The difference between the difficult group and the positive samples is small and the distinction is difficult, so all of them are retained. The difference between the non-difficult group and the positive samples is large, so stratified sampling can be performed, and only a part of them needs to be retained. During the sampling process, it is not necessary to process the entire amount of original data, so less computing resources are consumed and less time is consumed.

[0191] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0192] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A data sampling method, characterized in that: include: Acquire raw data, wherein each raw data includes an index value and at least one characteristic value, the raw data is divided into positive samples and negative samples, the index value of the positive sample is greater than a preset threshold, and the index value of the negative sample is not greater than the preset threshold; wherein the raw data includes data for training a model to be trained, the model to be trained is used to predict whether the playback volume of a video reaches a preset threshold according to input video features, the characteristic value includes the video feature, and the index value includes the video playback volume; According to the index values ​​of the negative samples, the negative samples are divided into multiple groups; Calculate the difference between the characteristic value of the negative sample in each group and the characteristic value of the positive sample, wherein the difference is the normalized result of the Euclidean distance of each characteristic value between each negative sample and the positive sample in each group; According to the difference value, the group is divided into a difficult group and a non-difficult group, wherein the difficult group is a group whose difference value is less than a screening threshold, and the non-difficult group is a group whose difference value is not less than the screening threshold; The non-difficult group is subjected to stratified sampling, and part of the samples in the non-difficult group is retained to obtain non-difficult samples, and the positive samples, the negative samples in the difficult group and the non-difficult samples are used as sampling results of the original data.

2. The data sampling method according to claim 1, characterized in that: The negative samples are divided into a plurality of groups according to the index values ​​of the negative samples, including: According to the index values ​​of the negative samples and the preset grouping rules, the negative samples are divided into a plurality of groups; or, According to the index value of the negative sample, the negative sample is segmented into equal value segments, and the negative sample is divided into a preset number of groups.

3. The data sampling method according to claim 1, characterized in that: The calculating the difference between the characteristic value of the negative sample in each group and the characteristic value of the positive sample comprises: Calculate a first statistical parameter of any eigenvalue of each negative sample in any group; Calculating a second statistical parameter of any one of the eigenvalues ​​of the positive sample; Calculating the Euclidean distance between the first statistical parameter and the second statistical parameter to obtain a target difference value between the any characteristic value of the any group and the any characteristic value of the positive sample; The target difference values ​​are averaged, and the average result is normalized to obtain the difference value between the characteristic value of the negative sample in any group and the characteristic value of the positive sample.

4. The data sampling method according to claim 3, characterized in that: The first statistical parameter and the second statistical parameter include any one or more of the following: Mean, variance, 25th, 50th, and 75th quantiles.

5. The data sampling method according to claim 3, characterized in that: The averaging the target difference values ​​and normalizing the average result to obtain the difference value between the characteristic value of the negative sample in any group and the characteristic value of the positive sample includes: According to the preset weight of each eigenvalue, the target difference value is weighted and averaged, and the average result is normalized to obtain the difference value between the eigenvalue of the negative sample in any group and the eigenvalue of the positive sample.

6. The data sampling method according to claim 1, characterized in that: The group is divided into a difficult group and a non-difficult group according to the difference value, including: Sorting the groups according to the order of the difference values ​​from large to small, and drawing a second-order difference curve of the groups based on the sorting result; The difference value of the group corresponding to the first peak point of the second-order difference curve in reverse order is used as the screening threshold; The group whose difference value is less than the screening threshold is regarded as a difficult group, and the group whose difference value is not less than the screening threshold is regarded as a non-difficult group.

7. The data sampling method according to claim 1, characterized in that: The performing stratified sampling on the non-difficult group and retaining part of the samples in the non-difficult group to obtain a non-difficult sample includes: Calculate the number of samples of any non-difficult group according to the difference value of any non-difficult group and the number of negative samples in any non-difficult group; According to the sampling quantity of the non-difficult group, the non-difficult group is sampled to obtain a non-difficult sample.

8. The data sampling method according to claim 7, characterized in that: The calculating the number of samples of any non-difficult group according to the difference value of any non-difficult group and the number of negative samples in any non-difficult group includes: When the difference value of any non-difficult group is not 1, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the number of samples of any non-difficult group; When the difference value of any non-difficult group is 1, the difference value of any non-difficult group is set to a preset value or the maximum value of the difference values ​​of each non-difficult group, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the sampling number of any non-difficult group.

9. The data sampling method according to claim 1, characterized in that: After performing stratified sampling on the non-difficult group to obtain a non-difficult sample, the method further includes: If the number of the non-difficult samples is less than the number of the positive samples, the non-difficult group is resampled according to the number of the positive samples so that the number of the obtained non-difficult samples is the same as the number of the positive samples.

10. The data sampling method according to claim 1, characterized in that: After performing stratified sampling on the non-difficult group to obtain non-difficult samples, and taking the positive samples, the negative samples in the difficult group, and the non-difficult samples as sampling results of the original data, the method further includes: Using the sampling results to perform model training to obtain a target model; The target model is used to process the test sample, and if the accuracy of the processing result reaches a preset accuracy threshold, it is determined that the sampling result meets the requirements.

11. A data sampling device, characterized in that: include: The acquisition unit is configured to execute acquisition of raw data, wherein each raw data includes an index value and at least one characteristic value, the raw data is divided into positive samples and negative samples, the index value of the positive sample is greater than a preset threshold, and the index value of the negative sample is not greater than the preset threshold; wherein the raw data includes data for training a model to be trained, the model to be trained is used to predict whether the playback volume of a video reaches a preset threshold according to input video features, the characteristic value includes the video feature, and the index value includes the video playback volume; A grouping unit, configured to divide the negative samples into a plurality of groups according to the index values ​​of the negative samples; A calculation unit is configured to calculate a difference between a characteristic value of a negative sample in each group and a characteristic value of the positive sample, wherein the difference is a normalized result of a Euclidean distance of each characteristic value between each negative sample and the positive sample in each group; a screening unit configured to divide the group into a difficult group and a non-difficult group according to the difference value, wherein the difficult group is a group whose difference value is less than a screening threshold, and the non-difficult group is a group whose difference value is not less than the screening threshold; The sampling unit is configured to perform stratified sampling on the non-difficult group, retain part of the samples in the non-difficult group to obtain non-difficult samples, and use the positive samples, the negative samples in the difficult group and the non-difficult samples as the sampling results of the original data.

12. The data sampling device according to claim 11, characterized in that: The grouping unit is further configured to execute: According to the index values ​​of the negative samples and the preset grouping rules, the negative samples are divided into a plurality of groups; or, According to the index value of the negative sample, the negative sample is segmented into equal value segments, and the negative sample is divided into a preset number of groups.

13. The data sampling device according to claim 11, characterized in that: The computing unit is further configured to execute: Calculate a first statistical parameter of any eigenvalue of each negative sample in any group; Calculating a second statistical parameter of any one of the eigenvalues ​​of the positive sample; Calculating the Euclidean distance between the first statistical parameter and the second statistical parameter to obtain a target difference value between the any characteristic value of the any group and the any characteristic value of the positive sample; The target difference values ​​are averaged, and the average result is normalized to obtain the difference value between the characteristic value of the negative sample in any group and the characteristic value of the positive sample.

14. The data sampling device according to claim 13, characterized in that: The first statistical parameter and the second statistical parameter include any one or more of the following: Mean, variance, 25th, 50th, and 75th quantiles.

15. The data sampling device according to claim 13, characterized in that: The computing unit is further configured to execute: According to the preset weight of each eigenvalue, the target difference value is weighted and averaged, and the average result is normalized to obtain the difference value between the eigenvalue of the negative sample in any group and the eigenvalue of the positive sample.

16. The data sampling device according to claim 11, characterized in that: The screening unit is configured to perform: Sorting the groups according to the order of the difference values ​​from large to small, and drawing a second-order difference curve of the groups based on the sorting result; The difference value of the group corresponding to the first peak point of the second-order difference curve in reverse order is used as the screening threshold; The group whose difference value is less than the screening threshold is regarded as a difficult group, and the group whose difference value is not less than the screening threshold is regarded as a non-difficult group.

17. The data sampling device according to claim 11, characterized in that: The sampling unit is configured to perform: Calculate the number of samples of any non-difficult group according to the difference value of any non-difficult group and the number of negative samples in any non-difficult group; According to the sampling quantity of the non-difficult group, the non-difficult group is sampled to obtain a non-difficult sample.

18. The data sampling device according to claim 17, characterized in that: The sampling unit is further configured to execute: When the difference value of any non-difficult group is not 1, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the number of samples of any non-difficult group; When the difference value of any non-difficult group is 1, the difference value of any non-difficult group is set to a preset value or the maximum value of the difference values ​​of each non-difficult group, the difference between 1 and the difference value of any non-difficult group is calculated, and the product of the difference and the number of negative samples in any non-difficult group is calculated as the sampling number of any non-difficult group.

19. The data sampling device according to claim 11, characterized in that: The sampling unit is further configured to execute: If the number of the non-difficult samples is less than the number of the positive samples, the non-difficult group is resampled according to the number of the positive samples so that the number of the obtained non-difficult samples is the same as the number of the positive samples.

20. The data sampling device according to claim 11, characterized in that: The device also includes: The verification unit is also configured to perform model training using the sampling results to obtain a target model; use the target model to process the test sample, and if the accuracy of the processing result reaches a preset accuracy threshold, it is determined that the sampling result meets the requirements.

21. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the data sampling method according to any one of claims 1 to 10.

22. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of a data sampling electronic device, the data sampling electronic device is enabled to perform the data sampling method according to any one of claims 1 to 10.

23. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the data sampling method according to any one of claims 1 to 10 is implemented.