Unbalanced data and image processing method, system and computer device
By constructing an RBF neural network data generation model based on the maximum distribution algorithm based on Hausdorff distance, a new sample set is generated, which solves the problem of low minority class recognition rate in unbalanced data processing in the existing technology and achieves the balance of the data set. performance improvements and improved analytical accuracy.
Patent Information
- Application Number
- CN202111485510.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2041-12-07
AI Technical Summary
Existing technologies lack effective methods to improve the recognition rate of minority classes when dealing with imbalanced data. Existing methods such as resampling technology and SMOTE fail to fully consider the actual distribution characteristics of the data set, resulting in poor recognition results.
The maximum distribution algorithm based on Hausdorff distance is used to construct the RBF neural network data generation model. By generating new sample sets, adjusting unbalanced data sets, adaptively learning intra-class and inter-class distributions, and automatically expanding minority class samples to form Balance the data set.
Effectively improve the imbalance of data, improve the accuracy of data analysis, improve the recognition rate of minority classes, and enhance the recognition ability of classifiers.
Smart Images

Figure CN114254698B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data analysis and processing, and in particular to a method, system and computer equipment for processing unbalanced data and images. Background Art
[0002] In the same data set, one or part of the classes has very few samples (positive class or minority class), while another or other part of the classes has relatively many samples (negative class or majority class), and the difference in the number of samples contained in these two parts is very large. The data set that meets this situation is called an imbalanced data set. In an imbalanced data set, since the number of minority class samples is small, it cannot provide enough information to the classifier during classification learning, while the majority class has a large number of samples, which provides enough information for the classifier. This makes it easier for the classifier to identify the majority class during the classification process, and the recognition rate of the minority class is very low.
[0003] In real life, there are many fields that require knowledge modeling and analysis for data imbalance, such as the following fields: medical information-assisted diagnosis, large-scale advertising spam processing, multimedia information retrieval, credit card fraud detection, text information classification, etc. In many related fields, the identification and classification of minority classes are crucial, and the correct identification of minority classes is far more significant to the entire classification learning than the correct identification of majority class samples. For example, in medical information-assisted diagnosis, doctors' diagnoses can be divided into four situations: normal people are correctly diagnosed as normal, sick people are correctly diagnosed as sick, normal people are misdiagnosed as sick, and sick people are misdiagnosed as normal. In this process, if the doctor misdiagnoses a normal person as a patient, it will bring very serious psychological and financial pressure to the normal person. However, if a patient is misdiagnosed as a healthy person by the auxiliary medical diagnosis system, it is very likely that the patient will not be treated in time. Among these four situations, misdiagnosing a patient as normal is the rarest one in reality, which can be regarded as a minority class, while the other three situations occur more frequently and are regarded as the majority class. However, among the existing classification methods, most methods have a high recognition rate for the majority class, but a very low recognition rate for the minority class, which does not reflect the true role of the classifier.
[0004] The main method for dealing with imbalanced data is to use resampling technology to undersample or oversample the samples to adjust the imbalance of the sample set. Common methods for adjusting imbalanced data from the perspective of minority classes include: random oversampling, SMOTE, borderline-SMOTE, etc. These methods do not take into account the data distribution characteristics of the actual data set, and have a certain degree of randomness and blindness, which affects the classification effect.
[0005] Therefore, it is necessary to provide a more reliable solution. Summary of the invention
[0006] The technical problem to be solved by the present invention is to provide an unbalanced data and image processing method, system and computer device in view of the deficiencies in the above-mentioned prior art.
[0007] In order to solve the above technical problems, the technical solution adopted by the present invention is: to provide an unbalanced data and image processing method, comprising the following steps:
[0008] 1) Preprocess the imbalanced data set O;
[0009] 2) The preprocessed unbalanced data set O is processed using a maximum distribution algorithm based on Hausdorff distance to determine the parameters of the RBF neural network data generation model to be constructed; the parameters include hidden layer neurons of the RBF neural network data generation model, the category, output weight and diagonal distribution matrix corresponding to each hidden layer neuron, and the connection weight between each hidden layer neuron and the corresponding output neuron;
[0010] 3) Building a RBF neural network data generation model based on the results of step 2);
[0011] 4) Use the constructed RBF neural network data generation model combined with the mvnrnd function to generate data and obtain the generated sample set S;
[0012] 5) Fill the generated sample set S into the original unbalanced data set O to obtain the processed balanced data set O s , O s =O∪S.
[0013] Preferably, the step 1) is specifically:
[0014] The missing values of numerical attributes in the imbalanced data set O are filled with the mean value of the attribute in the same sample; the missing values of ordinal attributes and nominal attributes are filled with the value with the highest frequency of the attribute in the same sample;
[0015] After data completion, ordinal and nominal attributes are sequentially coded;
[0016] The image data in the unbalanced data set O is converted into numerical data and added to O based on the PyRadiomics toolkit. All attributes are standardized using the z-score method to obtain the preprocessed data set D.
[0017] Use vector L mean and L std The mean and standard deviation of each attribute are saved separately, and the order encoding of ordinal and nominal attributes is saved.
[0018] Preferably, step 2) specifically includes:
[0019] 2-1) Assume that there are N input samples {x n , n = 1, 2,..., N} in the dataset D. Each sample has M attributes, and each sample belongs to one of the C classes. The number of samples in the c-th class is N c , c = 1, 2,..., C;
[0020] 2-2) Divide the samples in the dataset according to their所属类别, and obtain the data subset D c composed of the samples belonging to the c-th class, c = 1, 2,..., C; Initialize, let the current class index c = 0, and the current number of hidden layer neurons P = 0;
[0021] 2-3) Let c = c + 1;
[0022] 2-4) Let P = P + 1, and calculate the Hausdorff distance h c between D P and other samples. The corresponding sample is used as the center k P of a newly added hidden layer neuron in the c-th class; Calculate the Euclidean distance from all samples in D c to k P . Record the subset d P composed of all samples with distances less than h c , and delete d c from D c ; Use the number of samples in d c as the connection weight w P between k P and the output neuron of the corresponding class, and the connection weights between k P and the output neurons of other classes are 0; Calculate the variance v c of each dimension attribute in d m , and form the diagonal distribution matrix P corresponding to k
[0023] 2-5) If the number of remaining samples in D c is not 0, then go back to step 2-4); Otherwise, check whether c is equal to C. If c < C, then go back to step 2-3). If c = C, then the algorithm terminates.
[0024] Preferably, step 3) specifically includes:
[0025] 3-1) According to each sample in the dataset D having M attributes, determine that the input layer of the RBF neural network data generation model has M input neurons, and each neuron corresponds to an attribute;
[0026] 3-2) Determine that the output layer of the RBF neural network data generation model has C output neurons according to the C categories in the data set D, and each neuron corresponds to a category;
[0027] 3-3) According to the result of step 2), obtain P hidden layer neurons {k1, k2,..., k P-1 , k P} and their corresponding categories and output weights {w1, w2,..., w P-1 , w P}, as well as the corresponding P diagonal distribution matrices {V1, V2,..., V P-1 , V P}, determine the parameters of the P hidden layer neurons {(k1, V1), (k2, V3),..., (k P-1 , V P-1 ), (k P , V P )}, and the connection weights {w1, w2,..., w P-1 , w P} between each hidden layer neuron and the corresponding output neuron.
[0028] Preferably, step 4) specifically includes:
[0029] 4-1) Set the number of samples S to be generated for each category, c = 1, 2,..., C; perform initialization, let the current hidden layer neuron center index p = 0, and the generated sample set c represent an empty set; 4-2) Let p = p + 1. Assume that the current hidden layer neuron center k P belongs to category c, then the number of generated samples corresponding to k P is
[0031] 4-3) The generated sample matrix where each sample belongs to category c; merge into the generated sample set S, check whether p is equal to P. If p < P, go back to step 4-2); if p = P, obtain the complete generated sample set S and execute the next step;
[0032] 4-4) According to the mean vector L mean and standard deviation L std of all attributes saved during preprocessing, perform inverse standardization on S; according to the sequential encoding method of ordinal attributes and nominal attributes, convert the corresponding numerical values in S back to the original values of ordinal attributes and nominal attributes.
[0033] The present invention also provides an unbalanced data and image processing system, which uses the above method to process unbalanced data, and the system includes:
[0034] A data preprocessing module, which is used to preprocess the unbalanced data set O according to the method of step 1) to obtain a data set D;
[0035] A maximum distribution algorithm module, which is used to determine the parameters of the RBF neural network data generation model to be constructed according to the method of step 2);
[0036] A network model building module, which builds an RBF neural network data generation model according to the method of step 3);
[0037] The RBF neural network data generation model combines the mvnrnd function to adaptively generate a new data set S according to the distribution of the original unbalanced data set according to the method of step 4);
[0038] And the data post-processing module fills the generated sample set S into the original unbalanced data set O to obtain the processed balanced data set O s .
[0039] The present invention also provides a storage medium on which a computer program is stored, and when the program is executed, it is used to implement the method as described above.
[0040] The present invention also provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described above when executing the computer program.
[0041] The beneficial effects of the present invention are as follows: the unbalanced data and image processing method provided by the present invention can handle missing values and different types of attributes, adaptively learn the intra-class and inter-class distribution of original unbalanced data, and automatically generate data by category to expand the minority classes in the original data, thereby effectively improving the imbalance of the data and improving the accuracy of data analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 is a flow chart of the unbalanced data and image processing method of the present invention;
[0043] Figure 2 It is a schematic diagram of the principle structure of the RBF neural network data generation model of the present invention. DETAILED DESCRIPTION
[0044] The present invention is further described in detail below in conjunction with embodiments so that those skilled in the art can implement the invention with reference to the description.
[0045] It should be understood that terms such as “having”, “including” and “comprising” used herein do not exclude the existence or addition of one or more other elements or combinations thereof.
[0046] Example 1
[0047] Reference Figure 1 , an unbalanced data and image processing method of this embodiment includes the following steps:
[0048] S1. Preprocess the imbalanced data set O:
[0049] The missing values of numerical attributes in the imbalanced data set O are filled with the mean value of the attribute in the same sample; the missing values of ordinal attributes and nominal attributes are filled with the value with the highest frequency of the attribute in the same sample;
[0050] After data completion, ordinal and nominal attributes are sequentially coded;
[0051] The image data in the unbalanced data set O is converted into numerical data and added to O based on the PyRadiomics toolkit, and all attributes are standardized using the z-score method to obtain the preprocessed data set D; wherein the data types in the unbalanced data set O include numerical data and image data, etc.;
[0052] Use vector L mean and L std The mean and standard deviation of each attribute are saved separately, and the order encoding of ordinal and nominal attributes is saved.
[0053] S2. The preprocessed unbalanced data set O is processed using the maximum distribution algorithm based on Hausdorff distance to determine the parameters of the RBF neural network data generation model to be constructed; the parameters include the hidden layer neurons of the RBF neural network data generation model, the category, output weight and diagonal distribution matrix corresponding to each hidden layer neuron, and the connection weight between each hidden layer neuron and the corresponding output neuron; specifically including:
[0054] S2-1) Assume that there are N input samples {x n , n = 1, 2, ..., N}, each sample has M attributes, each sample belongs to one of C categories, and the number of samples in the cth category is N c , c = 1, 2, ..., C;
[0055] S2-2) Divide the samples in the data set according to their categories to obtain a data subset D consisting of samples belonging to the cth category. c, where \(c = 1, 2, \ldots, C\); Initialize by setting the current class index \(c = 0\) and the current number of hidden layer neurons \(P = 0\);
[0056] S2 - 3) Let \(c=c + 1\);
[0057] S2 - 4) Let \(P = P+1\), calculate the Hausdorff distance \(h\) c between \(D\) P and other samples, and use the corresponding sample as the center \(k\) of a newly added hidden layer neuron in the \(c\)-th class; P Calculate the Euclidean distance from all samples in \(D\) c to \(k\) P , record the subset \(d\) consisting of all samples with distances less than \(h\) P , and delete \(d\) c from \(D\) c ; Use the number of samples in \(d\) c as the connection weight \(w\) c between \(k\) P and the output neuron of the corresponding class, and set the connection weights between \(k\) P and the output neurons of other classes to 0; Calculate the variance \(v\) P of each dimension attribute in \(d\) c , and form the diagonal distribution matrix m corresponding to \(k\) P ;
[0058] S2 - 5) If the number of remaining samples in \(D\) c is not 0, go back to step 2 - 4); Otherwise, check if \(c\) is equal to \(C\). If \(c < C\), go back to step S2 - 3), and if \(c = C\), the algorithm terminates.
[0059] S3. Based on the results of step S2), construct an RBF neural network data generation model, specifically including:
[0060] S3 - 1) According to each sample in the dataset \(D\) having \(M\) attributes, determine that the input layer of the RBF neural network data generation model has \(M\) input neurons, and each neuron corresponds to an attribute;
[0061] S3 - 2) According to the dataset \(D\) having a total of \(C\) classes, determine that the output layer of the RBF neural network data generation model has \(C\) output neurons, and each neuron corresponds to a class;
[0062] S3 - 3) According to the results of step S2), obtain \(P\) hidden layer neurons \(\{k_1, k_2, \ldots, k\) P-1 , \(k\) P \}\) and their corresponding classes and output weights \(\{w_1, w_2, \ldots, w\) P-1 , \(w\) P}, and the corresponding P diagonal distribution matrices {V1, V2, …, V P-1 , V P}, determine the parameters of P hidden layer neurons {(k1, V1), (k2, V3), …, (k P-1 , V P-1 ), (k P , V P ), and the connection weights {w1, w2, …, w P-1 , w P} between each hidden layer neuron and the corresponding output neuron.
[0063] Among them, it is assumed that the 1st and 2nd hidden layer neurons belong to category 1, and the (P - 1)th and Pth hidden layer neurons belong to category C.
[0064] The principle structure of the constructed RBF neural network data generation model is as Figure 2 shown.
[0065] S4. Use the constructed RBF neural network data generation model combined with the mvnrnd function to generate data, and obtain the generated sample set S, specifically including:
[0066] S4 - 1) Set the number of samples Sc to be generated for each category, c = 1, 2, …, C; perform initialization, let the current hidden layer neuron center index p = 0, and the generated sample set c represent an empty set;
[0067] S4 - 2) Let p = p + 1. Assume that the current hidden layer neuron center k P belongs to category c, then the number of generated samples corresponding to k P is
[0068] S4 - 3) The generated sample matrix where each sample belongs to category c; merge into the generated sample set S, check whether p is equal to P. If p < P, go back to step S4 - 2); if p = P, obtain the complete generated sample set S, and execute the next step;
[0069] S4 - 4) According to the mean vector L mean and standard deviation L std of all attributes saved during preprocessing, perform inverse standardization on S; according to the order encoding methods of ordinal attributes and nominal attributes, convert the corresponding numerical values in S back to the original values of ordinal attributes and nominal attributes.
[0070] S5. Fill the generated sample set S into the original unbalanced data set O to obtain the processed balanced data set O. s , O s =O∪S.
[0071] Example 2
[0072] This embodiment provides an unbalanced data and image processing system, which uses the method of embodiment 1 to process unbalanced data. The system includes:
[0073] A data preprocessing module, which is used to preprocess the unbalanced data set O according to the method of step 1) to obtain a data set D;
[0074] A maximum distribution algorithm module, which is used to determine the parameters of the RBF neural network data generation model to be constructed according to the method of step 2);
[0075] A network model building module, which builds an RBF neural network data generation model according to the method of step 3);
[0076] The RBF neural network data generation model combines the mvnrnd function to adaptively generate a new data set S according to the distribution of the original unbalanced data set according to the method of step 4);
[0077] And the data post-processing module fills the generated sample set S into the original unbalanced data set O to obtain the processed balanced data set O s .
[0078] This embodiment also provides a storage medium on which a computer program is stored. When the program is executed, it is used to implement the method of embodiment 1.
[0079] This embodiment also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the method of Embodiment 1 is implemented when the processor executes the computer program.
[0080] Although the embodiments of the present invention have been disclosed as above, they are not limited to the applications listed in the specification and the implementation modes. They can be fully applied to various fields suitable for the present invention. For those familiar with the art, additional modifications can be easily implemented. Therefore, without departing from the general concept defined by the claims and the scope of equivalents, the present invention is not limited to specific details.
Claims
1. A method for processing unbalanced data and images, characterized in that: The following steps are involved: 1) Preprocessing the unbalanced data set O, wherein the unbalanced data set O includes an image data set; 2) The preprocessed unbalanced data set O is processed using a maximum distribution algorithm based on Hausdorff distance to determine the parameters of the RBF neural network data generation model to be constructed; the parameters include hidden layer neurons of the RBF neural network data generation model, the category, output weight and diagonal distribution matrix corresponding to each hidden layer neuron, and the connection weight between each hidden layer neuron and the corresponding output neuron; 3) Building a RBF neural network data generation model based on the results of step 2); 4) Use the constructed RBF neural network data generation model combined with the mvnrnd function to generate data and obtain the generated sample set S; 5) Fill the generated sample set S into the original unbalanced data set O to obtain the processed balanced data set O s , O s =O∪S; The step 1) is specifically as follows: The missing values of numerical attributes in the imbalanced data set O are filled with the mean value of the attribute in the same sample; the missing values of ordinal attributes and nominal attributes are filled with the value with the highest frequency of the attribute in the same sample; After data completion, ordinal and nominal attributes are sequentially coded; The image data in the unbalanced data set O is converted into numerical data and added to O based on the PyRadiomics toolkit. All attributes are standardized using the z-score method to obtain the preprocessed data set D. Use vector L mean and L std Save the mean and standard deviation of each attribute separately, and save the order encoding of ordinal and nominal attributes; The step 2) specifically includes: 2-1) Assume that there are N input samples {x n ,n=1,2,…,N}, each sample has M attributes, each sample belongs to one of C categories, and the number of samples in the cth category is N c , c=1,2,…,C; 2-2) Divide the samples in the data set according to their categories to obtain a data subset D consisting of samples belonging to category c c , c=1, 2, …, C; initialize, set the current category index c=0, the current number of hidden layer neurons P=0; 2-3) Let c = c + 1; 2-4) Let P = P + 1, calculate D c The Hausdorff distance h between the samples P , the corresponding sample is used as a hidden layer neuron center k added to the cth class P ; Calculate D c All samples in k P The Euclidean distance is recorded as less than h. P The corresponding subset d consists of all samples c , and d c From D c Delete from ; c The number of samples in k is P The connection weight w between the output neurons of the corresponding category P , k P The connection weights between the output neurons of other categories are 0; calculate d c The variance v of each dimension of the attribute m , forming k P The corresponding diagonal distribution matrix 2-5) If the number of remaining samples in D c is not 0, then go back to step 2-4); otherwise, check whether c is equal to C. If c < C, then go back to step 2-3). If c = C, then the algorithm terminates. The step 4) specifically includes: 4-1) Set the number of samples S to be generated for each category c , c=1,2,…,C; initialize, let the current hidden layer neuron center index p=0, the generated sample set represents the empty set; 4-2) Let p = p + 1, assuming that the center k of the current hidden layer neuron P belongs to category c, then k P The corresponding number of generated samples is The sample matrix generated in 4-3) where each sample belongs to class c; Merge into the generated sample set S, Check whether p is equal to P. If p < P, go back to step 4-2); If p = P, obtain the complete generated sample set S and execute the next step; 4-4) According to the mean vector L of all attributes saved during preprocessing mean and standard deviation L std , denormalize S; according to the sequential encoding method of ordinal attributes and nominal attributes, convert the corresponding values in S back to the original values of ordinal attributes and nominal attributes.
2. The unbalanced data and image processing method according to claim 1, characterized in that: The step 3) specifically includes: 3-1) According to the fact that each sample in the data set D has M attributes, it is determined that the input layer of the RBF neural network data generation model has M input neurons, and each neuron corresponds to one attribute; 3-2) According to the total number of C categories in the data set D, it is determined that the output layer of the RBF neural network data generation model has C output neurons, each neuron corresponds to a category; 3-3) According to the result of step 2), P hidden layer neurons {k1, k2, ..., k P-1 , k P } and its corresponding categories and output weights {w1, w2, ..., w P-1 , w P }, and the corresponding P diagonal distribution matrices {V1, V2, …, V P-1 , V P }, determine the parameters of P hidden layer neurons {(k1, V1), (k2, V3), ..., (k P-1 , V P-1 ), (k P , V P )}, and the connection weights {w1, w2, …, w P-1 , w P }.
3. An unbalanced data and image processing system, characterized in that: The method according to any one of claims 1 to 2 is used to process unbalanced data, and the system comprises: A data preprocessing module, which is used to preprocess the unbalanced data set O according to the method of step 1) to obtain a data set D; A maximum distribution algorithm module, which is used to determine the parameters of the RBF neural network data generation model to be constructed according to the method of step 2); A network model building module, which builds an RBF neural network data generation model according to the method of step 3); The RBF neural network data generation model combines the mvnrnd function to adaptively generate a new data set S according to the distribution of the original unbalanced data set according to the method of step 4); And the data post-processing module fills the generated sample set S into the original unbalanced data set O to obtain the processed balanced data set O s .
4. A storage medium having a computer program stored thereon, characterized in that: When the program is executed, it is used to implement the method according to any one of claims 1 to 2.
5. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 2 is implemented.
