Over-sampling algorithm based on minority class cluster weighting
Through the oversampling algorithm based on minority cluster weighting, the problem of insufficient classification performance of traditional SMOTE algorithm for minority samples is solved. New samples are generated through k-means clustering and improved SMOTE method, and the balance and classification of the data set are realized. Performance improvement.
Patent Information
- Application Number
- CN202411059543.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-04
- Publication Date
- 2025-01-07
AI Technical Summary
The traditional SMOTE algorithm lacks classification performance for a few categories of samples, and the generated new samples have high randomness and redundancy, which makes it difficult to effectively solve the problem of data set imbalance.
Using an oversampling algorithm based on minority class cluster weighting, the minority class samples are divided into safe points and boundary points through k-means clustering, and the density weight and distance weight are allocated to them respectively, and the new minority class is synthesized using the improved SMOTE method. Sample, ensuring that the sample is generated within its neighborhood, reducing randomness and redundancy.
The classification performance of the classifier is improved, the data set reaches a better balance state, the randomness of traditional oversampling algorithms is reduced, and the accuracy of the classifier and the uniformity of the data distribution are improved.
Smart Images

Figure FT_1 
Figure FT_2 
Figure BDA0004977446150000031
Abstract
Description
Technical field:
[0001] The present invention relates to an oversampling algorithm based on a weighted minority cluster, which divides minority samples into safe point samples and boundary point samples, assigns corresponding weights to the two types of points using different methods, and then uses an improved SMOTE method to synthesize new minority samples, thereby achieving a better balanced ratio of data set samples. Background technology:
[0002] Imbalanced data processing is an important issue in machine learning and data mining, because in the real world, many data sets have imbalanced categories, that is, the number of samples in some categories is much larger or much smaller than the number of samples in other categories. This situation will cause the model to be biased during training and evaluation, making the model more inclined to predict the category with a larger number of samples, while performing poorly for the category with a smaller number of samples.
[0003] According to different strategies, domestic and foreign researchers deal with imbalanced data in two aspects, namely the data level and the algorithm level. The processing idea at the data level is to improve the imbalance of the original data set by artificially deleting majority class instances or increasing minority class instances according to certain rules, and effectively solve the imbalanced distribution of positive and negative class samples in imbalanced data by making the original data set as balanced as possible. According to the different sampling methods in the data preprocessing process, sampling is divided into three parts: undersampling, oversampling and mixed sampling, among which undersampling and oversampling are the mainstream. The processing logic at the algorithm level mainly includes ensemble learning and cost-sensitive learning. Among them, oversampling technology is the most common data preprocessing method at the data level. It synthesizes a certain number of minority class samples through certain rules to solve the problem of data imbalance and achieve rebalancing of the original data. Summary of the invention:
[0004] In order to solve the problem that the traditional SMOTE algorithm has insufficient classification performance for minority class samples, the present invention discloses an oversampling algorithm based on minority class cluster weighting.
[0005] To this end, the present invention provides the following technical solutions:
[0006] 1. An oversampling algorithm based on weighted minority clusters, characterized in that the method comprises the following steps:
[0007] Step 1: Perform k-means clustering on minority samples. This method first clusters the minority class to form multiple minority clusters, and divides the minority class samples into safe points, boundary points, and noise points. The noise points are deleted.
[0008] Step 2: Determine the total number of minority class samples that need to be synthesized.
[0009] Step 3: Calculate the number of minority class samples to be synthesized for each minority class cluster according to the sampling rate.
[0010] Step 4: Assign weights to each minority class boundary point sample. This includes density weights and distance weights. Determine the order of minority class samples to be used when synthesizing new minority class samples according to the magnitude of the weights. Among them, the higher the weight of a sample, the more priority should be given to synthesizing minority class samples in its sampling area and the larger the number of synthesized samples. And use the improved SMOTE method to synthesize new minority class samples.
[0011] Step 5: Assign weights to each minority class safe point sample, which includes density weights and distance weights. Determine the order of minority class samples to be used when synthesizing new minority class samples according to the magnitude of the weights. Among them, the higher the weight of a sample, the more priority should be given to synthesizing minority class samples in its sampling area and the larger the number of synthesized samples. And use the improved SMOTE method to synthesize new minority class samples.
[0012] Step 6: For each minority class cluster, after generating new minority class samples each time, record the total number of newly synthesized minority class samples in this cluster at this time. If the total number of newly synthesized minority class samples in this cluster has reached the number required in Step 3 at this time, the algorithm ends. If after all minority class samples in this cluster have participated in the process of synthesizing new samples, the number of newly generated minority class samples is less than the number required in Step 3, then use the random smote method to synthesize new minority class samples for all safe point samples in this cluster until the number of newly synthesized minority class samples in each minority class cluster reaches the number required in Step 3, and then the algorithm ends.
[0013] 2. The oversampling algorithm based on weighted minority class clusters according to claim 1, wherein in the said Step 1, the k-means clustering of minority class samples is specifically as follows:
[0014] Step 1: Randomly select k data points as the initial centroids, and assign each data point to the cluster corresponding to the centroid closest to it. Calculate the average value of all data points in each cluster, and use them as the new centroids. Repeat the above steps until one of the three conditions is met: the centroid of the cluster no longer changes, the predetermined maximum number of iterations has been reached, or the change in the cluster is less than the predetermined threshold, and the clustering ends. Form multiple minority class clusters. For each minority class, identify its m nearest neighbors. Among them, record the number of majority classes as n. If n = 0, then this minority class point is a safe point. If 0 < n < m, then it is called a boundary point. If n = m, then it is called a noise point, and the noise points are deleted.
[0015] 3. The oversampling algorithm based on weighted minority clusters according to claim 1 is characterized in that in step 2, the balance ratio of the synthesized data set is set to 1:1, and the total number of new samples that need to be synthesized in the entire data set is calculated, and the specific formula is as follows:
[0016] T add =T max -T min
[0017] Among them, T max is the number of majority class samples in the dataset, T min is the number of minority class samples in the dataset.
[0018] 4. The oversampling algorithm based on weighted minority clusters according to claim 1, characterized in that in step 3, the number of minority samples required to be synthesized for each minority cluster is calculated according to the sampling rate. The specific formula is as follows:
[0019]
[0020]
[0021] where d j represents the distance from each point in the minority cluster to the cluster center, represents the average distance from all points in the minority cluster to the cluster center, u i Indicates the number of minority class samples in the minority class cluster. The variance of the distance from all points in the minority class cluster to the cluster center is used to indicate the sparsity of the samples between clusters. The larger the variance, the more dispersed the data points in the cluster, the higher the sparsity of the cluster, and the higher the corresponding sampling rate should be; the smaller the variance, the more concentrated the data points in the cluster, the lower the sparsity of the cluster, and the lower the corresponding sampling rate should be. v represents the number of minority class samples in the entire sample, where v and u i The larger the ratio of v and u, the smaller the number of minority class samples in this minority class cluster, so the number of minority class samples that need to be synthesized in this minority class cluster should be more, and the corresponding sampling rate is also higher. On the contrary, v and u i The smaller the ratio, the lower the corresponding sampling rate. The above method can be used to calculate the sampling rate to solve both the intra-class imbalance and the inter-class imbalance problem.
[0022] 5. The oversampling algorithm based on weighted minority clusters according to claim 1 is characterized in that, in step 4, a weight is assigned to each minority class boundary point sample. The weight includes density weight and distance weight, and an improved SMOTE method is used to synthesize new minority class samples. The specific steps are:
[0023] Step 4-1 calculates the density weight of each boundary point sample in the minority cluster. The specific formula is as follows:
[0024]
[0025] Where a is the number of minority class samples among the k samples closest to the boundary sample.
[0026] Step 4-2 calculates the distance weight of each boundary point sample in the minority cluster. The specific formula is as follows:
[0027]
[0028] Among them, dist(x i ,x j ) is the Euclidean distance between each boundary point sample and its k nearest safe point samples.
[0029] Step 4-3 calculates the total weight of each minority class boundary point sample. The specific formula is as follows:
[0030]
[0031] Here, λ is a factor used to balance the influence of density and distance, and here the value of λ is 0.5.
[0032] Step 4-4: The weights calculated in step 4-3 represent the weights of the boundary point samples. After selecting which samples are used to synthesize the minority class samples of the new samples according to the weights, the improved SMOTE method is used to synthesize the new minority class samples: for the selected boundary samples, select the two boundary point samples closest to it, and then randomly generate a transition sample x1, x2 on the line between this boundary point sample and the two boundary point samples closest to it. Then randomly generate a new sample x0 on the line between x1 and x2. This sample is the final synthesized new minority class sample we need. The specific formula is as follows:
[0033]
[0034]
[0035]
[0036] where x i represents the boundary point samples selected for synthesis, and Respectively represent the distance from the boundary point sample x i The two nearest boundary point samples. rand(0,1) randomly generates a number between 0 and 1 to indicate randomness. bFinally, the synthesized new minority class samples are selected. This generation method can ensure that the newly generated samples are still near the boundary points, and will not be generated near the safe points, which will not cause sample redundancy. It also makes the sample set more balanced within the class and the data distribution more even.
[0037] 6. The oversampling algorithm based on minority class cluster weighting according to claim 1 is characterized in that in step 5, a weight is assigned to each minority class safety point sample. The weight includes density weight and distance weight, and an improved SMOTE method is used to synthesize new minority class samples. The specific steps are:
[0038] Step 5-1 calculates the density weight of each safe point sample in the minority cluster. The specific formula is as follows:
[0039]
[0040] where p i is a safe point sample x i The number of minority class samples in a circle with a radius of r and a center of x. r represents the distance from the safe point sample x. i The distance to the nearest boundary point sample. This ensures that all samples in this circle are safe point samples. This can better represent the density weight of safe point samples.
[0041] Step 5-2 calculates the distance weight of each safe point sample in the minority cluster. The specific formula is as follows:
[0042]
[0043] in, It is the distance from each safe point in the minority cluster and the k nearest safe points to the centroid x of the cluster c The sum of the distances.
[0044] Step 5-3 calculates the total weight of each minority class safety point sample. The specific formula is as follows:
[0045]
[0046] β is a factor used to balance the influence of density and distance, and here β is taken as 0.5.
[0047] Step 5-4: The weight calculated in step 5-3 represents the weight of the last safe point sample. After selecting which samples are used to synthesize the minority class samples of the new sample according to the weight, the improved SMOTE method is used to synthesize the new minority class samples: for the selected safe point sample, select the two safe point samples closest to it, and then randomly generate a transition sample x3, x4 on the line between this safe point sample and the two safe point samples closest to it. Then randomly generate a new sample x on the line between x3 and x4. a , this sample is the final synthesized new minority class sample we need. The specific formula is as follows:
[0048]
[0049]
[0050] x a =x3+rand(0,1)*(x3-x4)
[0051] where x i represents the selected synthetic safety point samples, and Respectively represent the distance to the safe point sample x i The two most recent safe point samples. rand(0,1) means randomly generating a number between 0 and 1 to indicate randomness. a Finally, the synthesized new minority class samples are selected. This generation method can ensure that the newly generated samples are still near the safe point, will not be generated at the boundary, and will not cause sample redundancy. It also makes the sample set more balanced within the class and the data distribution more even.
[0052] Beneficial effects:
[0053] 1. The present invention is an oversampling algorithm based on weighted minority clusters. The traditional SMOTE oversampling algorithm has a high randomness when generating minority samples. The newly generated samples are easy to overlap with the original data samples, and the redundancy is high. Therefore, the data is preprocessed first, and k-means clustering is performed on all minority samples in the original data set to form multiple minority clusters. The minority samples are divided into safe points, boundary points and noise points, and the noise points are deleted. Secondly, the number of minority samples that need to be synthesized for each minority cluster is calculated in combination with the sampling rate, and then the weights of the minority samples and the safe point samples are distributed in different ways according to the distribution of the minority point samples and the safe point samples. Finally, the improved SMOTE algorithm is used to generate minority samples according to the weight of each minority sample point, so that the data set reaches a balanced state. This can greatly reduce the randomness brought by the traditional oversampling algorithm, thereby improving the classification performance of the classifier.
[0054] 2. The data structure model used in the present invention is a k-means clustering data model. The basic principle and implementation process of the k-means clustering algorithm are relatively simple, easy to understand and implement, and have high computational efficiency. It can be easily applied to large-scale data sets, and the processing speed can be further improved through parallel computing. It can usually produce stable clustering results.
[0055] 3. The evaluation index used in the present invention is to construct a confusion matrix, and use indicators such as F-value, G-mean, AUC, etc. to evaluate the quality of the classification. This indicator is specifically used to verify the accuracy of the imbalanced data classification algorithm and can make an accurate evaluation of the classification results of the algorithm.
[0056] 4. When calculating the sample weight, since each sample belongs to a different location, the information carried may also be different, so we cannot regard each minority class sample as equal. Therefore, the present invention takes into account the information differences between each sample and assigns weights to each minority class sample. These include density weights and distance weights. The order of minority class samples required to synthesize new minority class samples is determined according to the size of the weights. The higher the weight of the sample, the more minority class samples need to be synthesized in the area where it is sampled, and the more synthesized samples are required. This ensures the balance of data distribution within the class.
[0057] 5. When synthesizing new minority class samples, choosing this generation method can ensure that the newly generated samples are still in the vicinity of their neighborhoods, and will not be generated in areas that do not belong to the same class as the selected synthesized samples, which will not cause sample redundancy. It also makes the sample set more balanced within the class and the data distribution more even. Description of the drawings:
[0058] Figure 1 This is a division diagram of boundary points, safety points and noise points in an implementation manner of the present invention.
[0059] Figure 2 This is a schematic diagram of the improved SMOTE algorithm in an embodiment of the present invention. Specific implementation method:
[0060] In order to clearly and completely describe the technical solutions in the embodiments of the present invention, the present invention is further described in detail below in conjunction with the drawings in the embodiments.
[0061] The embodiment of the present invention is based on a weighted oversampling algorithm for minority clusters and includes the following steps.
[0062] Step 1: Perform k-means clustering on minority samples to form multiple minority clusters, and divide minority samples into safe points, boundary points, and noise points. Delete the noise points.
[0063] Step 1-1: Perform k-means clustering on the minority class samples to form multiple minority class clusters;
[0064] Step 1-2: For each minority class, identify its m nearest neighbors. Record the number of majority class samples as n. If n = 0, then this minority class point is a safe point. If 0 < n < m, then it is called a boundary point. If n = m, then it is called a noise point, and the noise points are deleted.
[0065] Step 2: Set the balance ratio of the synthesized dataset to 1:1, and calculate the total number of new samples that need to be synthesized for the entire dataset.
[0066] Step 3: Calculate the number of minority class samples that need to be synthesized for each minority class cluster according to the sampling rate.
[0067] Step 4: Assign weights to each minority class boundary point sample. This includes density weight and distance weight, and use the improved SMOTE method to synthesize new minority class samples.
[0068] Step 4-1: Calculate the density weight of each boundary point sample in the minority class cluster. The proportion of minority class samples among the K nearest samples to each boundary sample is the density weight.
[0069] Step 4-2: Calculate the distance weight of each boundary point sample in the minority class cluster. The average distance between each boundary point and its K nearest safe points is the distance weight.
[0070] Step 4-3: Calculate the total weight of each minority class boundary point sample. The specific formula is as follows:
[0071]
[0072] Where λ is the influence factor used to balance the effects of density and distance, and here λ takes the value of 0.5.
[0073] Step 4-4: According to the weights calculated in Step 4-3, which represent the weights of the final boundary point samples, select the minority class samples that are used to synthesize new samples according to the weight size, and then use the improved SMOTE method to synthesize new minority class samples.
[0074] Step 5: Assign weights to each minority class safe point sample. This includes density weight and distance weight, and use the improved SMOTE method to synthesize new minority class samples.
[0075] Step 5-1: Calculate the density weight of each safe point sample in the minority class cluster. Taking the safe samples in each minority class cluster as the center, calculate the number of minority class samples in a circle with a radius of r. r represents the distance from the safe point sample x iThe distance to the nearest boundary point sample. This ensures that all samples in this circle are safe point samples. This can better represent the density weight of safe point samples.
[0076] Step 5-2 calculates the distance weight of each safety point sample in the minority cluster. The average distance between each safety point in the minority cluster and the K nearest safety points to the cluster center is the distance weight.
[0077] Step 5-3 calculates the total weight of each minority class safety point sample. The specific formula is as follows:
[0078]
[0079] β is a factor used to balance the influence of density and distance, and here β is taken as 0.5.
[0080] In step 5-4, the weight calculated in step 5-3 represents the weight of the last safe point sample. After selecting which samples are used to synthesize the minority class samples of the new samples according to the weight size, the improved SMOTE method is used to synthesize the new minority class samples.
[0081] Step 6: After each minority class cluster generates a new minority class sample, record the total number of newly synthesized minority class samples in the cluster. If the total number of newly synthesized minority class samples in the cluster has reached the number required in step 3, the algorithm ends. If the number of newly generated minority class samples is less than the number required in step 3 after all minority class samples in the cluster have participated in the process of synthesizing new samples, all safety point samples in the cluster are subjected to random SMOTE method to synthesize new minority class samples until the number of newly synthesized minority class samples in each minority class cluster reaches the number required in step 3, and the algorithm ends.
[0082] In order to make the experimental results more accurate, the improved algorithm is compared with the traditional SMOTE algorithm, and a classification effect confusion matrix is introduced, where the value of TP is the number of samples that are actually in the minority class but predicted to be in the minority class, the value of FN refers to the number of samples that are actually in the minority class but predicted to be in the majority class, FP refers to the number of samples that are actually in the majority class but predicted to be in the minority class, and TN refers to the number of samples that are actually in the majority class but predicted to be in the majority class.
[0083] According to the confusion matrix, the ratio of correctly classified minority class samples to all predicted minority class samples can be obtained:
[0084] Precision:
[0085] The percentage of samples that are actually predicted to be correct for minority samples:
[0086] Recall rate:
[0087] The percentage of samples that are actually the majority class but are predicted incorrectly:
[0088] False Positive Rate:
[0089] The percentage of samples that are actually the majority class that are predicted correctly:
[0090] True negative rate:
[0091] F-value and geometric mean accuracy G-mean take into account the correct accuracy and recall rate. The formulas are defined as follows:
[0092]
[0093]
[0094] The ROC curve is a curve formed by connecting the points formed by the coordinates formed by FRP as the horizontal axis and recall as the vertical axis. AUC represents the area value from the ROC curve to the coordinate axis. The larger the area, the higher the classification accuracy and the better the algorithm effect of the experiment.
[0095] The oversampling algorithm based on weighted minority clusters in the embodiment of the present invention performs k-means clustering on all minority samples in the original data set to form multiple minority clusters, divides the minority samples into safe points, boundary points and noise points, and deletes the noise points. Secondly, the number of minority samples that need to be synthesized for each minority cluster is calculated in combination with the sampling rate, and then the weights of the boundary point samples and the safe point samples are distributed in different ways according to the distribution of the boundary point samples and the safe point samples. Finally, the improved SMOTE algorithm is used to generate minority samples according to the weight of each minority sample point, so that the data set reaches a balanced state. The performance of the traditional SMOTE classification algorithm is greatly improved.
[0096] The above is a detailed description of the embodiments of the present invention in conjunction with the accompanying drawings, and the specific implementation methods herein are only used to help understand the method of the present invention. For those of ordinary skill in the art, according to the idea of the present invention, changes and modifications can be made in the specific implementation methods and application scopes, so the present invention should not be understood as limiting the present invention.
Claims
1. An oversampling algorithm based on weighted minority clusters, characterized in that: The method includes the following steps: Step 1: Perform k-means clustering on the minority class samples. In this method, the minority class is first clustered to form multiple minority class clusters, and the minority class samples are classified into safe points, boundary points, and noise points. The noise points are deleted. Step 2: Determine the total number of minority class samples to be synthesized. Step 3: Calculate the number of minority class samples to be synthesized for each minority class cluster according to the sampling rate. Step 4: Assign weights to each minority class boundary point sample. It includes density weight and distance weight. According to the size of the weights, determine the order of minority class samples to be used when synthesizing new minority class samples. Among them, the higher the weight of the sample, the more priority should be given to synthesizing minority class samples in its sampling area and the larger the synthesis quantity. And use the improved SMOTE method to synthesize new minority class samples. Step 5: Assign weights to each minority class safe point sample. It includes density weight and distance weight. According to the size of the weights, determine the order of minority class samples to be used when synthesizing new minority class samples. Among them, the higher the weight of the sample, the more priority should be given to synthesizing minority class samples in its sampling area and the larger the synthesis quantity. And use the improved SMOTE method to synthesize new minority class samples. Step 6: For each minority class cluster, after generating new minority class samples each time, record the total number of newly synthesized minority class samples in this cluster at this time. If the total number of newly synthesized minority class samples in this cluster has reached the quantity required in Step 3 at this time, the algorithm ends. If after all minority class samples in this cluster have participated in the process of synthesizing new samples, the number of newly generated minority class samples is less than the quantity required in Step 3, then use the random smote method to synthesize new minority class samples for all safe point samples in this cluster until the number of newly synthesized minority class samples in each minority class cluster reaches the quantity required in Step 3, and then the algorithm ends.
2. The oversampling algorithm based on weighted minority clusters according to claim 1, characterized in that: In the above Step 1, for the k-means clustering of the minority class samples, the specific steps are as follows: Step 1 randomly selects k data points as the initial centroids, and assigns each data point to the cluster corresponding to the nearest centroid. Calculate the average value of all data points in each cluster and use them as the new centroids. Repeat the above steps until one of the three conditions is met: the centroid of the cluster no longer changes, the predetermined maximum number of iterations has been reached, or the change of the cluster is less than the predetermined threshold, and the clustering ends. Multiple minority class clusters are formed. For each minority class, identify its m nearest neighbors. Among them, record the number of majority class as n. If n = 0, then this minority class point is a safe point. If 0 < n < m, it is called a boundary point. If n = m, it is called a noise point, and the noise points are deleted.
3. The oversampling algorithm based on weighted minority clusters according to claim 1, characterized in that: In the above Step 2, set the balance ratio of the synthesized dataset to 1:1, and calculate the total number of new samples that need to be synthesized in the entire dataset. The specific formula is as follows: T add =T max -T min Among them, T max is the number of majority class samples in the dataset, T min is the number of minority class samples in the dataset.
4. The oversampling algorithm based on weighted minority clusters according to claim 1, characterized in that: In the above Step 3. Calculate the number of minority class samples to be synthesized for each minority class cluster according to the sampling rate. The specific formula is as follows: where d j represents the distance from each point in the minority cluster to the cluster center, represents the average distance from all points in the minority cluster to the cluster center, u i Indicates the number of minority class samples in the minority class cluster. The variance of the distance from all points in the minority class cluster to the cluster center is used to indicate the sparsity of the samples between clusters. The larger the variance, the more dispersed the data points in the cluster, the higher the sparsity of the cluster, and the higher the corresponding sampling rate should be; the smaller the variance, the more concentrated the data points in the cluster, the lower the sparsity of the cluster, and the lower the corresponding sampling rate should be. v represents the number of minority class samples in the entire sample, where v and u i The larger the ratio of v and u, the smaller the number of minority class samples in this minority class cluster, so the number of minority class samples that need to be synthesized in this minority class cluster should be more, and the corresponding sampling rate is also higher. On the contrary, v and u i The smaller the ratio, the lower the corresponding sampling rate. The above method can be used to calculate the sampling rate to solve both the intra-class imbalance and the inter-class imbalance problem.
5. The oversampling algorithm based on weighted minority clusters according to claim 1, characterized in that: In step 4, a weight is assigned to each minority class boundary point sample. This weight includes density weight and distance weight, and an improved SMOTE method is used to synthesize new minority class samples. The specific steps are: Step 4-1 calculates the density weight of each boundary point sample in the minority cluster. The specific formula is as follows: Where a is the number of minority class samples among the k samples closest to the boundary sample. Step 4-2 calculates the distance weight of each boundary point sample in the minority cluster. The specific formula is as follows: Among them, dist(x i ,x j ) is the Euclidean distance between each boundary point sample and its k nearest safe point samples. Step 4-3 calculates the total weight of each minority class boundary point sample. The specific formula is as follows: Here, λ is a factor used to balance the influence of density and distance, and here the value of λ is 0.
5. Step 4-4: The weights calculated in step 4-3 represent the weights of the boundary point samples. After selecting which samples are used to synthesize the minority class samples of the new samples according to the weights, the improved SMOTE method is used to synthesize the new minority class samples: for the selected boundary samples, select the two boundary point samples closest to it, and then randomly generate a transition sample x1, x2 on the line between this boundary point sample and the two boundary point samples closest to it. Then randomly generate a new sample x0 on the line between x1 and x2. This sample is the final synthesized new minority class sample we need. The specific formula is as follows: where x i represents the boundary point samples selected for synthesis, and Respectively represent the distance from the boundary point sample x i The two nearest boundary point samples. rand(0,1) randomly generates a number between 0 and 1 to indicate randomness. b Finally, the synthesized new minority class samples are selected. This generation method can ensure that the newly generated samples are still near the boundary points, and will not be generated near the safe points, which will not cause sample redundancy. It also makes the sample set more balanced within the class and the data distribution more even.
6. The oversampling algorithm based on weighted minority clusters according to claim 1, characterized in that: In step 5, each minority class safety point sample is assigned a weight, which includes density weight and distance weight, and the improved SMOTE method is used to synthesize new minority class samples. The specific steps are: Step 5-1 calculates the density weight of each safe point sample in the minority cluster. The specific formula is as follows: where p i is a safe point sample x i The number of minority class samples in a circle with a radius of r and a center of x. r represents the distance from the safe point sample x. i The distance to the nearest boundary point sample. This ensures that all samples in this circle are safe point samples. This can better represent the density weight of safe point samples. Step 5-2 calculates the distance weight of each safe point sample in the minority cluster. The specific formula is as follows: in, It is the distance from each safe point in the minority cluster and the k nearest safe points to the centroid x of the cluster c The sum of the distances. Step 5-3 calculates the total weight of each minority class safety point sample. The specific formula is as follows: β is a factor used to balance the influence of density and distance, and here β is taken as 0.
5. Step 5-4: The weight calculated in step 5-3 represents the weight of the last safe point sample. After selecting which samples are used to synthesize the minority class samples of the new sample according to the weight, the improved SMOTE method is used to synthesize the new minority class samples: for the selected safe point sample, select the two safe point samples closest to it, and then randomly generate a transition sample x3, x4 on the line between this safe point sample and the two safe point samples closest to it. Then randomly generate a new sample x on the line between x3 and x4. a , this sample is the final synthesized new minority class sample we need. The specific formula is as follows: where x i represents the selected synthetic safety point samples, and Respectively represent the distance to the safe point sample x i The two most recent safe point samples. rand(0,1) means randomly generating a number between 0 and 1 to indicate randomness. a Finally, the synthesized new minority class samples are selected. This generation method can ensure that the newly generated samples are still near the safe point, will not be generated at the boundary, and will not cause sample redundancy. It also makes the sample set more balanced within the class and the data distribution more even.