Imbalanced-data-set processing system and method for smart contract vulnerability data set

By applying subset division and sampling strategies for smart contract data sets, the problem of category imbalance in smart contract data sets is solved, the accuracy and sample quality of vulnerability detection are improved, and the sample sets are suitable for sample sets of multiple types of data.

WO2025065557A1PCT designated stage expired Publication Date: 2025-04-03HARBIN ENG UNIV +2
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/122714
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-09-27
Filing Date
2023-09-28
Publication Date
2025-04-03

AI Technical Summary

Technical Problem

Due to category imbalance in smart contract datasets, machine learning models tend to predict positive samples during training, which reduces model performance. At the same time, the existing SMOTE algorithms have the problem of generating too many similar samples and reducing generalization capabilities when dealing with multi-class sample imbalance.

Method used

By subsetting the minority class samples in the smart contract dataset, different sampling strategies are adopted, including P-SMOTE and TB-SMOTE algorithms, data augmentation is performed on internal samples and boundary samples to generate enhanced new data, which solves the problem of fuzzy data boundary and small number of samples in a minority class.

Benefits of technology

It reduces the imbalance of data distribution in the sample set, improves the accuracy of smart contract vulnerability detection, reduces boundary fuzziness problems, improves sample quality, and is suitable for sample sets of multiple types of data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023122714_03042025_PF_FP_ABST
    Figure CN2023122714_03042025_PF_FP_ABST
Patent Text Reader

Abstract

Disclosed in the present invention are an imbalanced-data-set processing system and method for a smart contract vulnerability data set. The system comprises: a data reading module, which is used for sequentially reading vulnerability sample sets of different classes, and inputting the vulnerability sample sets of different classes into a subset division module; the subset division module, which is used for dividing minority-class samples in vulnerability data sets of different classes, so as to acquire several sample subsets, and sending the sample subsets to a data generation module; and the data generation module, which is used for processing the sample subsets of different classes, respectively, so as to generate new data, wherein the data reading module, the subset division module and the data generation module are connected in sequence. By means of the present invention, the problem of boundary blurring is mitigated, the quality of samples is improved to a certain extent, and various samples are expanded; thus, the present invention is applicable to sample sets of multiple types of data.
Need to check novelty before this filing date? Find Prior Art

Description

Imbalanced dataset processing system and method for smart contract vulnerability datasets Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a system and method for processing an unbalanced dataset for a smart contract vulnerability dataset. Background Art

[0002] Smart contract datasets are often highly unbalanced, as most smart contracts are vulnerability-free, with only a small minority exhibiting vulnerabilities. This leads to a significant class imbalance in the dataset, with positive samples (i.e., smart contracts without vulnerabilities) dominating the dataset, while negative samples (i.e., smart contracts with vulnerabilities) are relatively rare. This imbalance causes machine learning models to favor positive predictions during training, resulting in poor performance.

[0003] The SMOTE (Synthetic Minority Over-sampling Technique) algorithm is a widely used data augmentation method for addressing data imbalance. The SMOTE algorithm generates new minority class samples by interpolating between minority class samples, increasing the number of minority class samples and balancing the training set. While the SMOTE algorithm effectively alleviates data imbalance, it also has some drawbacks. For example, it may generate too many similar samples, reducing the classifier's generalization ability. Furthermore, the SMOTE algorithm can only handle binary classification problems and cannot simultaneously address multi-class imbalance.

[0004] To address the issues with the SMOTE algorithm, researchers have proposed various improvements. These include dataset expansion methods such as Borderline-SMOTE, K-Means-SMOTE, and ENN. Some applications exist in processing smart contract datasets, such as using the SMOTE+ENN algorithm to perform mixed sampling of feature datasets. SMOTE is first used to generate new samples for the minority class, followed by undersampling using ENN to address data overlap. However, existing smart contract dataset processing methods do not address situations where there are more than one minority class sample and can lead to blurred boundaries.

[0005] Summary of the Invention

