Small sample Bug Report effectiveness prediction method based on spectral clustering
By combining spectral clustering and CNN models, the problem of predicting the effectiveness of small sample bug reports was solved, efficient and accurate prediction results were achieved, and project maintenance efficiency was improved.
Patent Information
- Application Number
- CN202510768128.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-09-23
AI Technical Summary
Under small sample conditions, existing technologies are difficult to efficiently and accurately predict the effectiveness of bug reports, manual screening is inefficient, and traditional supervised learning methods are ineffective.
The spectral clustering algorithm is used to cluster the bug reports. The proportion and standard deviation of samples within the cluster are adjusted in combination with the interference index. The CNN model is used to train the classification of each cluster and predict the validity of the bug reports.
It improves the accuracy and efficiency of bug report effectiveness prediction under small sample conditions, reduces the burden of manual screening, and improves project maintenance efficiency.
Smart Images

Figure CN120687130A_ABST
Abstract
Description
Technical field
[0001] The present invention belongs to the field of artificial intelligence and software engineering, and relates to machine learning, deep learning and natural language processing technologies, and specifically to a small sample bug report effectiveness prediction method based on spectral clustering. [Background Technology]
[0002] Developers use bug reports to fix bugs in software systems or projects. The number of bug reports submitted is growing rapidly, but submitters often submit a large number of invalid reports. Developers need to screen valid bug reports to help maintain projects and fix bugs. Manual screening is very inefficient, and traditional supervised learning-based prediction methods require training using large numbers of bug reports, which is ineffective in small sample projects. Therefore, how to efficiently and accurately predict the validity of bug reports under small sample conditions has become a pressing problem. [Summary of the invention]
[0003] To address these issues, this paper proposes a bug report validity prediction method for small sample projects based on spectral clustering. This method uses a spectral clustering algorithm to cluster bug reports from n projects into k clusters. Then, an adjustment strategy is used to adjust these k clusters to m clusters. Finally, a CNN classification model is trained for each cluster to predict the validity of the bug reports.
[0004] To achieve the above technical objectives, the present invention provides a technical solution, which is a method for predicting the effectiveness of small sample bug reports based on spectral clustering. The method comprises:
[0005] Step S1: preprocess all bug report texts of n projects, including text extraction, normalization, word segmentation, stop word removal, and word2vec vectorization;
[0006] Step S2, using a spectral clustering algorithm combined with multiple evaluation indicators to cluster the item vectors into k clusters C = {C1, C2, ..., Ck};
[0007] Step S3: Introduce the interference index to detect and bind the interference between items in the cluster, and adjust the clustering results so that the sample size in each cluster is no less than 3000 and the positive and negative sample ratio is in the range of [1 / 1.6, 1.6 / 1], while the global standard deviation is minimized. Finally, the adjusted m clusters C′ = {C1′, C2′, …, Cm′} are obtained.
[0008] Step S4: For each of the adjusted m clusters, a CNN model is trained for bug report validity classification prediction. After training, m CNN models are obtained and used to predict the validity of newly submitted bug reports.
[0009] 2. The method for predicting the effectiveness of a small sample of bug reports based on spectral clustering according to claim 1, wherein the process of preprocessing the bug report text in step S1 comprises:
[0010] S11. Extract the title and description text of the Bug Report;
[0011] S12. Use Python's NLTK package to convert all words and letters in the text to lowercase, break the text string into individual words, and remove punctuation.
[0012] S13. Filter words that appear less than 5 times and convert the text into vectors using word2vec. Set the vector dimension to 200 and the window size to 5. Select Skip-gram as the word2vec training algorithm.
[0013] S14. The first 10 words of the title and the first 50 words of the description are retained. The excess words are discarded, and the insufficient words are padded with zero vectors to the specified length.
[0014] 3. The method for predicting the effectiveness of small sample bug reports based on spectral clustering according to claim 1, wherein the process of clustering the projects into a plurality of clusters using spectral clustering in step S2 comprises:
[0015] S21. Clustering results are determined by comprehensive evaluation of silhouette coefficient, Calinski-Harabasz index and Davies-Bouldin index. When the number of clusters is k, the comprehensive score calculation formula of clustering results is Score k =w_s·S k +w_c·C k +w_d·(1-D k ). Among them, S k 、C k 、D k The silhouette coefficient, CH index, and DB index calculated when the number of clusters is k are normalized to the interval (0, 1). w_s, w_c, and w_d represent the weights of the silhouette coefficient, CH index, and DB index, respectively. w_s is set to 0.7, and w_c and w_d are both set to 0.15.
[0016] S22. Based on the above evaluation formula, calculate the Score values corresponding to k=1~n (n is the number of items) in sequence to obtain the clustering result C={C1, C2, ..., Ck} that maximizes the Score.
[0017] 4. The method for predicting the effectiveness of small sample bug reports based on spectral clustering according to claim 1, wherein the process of adjusting the clustering results in step S3 comprises:
[0018] S31. Use the "interference degree" indicator to measure the overlap ratio of high-frequency words between valid and invalid bug reports. The calculation formula is: Among them, I all The union of the word sets representing invalid Bug Reports in all projects; V all W represents the union of the word sets of valid Bug Reports in all projects; all The intersection of the word sets representing invalid and valid bug reports in all projects. all and V all The words ranked in the top 5% of the frequency statistics were used;
[0019] S32. Calculate the interference value of each item and bundle items whose interference value is less than a threshold value α = 0.05 and belong to the same cluster. In the subsequent adjustment process, the result of bundling multiple items together is regarded as one item;
[0020] S33. Create a difference dictionary D to record the number of valid samples and invalid samples of each item and their differences, and initialize the item removal set S to store items whose differences are greater than zero;
[0021] S34, traverse each item in each cluster, calculate the difference between the number of valid and invalid samples of the item, and obtain the item difference. If the difference is greater than zero, the product is considered to affect the balance of the cluster and is added to the removal set S;
[0022] S35. Remove the items in S from each cluster. If the cluster becomes empty, remove the cluster from the original set of clusters.
[0023] S36. Calculate the number of valid samples, the number of invalid samples, and their difference for each cluster. Calculate the balance coefficient R_i for each cluster. This value is used to measure the balance of the cluster. The closer the value is to 1, the more balanced the cluster is.
[0024] S37, continuously select the items with the smallest differences and add them to the cluster with the largest differences to reduce the overall standard deviation;
[0025] S38. Repeat the above steps until the removal set is empty, or when the balance coefficients of all clusters satisfy R_min≤R_i≤R_max (R_min=1 / 1.6, R_max=1.6 / 1), and the sample size within each cluster is not less than N (N=3000), stop adjusting and obtain the adjusted clustering result C′={C1′,C2′,…,Cm′}.
[0026] 5. The method for predicting the effectiveness of small sample bug reports based on spectral clustering according to claim 1, wherein the process of training a CNN model for each adjusted cluster separately in step S4 comprises:
[0027] S41. The title and description of the input model are the first 10 and first 50 words respectively (the insufficient part is padded with zero vectors to the corresponding length);
[0028] S42. Set up two independent convolutional layers to process the title and description respectively. For both convolutional layers, we set three kernels with a width of 200. The kernel lengths for processing the title are 1, 2, and 3, respectively, and the kernel lengths for processing the description are 2, 3, and 4, respectively. The number of kernels of each type is 128, the stride is 1, there is no padding, and the activation function is RELU.
[0029] S43, global maximum pooling is used in the pooling layer without padding;
[0030] The output dimension of the S44 and connection layers is 1, the activation function is sigmoid, the optimizer is adam, and the learning rate is 0.0001. Training automatically stops when the model loss no longer decreases significantly over five consecutive epochs.
Brief Description of the Drawings
[0031] Figure 1 4 is a flowchart of a method for predicting the effectiveness of a small sample bug report based on spectral clustering according to an embodiment of the present invention.
[0032] Figure 2 This is an overall flow chart of a small sample bug report effectiveness prediction method based on spectral clustering according to an embodiment of the present invention.
[0033] Figure 3 This is a bug report example of the small sample bug report effectiveness prediction method based on spectral clustering provided by an embodiment of the present invention.
[0034] Figure 4 This is a CNN model training flowchart of a small sample bug report effectiveness prediction method based on spectral clustering provided by an embodiment of the present invention. [Specific implementation method]
[0035] In order to further clarify the purpose, technical solutions and advantages of the present invention, the following is a further detailed description of the present invention in conjunction with the accompanying drawings and examples. The specific embodiment described here is only an embodiment of the present invention and is only used to explain the specific embodiment of the present invention and does not limit the scope of protection of the present invention. The complete implementation process of the present invention is as follows Figure 2 shown.
[0036] Example: A dataset of 43,054 bug reports from 21 open source projects was collected from GitHub. All reports were submitted before May 2023 and were in the CLOSED state. Based on this project data, a small sample bug report validity prediction method based on spectral clustering was developed. The method includes:
[0037] Step S1: Preprocess all bug report texts of 21 projects, including text extraction, normalization, word segmentation, stop word removal, and word2vec vectorization;
[0038] Step S2: Cluster the item vectors into 7 clusters C = {C1, C2, ..., C7} using a spectral clustering algorithm combined with multiple evaluation metrics;
[0039] Step S3: Calculate the interference index for each item and group items whose interference index is less than a threshold value α = 0.05 and that belong to the same cluster. Adjust the clustering results so that the sample size in each cluster is no less than 3000, the positive and negative sample ratios are within the range of [1 / 1.6, 1.6 / 1], and the global standard deviation is minimized. Finally, the adjusted six clusters C′ = {C1′, C2′, …, C6′} are obtained.
[0040] Step S4: For each of the six clusters obtained after adjustment, a CNN model is trained for BugReport validity classification prediction. Six CNN models are trained and used to predict the validity of newly submitted BugReports.
[0041] The process of pre-processing all bug reports in step 1 includes:
[0042] S11. Extract the title and description text of all Bug Reports. Figure 3 This is an example of a Bug Report, with the title and description selected.
[0043] S12. Use Python's NLTK package to convert all words and letters in the text to lowercase, break the text string into individual words, and remove punctuation.
[0044] S13. Filter words that appear less than 5 times and convert the text into vectors using word2vec. Set the vector dimension to 200 and the window size to 5. Select Skip-gram as the word2vec training algorithm.
[0045] S14. The first 10 words of the title and the first 50 words of the description are retained. The excess words are discarded, and the insufficient words are padded with zero vectors to the specified length.
[0046] The process of clustering the items into k clusters using spectral clustering in step 2 includes:
[0047] S21, set the value of k to 1 to 21 (21 is the number of items), and use the comprehensive score calculation formula as Calculate the scores for different values of k. When the score reaches the highest, the cluster result C = {C1, C2, ..., C7} is obtained, indicating that k = 7 can achieve the highest comprehensive score.
[0048] The process of adjusting the clustering results in step 3 includes:
[0049] S31. Calculate the interference value of each item and bundle items whose interference value is less than a threshold value α = 0.05 and belong to the same cluster. In the subsequent adjustment process, the result of bundling multiple items together is regarded as one item;
[0050] S32. Create a difference dictionary D to record the number of valid samples and invalid samples of each item and their differences, and initialize the item removal set S to store items whose differences are greater than zero;
[0051] S33, traverse each item in each cluster, calculate the difference between the number of valid and invalid samples of the item, and obtain the item difference. If the difference is greater than zero, the product is considered to affect the balance of the cluster and is added to the removal set S;
[0052] S34. Remove the items in S from each cluster. If the cluster becomes empty, remove the cluster from the original set of clusters.
[0053] S35. Calculate the number of valid samples, the number of invalid samples, and their difference for each cluster. Calculate the balance coefficient R_i for each cluster. This value is used to measure the balance of the cluster. The closer the value is to 1, the more balanced the cluster is.
[0054] S36, continuously select the items with the smallest differences and add them to the cluster with the largest differences to reduce the overall standard deviation;
[0055] S37. Repeat the above steps until the removal set is empty, or when the balance coefficients of all clusters satisfy R_min≤R_i≤R_max (R_min=1 / 1.6, R_max=1.6 / 1), and the sample size within each cluster is not less than N (N=3000), stop adjusting and obtain the adjusted clustering result C′={C1′,C2′,…,C6′}.
[0056] The process of training a CNN model for each adjusted cluster in step 4 includes:
[0057] C′={C1′,C2′,…,C6′} has 6 clusters in total, using Figure 4 The pipeline shown trains a CNN model for each cluster.
[0058] S41. The title and description of the input model are the first 10 and first 50 words respectively (the insufficient part is padded with zero vectors to the corresponding length);
[0059] S42. Set up two independent convolutional layers to process the title and description respectively. For both convolutional layers, we set three kernels with a width of 200. The kernel lengths for processing the title are 1, 2, and 3, respectively, and the kernel lengths for processing the description are 2, 3, and 4, respectively. The number of kernels of each type is 128, the stride is 1, there is no padding, and the activation function is RELU.
[0060] S43, global maximum pooling is used in the pooling layer without padding;
[0061] The output dimension of the S44 and connection layers is 1, the activation function is sigmoid, the optimizer is adam, and the learning rate is 0.0001. Training automatically stops when the model loss no longer decreases significantly over five consecutive epochs.
[0062] After the above steps are completed, a total of 6 trained models are obtained, which can be used to predict the validity of bug reports for projects in the corresponding cluster.
Claims
1. A small sample bug report validity prediction method based on spectral clustering, characterized by: The following steps are involved: Step S1: preprocess all bug report texts of n projects, including text extraction, normalization, word segmentation, stop word removal, and word2vec vectorization; Step S2, using a spectral clustering algorithm combined with multiple evaluation indicators to cluster the item vectors into k clusters C = {C1, C2, ..., Ck}; Step S3: Introduce the interference index to detect and bind the interference between items in the cluster, and adjust the clustering results so that the sample size in each cluster is no less than 3000 and the positive and negative sample ratio is in the range of [1 / 1.6, 1.6 / 1], while the global standard deviation is minimized. Finally, the adjusted m clusters C′ = {C1′, C2′, …, Cm′} are obtained. Step S4: For each of the adjusted m clusters, a CNN model is trained for bug report validity classification prediction. After training, m CNN models are obtained and used to predict the validity of newly submitted bug reports.
2. A small sample bug report validity prediction method based on spectral clustering according to claim 1, characterized in that The process of pre-processing the Bug Report text in step S1 includes: S11. Extract the title and description text of the Bug Report; S12. Use Python's NLTK package to convert all words and letters in the text to lowercase, break the text string into individual words, and remove punctuation. S13. Filter words that appear less than 5 times and convert the text into vectors using word2vec. Set the vector dimension to 200 and the window size to 5. Select Skip-gram as the word2vec training algorithm. S14. The first 10 words of the title and the first 50 words of the description are retained. The excess words are discarded, and the insufficient words are padded with zero vectors to the specified length.
3. The method for predicting the effectiveness of a small sample size bug report based on spectral clustering according to claim 1, characterized in that The process of clustering the items into several clusters using spectral clustering in step S2 includes: S21. Clustering results are determined by comprehensive evaluation of silhouette coefficient, Calinski-Harabasz index and Davies-Bouldin index. When the number of clusters is k, the comprehensive score calculation formula of clustering results is Score k =w_s·S k +w_c·C k +w_d·(1-D k ). Among them, S k 、C k 、D k The silhouette coefficient, CH index, and DB index calculated when the number of clusters is k are normalized to the interval (0, 1). w_s, w_c, and w_d represent the weights of the silhouette coefficient, CH index, and DB index, respectively. w_s is set to 0.7, and w_c and w_d are both set to 0.
15. S22. Based on the above evaluation formula, calculate the Score values corresponding to k=1~n (n is the number of items) in sequence to obtain the clustering result C={C1, C2, ..., Ck} that maximizes the Score.
4. The method for predicting the effectiveness of a small sample bug report based on spectral clustering according to claim 1, characterized in that The process of adjusting the clustering results in step S3 includes: S31. Use the "interference degree" indicator to measure the overlap ratio of high-frequency words between valid and invalid bug reports. The calculation formula is: Among them, I all The union of the word sets representing invalid Bug Reports in all projects; V all W represents the union of the word sets of valid Bug Reports in all projects; all The intersection of the word sets representing invalid and valid bug reports in all projects. all and V all The words ranked in the top 5% of the frequency statistics were used; S32. Calculate the interference value of each item and bundle items whose interference value is less than a threshold value α = 0.05 and belong to the same cluster. In the subsequent adjustment process, the result of bundling multiple items together is regarded as one item; S33. Create a difference dictionary D to record the number of valid samples and invalid samples of each item and their differences, and initialize the item removal set S to store items whose differences are greater than zero; S34, traverse each item in each cluster, calculate the difference between the number of valid and invalid samples of the item, and obtain the item difference. If the difference is greater than zero, the product is considered to affect the balance of the cluster and is added to the removal set S; S35. Remove the items in S from each cluster. If the cluster becomes empty, remove the cluster from the original set of clusters. S36. Calculate the number of valid samples, the number of invalid samples, and their difference for each cluster. Calculate the balance coefficient R_i for each cluster. This value is used to measure the balance of the cluster. The closer the value is to 1, the more balanced the cluster is. S37. Continuously select the items with the smallest differences and add them to the cluster with the largest differences to reduce the overall standard deviation; S38. Repeat the above steps until the removal set is empty, or when the balance coefficients of all clusters satisfy R_min≤R_i≤R_max (R_min=1 / 1.6, R_max=1.6 / 1), and the sample size within each cluster is not less than N (N=3000), stop adjusting and obtain the adjusted clustering result C′={C1′,C2′,…,Cm′}.
5. The method for predicting the effectiveness of a small sample bug report based on spectral clustering according to claim 1, wherein The process of training a CNN model for each adjusted cluster in step S4 includes: S41. The title and description of the input model are the first 10 and first 50 words respectively (the insufficient part is padded with zero vectors to the corresponding length); S42. Set up two independent convolutional layers to process the title and description respectively. For both convolutional layers, we set three kernels with a width of 200. The kernel lengths for processing the title are 1, 2, and 3, respectively, and the kernel lengths for processing the description are 2, 3, and 4, respectively. The number of kernels of each type is 128, the stride is 1, there is no padding, and the activation function is RELU. S43, global maximum pooling is used in the pooling layer without padding; The output dimension of the S44 and connection layers is 1, the activation function is sigmoid, the optimizer is adam, and the learning rate is 0.0001. Training automatically stops when the model loss no longer decreases significantly over five consecutive epochs.