[0006] In response to the problem of imbalanced smart contract datasets in the existing technology, the present invention proposes an unbalanced dataset processing system and method for smart contract vulnerability datasets. By subsetting minority class samples and adopting different sampling strategies, the problems of blurred data boundaries and small number of minority class samples are solved.

[0007] To achieve the above objectives, the present invention provides, on the one hand, an unbalanced dataset processing system for smart contract vulnerability datasets, comprising:

[0008] Data reading module: used to read vulnerability sample sets of different categories in sequence and input the vulnerability sample sets of different categories into the subset division module;

[0009] Subset division module: used to divide the minority class samples in the vulnerability data sets of different categories, obtain several sample subsets, and send the sample subsets to the data generation module;

[0010] Data generation module: used to process the sample subsets of different categories respectively to generate enhanced new data;

[0011] The data reading module, the subset division module, and the data generation module are connected in sequence.

[0012] Preferably, the sample subset includes internal samples, boundary samples and isolated samples.

[0013] Preferably, the subset partitioning module includes:

[0014] Main sample division unit: used to select the main sample a in the process of sample generation based on minority class samples;

[0015] Neighborhood sample division unit: used to calculate the k neighboring samples around the main sample a using the Euclidean distance, and define the range formed by the main sample and the k neighboring samples as the neighborhood of the main sample, denoted as U(a);

[0016] Safety sample division unit: used to determine if all samples in the neighborhood U(a) belong to the same type, then the main sample a is a safe sample;

[0017] Isolated sample classification unit: used to determine that if all samples in the neighborhood U(a) are inconsistent with the main sample type, then a is an isolated sample;

[0018] Boundary samples: used to determine if there are both samples of the same type as the main sample and samples of a different type from the main sample in the neighborhood U(a), then a is a boundary sample;

[0019] Among them, the internal sample is the safety sample.

[0020] On the other hand, in order to achieve the above-mentioned purpose, the present invention also provides a method for processing an unbalanced dataset for a smart contract vulnerability dataset, comprising:

[0021] The vulnerability data sets of different categories are read in sequence by the data reading module, and the vulnerability data sets of different categories are input into the subset partitioning module to partition the data sets;

[0022] Based on the subset division module, minority class samples in the vulnerability data sets of different categories are divided to obtain several sample subsets, and the sample subsets are sent to the data generation module for processing to generate new data; wherein, the sample subsets include internal samples, boundary samples and isolated samples.

[0023] Preferably, sending the sample subset to a data generation module for processing comprises:

[0024] For the internal samples, the P-SMOTE data augmentation method is used to generate enhanced new data;

[0025] For the boundary samples, triangular sampling and interpolation sampling are performed using the TB-SMOTE data expansion method to generate the enhanced new data.

[0026] Preferably, the P-SMOTE data expansion method is used to generate the enhanced new data, including:

[0027] Calculate the Euclidean distance between all minority samples in the security sample set, select the sample with the smallest average distance to other samples as the center point, and calculate the value of each sample. After calculating the sample value, solve the weight of each sample, and then use the SMOTE algorithm to combine the sample weights to generate the number of samples. Generate new samples based on the number of samples.

[0028] The value of the sample is determined based on the distance from the center point or the boundary point.

[0029] Preferably, the method for calculating the Euclidean distance between all minority class samples is:

[0030] Among them, d i is the distance from sample i to sample k, N is the total number of samples, j is the jth dimension of the Euclidean space, x ij -x kj is the difference between i and k in the jth dimension;

[0031] The method for calculating the value of the sample is:

[0032] Among them, v i represents the value of sample i, D i 、D j is the normalized sample d i ;

[0033] The method for solving the weight of each sample is:

[0034] Among them, w i is the weight value of the sample, v j Represents the value of sample j.

[0035] Preferably, the enhanced new data is generated by performing triangular sampling and interpolation sampling using the TB-SMOTE data expansion method, including:

[0036] If the points around the sample point are of the same type, the main sample is determined, and k neighboring samples of the main sample are obtained. Two samples of the same type are randomly selected from the k neighboring samples, and a point x is randomly selected on the line connecting the two samples of the same type. t , as a temporary sample point, between the original sample x and x t Randomly generate samples to obtain the enhanced new data;

[0037] If the points around the sample point are of different types, find the majority class sample point Q among the k nearest neighbor samples of the minority class sample point, and obtain the enhanced new data by calculation: new =x+ran(0,1)|xQ|

[0038] Among them, x is the original sample, Q is the majority class sample point, and ran(0,1) is a random number between 0 and 1.

[0039] Compared with the prior art, the present invention has the following advantages and technical effects:

[0040] (1) The present invention reduces the imbalance of data distribution in the sample set by expanding the sample of the smart contract data set, thereby improving the accuracy of smart contract vulnerability detection;

[0041] (2) The present invention reduces the problem of blurred boundaries, improves the quality of samples, and expands a variety of samples, making it applicable to sample sets of multiple types of data. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. In the accompanying drawings:

[0043] FIG1 is a flow chart of a method for processing an unbalanced dataset for a smart contract vulnerability dataset according to an embodiment of the present invention;

[0044] FIG2 is a schematic diagram of different samples according to an embodiment of the present invention. DETAILED DESCRIPTION

[0045] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0046] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0047] This paper proposes an unbalanced dataset processing system for smart contract vulnerability datasets, including:

[0048] Data reading module: used to read vulnerability sample sets of different categories in sequence and input the vulnerability sample sets of different categories into the subset division module;

[0049] Subset division module: used to divide the minority class samples in the vulnerability data sets of different categories, obtain several sample subsets, and send the sample subsets to the data generation module; wherein, if the number of samples in a certain class is less than 5% of the number of samples in the class with the largest number of samples, it is considered a minority class sample;

[0050] Data generation module: used to process the sample subsets of different categories respectively to generate new data;

[0051] The data reading module, the subset partitioning module, and the data generation module are connected in sequence.

[0052] The relationship between these modules follows the following rules:

[0053] (1) The data reading module is responsible for reading each type of vulnerability sample set in turn and inputting it into the subset division module for subsequent operations.

[0054] (2) The subset partitioning module is responsible for dividing each minority class sample into different subsets, namely, internal samples, boundary samples and isolated samples. After the above three subsets are divided, the results are sent to the data generation module for sample generation.

[0055] (3) The data generation module receives different sample subsets generated by the subset partitioning module. For isolated sample subsets, since the samples in their set also exist, they are not processed and the original samples are directly retained. For the internal set, a P-SMOTE data augmentation method is used to generate more new samples near the center and the edge of the set than in other places, thereby strengthening the boundaries of the samples and improving the classification ability. For the boundary sample set, a TB-SMOTE data augmentation method is adopted to perform triangular sampling and interpolation sampling.

[0056] The subset partitioning module includes:

[0057] Main sample division unit: used for selecting main sample a in the process of generating samples based on the minority class samples;

[0058] Neighborhood sample division unit: used to calculate the k neighboring samples around the main sample a using the Euclidean distance, and define the range formed by the main sample and the k neighboring samples as the neighborhood of the main sample, denoted as U(a);

[0059] Safety sample division unit: used to determine if all samples in the neighborhood U(a) belong to the same type, then the main sample a is a safe sample

[0060] Isolated sample classification unit: used to determine that if all samples in the neighborhood U(a) are inconsistent with the main sample type, then a is an isolated sample;

[0061] Boundary samples: used to determine if there are both samples of the same type as the main sample and samples of a different type from the main sample in the neighborhood U(a), then a is a boundary sample;

[0062] Among them, the internal sample is the safety sample.

[0063] The demarcation rules are as follows:

[0064] Primary sample: When the SMOTE algorithm is used to generate samples for the minority class, the selected sample a is called the primary sample. The primary sample is selected through a loop method.

[0065] Neighborhood: For the main sample a, use the Euclidean distance calculation to get the k neighboring samples around it. The range formed by a and its k neighboring samples is called the neighborhood of a, denoted as U(a).

[0066] Safe sample: If all samples in U(a) belong to the same type, then a is called a safe sample.

[0067] Isolated sample: If all samples in U(a) are inconsistent with the main sample type, then a is called an isolated sample.

[0068] Boundary samples: If U(a) contains both samples of the same type as the main sample and samples of a different type from the main sample, then a is called a boundary sample.

[0069] The present invention also proposes an unbalanced dataset processing method for smart contract vulnerability datasets, as shown in Figure 1, including:

[0070] The vulnerability data sets of different categories are read in sequence by the data reading module, and the vulnerability data sets of different categories are input into the subset partitioning module to partition the data sets;

[0071] The subset division module divides the minority class samples in the vulnerability datasets of different categories into several sample subsets, and sends the sample subsets to the data generation module for processing to generate new data; wherein the sample subsets include internal samples, boundary samples, and isolated samples, as shown in Figure 2.

[0072] The way to generate new data is as follows:

[0073] First, calculate the Euclidean distance between all minority class samples in the security sample set and select the sample with the smallest average distance to other samples as the center point. Let the distance from sample i to sample k be d i ,but:

[0074] Among them, d i is the distance from sample i to sample k, N is the total number of samples, j is the jth dimension of the Euclidean space, x ij -x kj is the difference between i and k in the jth dimension;

[0075] To facilitate subsequent calculations, d i Normalized representation, the formula is: D i =(d i -d min ) / (d max -d min )

[0076] For each sample, calculate its value v i , the value is defined by the distance from the center or boundary point:

[0077] Among them, v i represents the sample value, D i , D j is the normalized d i , N is the total number of samples;

[0078] After calculating the sample value, solve the weight of each sample:

[0079] Among them, w i is the weight value of the sample, v i 、v j Represents the sample value.

[0080] s and q are variables, and their value range is a natural number between 1...N.

[0081] Finally, the SMOTE algorithm is used in combination with w iCount the number of generated samples and generate new samples.

[0082] For the boundary sample set, the way to generate new data is as follows:

[0083] (1) First, determine a main sample and obtain its k nearest neighbors. Among them, there are samples of the same type as the main sample and samples of different types. First, randomly select two samples of the same type from its k nearest neighbors and select a point x on the line connecting them. t , as a temporary sample point, and then between x and x t Randomly generate samples on the new : X new =x+ran(0,1)|x t -x|

[0084] This method enables new sample points to be randomly generated in a triangular area, improving the situation where the sample points are distributed in a straight line.

[0085] (2) When the k sample points are surrounded by samples of the same type, the classification error will be greatly reduced. Therefore, a new interpolation method BSMOTE is used for the boundary sample points. By inserting a small number of sample points between the minority class samples and the majority class samples, the original sample points become safe sample points. At the same time, this method increases the number of safe samples, which facilitates the classifier to better learn features for classification.

[0086] The specific approach is: for the minority class sample point in the boundary sample set, find a majority class sample point Q in its k nearest neighbors, and use the following formula to generate new data: X new =x+ran(0,1)|xQ|

[0087] By expanding the sample of the smart contract data set, the present invention reduces the imbalance of data distribution in the sample set and improves the accuracy of smart contract vulnerability detection; reduces the problem of blurred boundaries and improves the quality of samples to a certain extent. At the same time, it expands multiple samples and is suitable for sample sets of multiple types of data.

[0088] The above are merely preferred embodiments of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. An unbalanced dataset processing system for smart contract vulnerability datasets, characterized by: include: Data reading module: used to read vulnerability sample sets of different categories in sequence, and input the vulnerability sample sets of different categories into the subset division module; Subset division module: used to divide the minority class samples in the vulnerability data sets of different categories, obtain several sample subsets, and send the sample subsets to the data generation module; Data generation module: used to process the sample subsets of different categories respectively to generate enhanced new data; The data reading module, the subset dividing module, and the data generating module are connected in sequence.

2. The unbalanced data set processing system for smart contract vulnerability data sets according to claim 1, characterized in that: The sample subset includes internal samples, boundary samples and isolated samples.

3. The unbalanced data set processing system for smart contract vulnerability data sets according to claim 2, characterized in that: The subset partitioning module comprises: Main sample division unit: used to select the main sample a in the process of sample generation based on minority class samples; A neighborhood sample division unit is used to calculate the k neighboring samples around the main sample a using the Euclidean distance, and the range formed by the main sample and the k neighboring samples is the neighborhood of the main sample, which is recorded as U(a); Safety sample division unit: used to determine if all samples in the neighborhood U(a) belong to the same type, then the main sample a is a safety sample; Isolated sample division unit: used to determine that if all samples in the neighborhood U(a) are inconsistent with the main sample type, then a is an isolated sample; Boundary samples: used to determine if there are samples of the same type as the main sample and samples of different types from the main sample in the neighborhood U(a), then a is a boundary sample; Among them, the internal sample is the safety sample.

4. The unbalanced data set processing method for smart contract vulnerability data set is characterized by: include: The vulnerability data sets of different categories are read in sequence by the data reading module, and the vulnerability data sets of different categories are input into the subset partitioning module to partition the data sets; Based on the subset division module, minority class samples in the vulnerability data sets of different categories are divided to obtain several sample subsets, and the sample subsets are sent to the data generation module for processing to generate new data; wherein the sample subsets include internal samples, boundary samples and isolated samples.

5. The unbalanced data set processing method for smart contract vulnerability data set according to claim 4 is characterized in that: Sending the sample subset to a data generation module for processing includes: For the internal samples, a P-SMOTE data augmentation method is used to generate enhanced new data; For the boundary samples, triangular sampling and interpolation sampling are performed through the TB-SMOTE data expansion method to generate the enhanced new data.

6. The unbalanced data set processing method for smart contract vulnerability data set according to claim 5 is characterized in that: The P-SMOTE data expansion method is used to generate the enhanced new data, including: Calculate the Euclidean distance between all minority samples in the security sample set, select the sample with the smallest average distance to other samples as the center point, and calculate the value of each sample. After calculating the sample value, solve the weight of each sample, and then use the SMOTE algorithm to combine the sample weight statistics to generate the number of samples, and generate new samples based on the number of samples; The value of the sample is determined based on the distance from the center point or the boundary point.

7. The unbalanced data set processing method for smart contract vulnerability data set according to claim 6 is characterized in that: The method to calculate the Euclidean distance between all minority class samples is: Among them, d i is the distance from sample i to sample k, N is the total number of samples, j is the jth dimension of the Euclidean space, x ij -x kj is the difference between i and k in the jth dimension; The method for calculating the value of the sample is: Among them, v i represents the value of sample i, D i , D j is the normalized sample d i ; The method for solving the weight of each sample is: Among them, w i is the weight value of the sample, v j Represents the value of sample j.

8. The unbalanced data set processing method for smart contract vulnerability data set according to claim 7 is characterized in that: The enhanced new data is generated by performing triangular sampling and interpolation sampling through the TB-SMOTE data expansion method, including: If the points around the sample point are of the same type, the main sample is determined, and k neighboring samples of the main sample are obtained. Two samples of the same type are randomly selected from the k neighboring samples, and a point x is randomly selected on the line connecting the two samples of the same type. t , as a temporary sample point, between the original sample x and x t Randomly generate samples to obtain the enhanced new data; If the points around the sample point are sample points of different types, then find the majority class sample point Q among the k nearest neighbor samples of the minority class sample point, and obtain the enhanced new data by calculation: X new =x+ran(0,1)|xQ| Among them, x is the original sample, Q is the majority class sample point, and ran(0,1) is a random number between 0 and 1.

Citation Information

Patent Citations

  • Efficient imbalanced data set classification method

    CN105760889A

  • Data processing method and device, equipment and storage medium

    CN113052198A

  • Synthetic oversampling method and system for processing unbalanced data

    CN113780419A

  • System and method for applying artificial intelligence techniques to respond to multiple choice questions

    US20200143274A1

  • Incremental machine learning for a parametric machine learning model

    US20230137184A1