Software quality prediction method, system, device and medium based on attention mechanism
By using dynamic learning based on attention mechanisms and GRU networks, the problems of static evaluation and multi-dimensional quantitative weight adjustment in software quality prediction are solved, realizing dynamic quality evaluation and accurate prediction throughout the software lifecycle.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SICHUAN XW BANK CO LTD
- Filing Date
- 2022-09-28
- Publication Date
- 2026-04-28
AI Technical Summary
Existing software quality prediction methods suffer from static quality prediction problems and the inability to dynamically adjust the weights of multi-dimensional elements that affect the evaluation results, and the accuracy of software quality prediction is not high.
We employ an attention-based approach, constructing an attention mechanism using the deep learning framework TensorFlow to dynamically learn and measure metadata weights. This is combined with a gated recurrent network (GRU) with memory capabilities to establish the comprehensive impact of metrics on software quality at various stages of the software lifecycle, enabling dynamic prediction.
It improves the accuracy of software quality prediction, realizes dynamic quality assessment throughout the software lifecycle, dynamically adjusts the weights of metrics, reduces the impact of noise, and enhances the positive effect of key features on prediction results.
Smart Images

Figure CN115509916B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent testing, and more specifically to a software quality prediction method, system, device, and medium based on an attention mechanism. Background Technology
[0002] With the continuous development of the software development field and the increasing scale of software, comprehensive quality control is crucial to effectively prevent losses caused by software failures. Traditional software evaluation methods involve establishing a software quality evaluation system, collecting test values of metrics during testing, calculating metric values based on measurement methods, and finally weighting and summing all metrics to assess software quality. However, this existing software quality evaluation technology represents a static statistical assessment of completed software. Software quality evaluation occurs throughout the entire software lifecycle and is a dynamic predictive process, not a static statistical assessment of completed software. Therefore, how to objectively and accurately assess software quality at each stage of the entire software lifecycle is a key research issue in the field of software quality.
[0003] In summary, existing technologies suffer from problems such as static quality prediction, the inability to dynamically adjust the weights of multi-dimensional elements affecting the evaluation results, and low accuracy of software quality prediction. Summary of the Invention
[0004] The technical problems this invention aims to solve are the static quality prediction issues and the inability to dynamically adjust the weights of multi-dimensional metrics affecting the evaluation results in existing software quality prediction methods, resulting in low accuracy. This invention aims to provide a software quality prediction method, system, device, and medium based on an attention mechanism. By automatically learning and adjusting the weight ratios of metric metadata through the attention mechanism, the accuracy of software quality prediction is improved. Furthermore, a gated recurrent network (GRU) with memory capabilities is introduced to establish the comprehensive impact of metrics on software quality at various stages of the software lifecycle, achieving dynamic prediction throughout the entire software lifecycle.
[0005] This invention is achieved through the following technical solution:
[0006] In a first aspect, the present invention provides a software quality prediction method based on an attention mechanism, the method comprising:
[0007] At fixed time intervals, acquire various test metric metadata from the software lifecycle of a historical project, and preprocess it to obtain preprocessed metric metadata.
[0008] Based on the preprocessed metric metadata, the influence weights are dynamically learned through an attention mechanism to obtain weighted metric metadata.
[0009] Train a GRU network prediction model based on weighted metric metadata.
[0010] The software quality of the new project is predicted using a trained GRU network prediction model, and the quality level of the new project is obtained.
[0011] Among them, the GRU network prediction model is a gated recurrent network prediction model with memory capabilities.
[0012] Furthermore, the metrics metadata includes test process analysis data and development process historical data.
[0013] Furthermore, the test process analysis data includes module defect density (number of defects / code size), number of defects in the testing phase, number of defects in the trial operation phase, number of defects in the regression phase, number of defects at each severity level, personnel turnover rate, individual work order time, and number of test points per person.
[0014] Historical development data includes the number of defects during the smoke phase, the number of lines of code modified, the number of new database tables and fields, the number of associated services, and the version interval.
[0015] The above technical solutions include a total of 13 categories of measurement metadata.
[0016] Furthermore, preprocessing methods include:
[0017] Clean up outliers in metric metadata;
[0018] It also vectorizes and standardizes all types of metric metadata.
[0019] Furthermore, based on the preprocessed metric metadata, the influence weights are dynamically learned through an attention mechanism to obtain weighted metric metadata, including:
[0020] An attention mechanism is built using the deep learning framework TensorFlow;
[0021] The preprocessed metric metadata is input into the constructed attention mechanism. The attention mechanism learns the effect of various types of metrics on the prediction results and dynamically adjusts the metric weights to obtain weighted metric metadata.
[0022] Further, the GRU network prediction model is trained, including:
[0023] The weighted metric metadata is input into the GRU network prediction model at each time step;
[0024] The GRU network prediction model calculates the loss value between the actual software quality score and the model's predicted software quality score using the cross-entropy function, and trains the GRU network using the error backpropagation algorithm to obtain the trained GRU network prediction model.
[0025] Secondly, the present invention provides a software quality prediction system based on an attention mechanism, which supports a software quality prediction method based on an attention mechanism; the system includes:
[0026] The acquisition unit is used to acquire metadata of various test metrics throughout the software lifecycle of a historical project at fixed time intervals.
[0027] The preprocessing unit is used to preprocess the metric metadata to obtain preprocessed metric metadata.
[0028] The dynamic learning weight unit is used to dynamically learn the influence weights based on the preprocessed metric metadata through an attention mechanism, and obtain the weighted metric metadata.
[0029] The GRU prediction model training unit is used to train the GRU network prediction model based on the weighted metric metadata.
[0030] The new project software quality prediction unit is used to predict the software quality of new projects using a trained GRU network prediction model, and obtain the quality level of the new project.
[0031] Furthermore, the execution process of the GRU prediction model training unit is as follows:
[0032] The weighted metric metadata is input into the GRU network prediction model at each time step;
[0033] The GRU network prediction model calculates the loss value between the actual software quality score and the model's predicted software quality score using the cross-entropy function, and trains the GRU network using the error backpropagation algorithm to obtain the trained GRU network prediction model.
[0034] Thirdly, the present invention 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 processor executes the computer program to implement the attention-based software quality prediction method described above.
[0035] Fourthly, the present invention provides a computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the aforementioned attention-based software quality prediction method.
[0036] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0037] This invention relates to a software quality prediction method, system, device, and medium based on an attention mechanism. The invention collects various test metric metadata throughout the software lifecycle at fixed time intervals and combines this with a deep learning algorithm to achieve dynamic prediction of software quality assessment. The invention learns the effects of different types of metrics on the prediction results through an attention mechanism, dynamically adjusting metric weights to reduce noise and enhance the positive impact of key features on the prediction results. Furthermore, the invention uses a deep learning model, GRU, to learn the global dependencies of weighted metric features and combines this with a cross-entropy loss function to back-train the deep learning model, thereby improving the accuracy of software quality prediction. Attached Figure Description
[0038] The accompanying drawings, which are included to provide a further understanding of embodiments of the invention and form part of this application, do not constitute a limitation thereof. In the drawings:
[0039] Figure 1 This is a flowchart of the software quality prediction method based on the attention mechanism of the present invention.
[0040] Figure 2 This is a detailed flowchart of the attention mechanism-based software quality prediction method of the present invention.
[0041] Figure 3 This is a schematic diagram of the software quality prediction system based on the attention mechanism of the present invention. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.
[0043] Example 1
[0044] This invention improves the accuracy of software quality prediction by automatically learning and adjusting the weight ratio of metric metadata through an attention mechanism; it introduces a gated recurrent network (GRU) with memory capabilities to establish the comprehensive impact of metric indicators on software quality at each stage of the software lifecycle, thereby achieving dynamic prediction throughout the entire software lifecycle.
[0045] like Figure 1 As shown, the present invention provides a software quality prediction method based on an attention mechanism, which includes:
[0046] Step 1: Acquire and store the test metrics metadata of a historical project software lifecycle at fixed time intervals, take the above metrics metadata as a sample, and preprocess it to obtain the preprocessed metrics metadata.
[0047] Metadata includes test process analysis data and development process historical data; test process analysis data includes module defect density (number of defects / code size), number of defects in the test submission phase, number of defects in the trial operation phase, number of defects in the regression phase, number of defects at each severity level, personnel turnover rate, individual work order time, and number of test points per person.
[0048] Historical development data includes the number of defects during the smoke phase, the number of lines of code modified, the number of new database tables and fields, the number of associated services, and the version interval.
[0049] When the technical solution of this invention is implemented, a total of 13 types of measurement metadata are used.
[0050] Preprocessing methods include: cleaning outliers in metric metadata and vectorizing and standardizing all types of metric metadata.
[0051] Step 2: Based on the preprocessed metric metadata, dynamically learn the influence weights through an attention mechanism to obtain weighted metric metadata; Step 2 specifically includes:
[0052] An attention mechanism is built using the deep learning framework TensorFlow;
[0053] The preprocessed metric metadata is input into the constructed attention mechanism. The attention mechanism learns the effect of various types of metrics on the prediction results and dynamically adjusts the metric weights to obtain weighted metric metadata.
[0054] The above technical solution, after multiple experiments, uses 7 days as a fixed time interval to collect metric data once, assembles it into a 1*13 dimension vector, and sets the data length of a sample to 30. Therefore, step 1 obtains a 30*13 data matrix as the input of the attention mechanism. Through the attention mechanism, the effect of various types of metrics on the prediction results is learned, and the metric weights are dynamically adjusted to achieve the purpose of noise reduction and improving the positive effect of key features on the prediction results.
[0055] Step 3: Train the GRU network prediction model based on the weighted metric metadata; where the GRU network prediction model is a gated recurrent network prediction model with memory capabilities.
[0056] Step 3 specifically includes:
[0057] The weighted metric metadata is input into the GRU network prediction model at each time step;
[0058] The GRU network prediction model calculates the loss value between the actual software quality score and the model's predicted software quality score using the cross-entropy function, and trains the GRU network using the error backpropagation algorithm to obtain the trained GRU network prediction model.
[0059] Step 4: Use the trained GRU network prediction model to predict the software quality of the new project and obtain the quality level of the new project.
[0060] A new project is given identical metric metadata collected at regular time intervals. After preprocessing, this metadata is fed into a pre-trained GRU network prediction model, which outputs a quality probability score for the new project. A predicted project quality probability score between 0 and 0.2 indicates a fatal risk; between 0.2 and 0.4, a moderate to urgent risk; between 0.4 and 0.6, a severe risk; between 0.6 and 0.8, a moderate risk; and between 0.8 and 1, a minor risk.
[0061] Figure 2 This is a detailed flowchart of the attention mechanism-based software quality prediction method of the present invention.
[0062] This invention collects various test metric metadata at fixed time intervals throughout the software lifecycle and combines it with deep learning algorithms to achieve dynamic prediction of software quality assessment. It uses an attention mechanism to learn the effects of different types of metrics on the prediction results, dynamically adjusting metric weights to reduce noise and enhance the positive impact of key features on the prediction results. Furthermore, it uses a deep learning model, GRU, to learn the global dependencies of weighted metric features and combines this with a cross-entropy loss function to back-train the deep learning model, thereby improving the accuracy of software quality prediction.
[0063] Example 2
[0064] like Figure 2 As shown, the difference between this embodiment and Embodiment 1 is that this embodiment further provides a software quality prediction system based on an attention mechanism, which supports the software quality prediction method based on an attention mechanism in Embodiment 1; the system includes:
[0065] The acquisition unit is used to acquire metadata of various test metrics throughout the software lifecycle of a historical project at fixed time intervals.
[0066] The preprocessing unit is used to preprocess the metric metadata to obtain preprocessed metric metadata.
[0067] The dynamic learning weight unit is used to dynamically learn the influence weights based on the preprocessed metric metadata through an attention mechanism, and obtain the weighted metric metadata.
[0068] The GRU prediction model training unit is used to train the GRU network prediction model based on the weighted metric metadata.
[0069] The new project software quality prediction unit is used to predict the software quality of new projects using a trained GRU network prediction model, and obtain the quality level of the new project.
[0070] Furthermore, the execution process of the GRU prediction model training unit is as follows:
[0071] The weighted metric metadata is input into the GRU network prediction model at each time step;
[0072] The GRU network prediction model calculates the loss value between the actual software quality score and the model's predicted software quality score using the cross-entropy function, and trains the GRU network using the error backpropagation algorithm to obtain the trained GRU network prediction model.
[0073] The execution process of each unit can be carried out according to the steps of the software quality prediction method based on attention mechanism described in Example 1, and will not be repeated in this example.
[0074] Meanwhile, the present invention 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 processor executes the computer program to implement the aforementioned attention-based software quality prediction method.
[0075] Meanwhile, the present invention also provides a computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, implements the aforementioned attention-based software quality prediction method.
[0076] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0077] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0078] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0079] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0080] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A software quality prediction method based on an attention mechanism, characterized in that, The method includes: At fixed time intervals, acquire various test metric metadata from the software lifecycle of a historical project, and preprocess it to obtain preprocessed metric metadata. Based on the preprocessed metric metadata, the influence weights are dynamically learned through an attention mechanism to obtain weighted metric metadata. Train a GRU network prediction model based on the weighted metric metadata. The software quality of the new project is predicted using a trained GRU network prediction model to obtain the quality level of the new project. The metric metadata includes test process analysis data and development process historical data; The data analyzed during the testing process includes module defect density, number of defects in the testing phase, number of defects in the trial operation phase, number of defects in the regression phase, number of defects at each severity level, personnel turnover rate, individual work order time, and number of test points per person. The historical data of the development process includes the number of defects during the smoke phase, the number of lines of code modified, the number of new database tables and fields, the number of associated services, and the version interval time. The trained GRU network prediction model includes: The weighted metric metadata is input into the GRU network prediction model at each time step; The GRU network prediction model calculates the loss value between the actual software quality score and the model's predicted software quality score using the cross-entropy function, and trains the GRU network using the error backpropagation algorithm to obtain the trained GRU network prediction model.
2. The software quality prediction method based on attention mechanism according to claim 1, characterized in that, The preprocessing methods include: Clean up outliers in metric metadata; It also vectorizes and standardizes all types of metric metadata.
3. The software quality prediction method based on attention mechanism according to claim 1, characterized in that, Based on the preprocessed metric metadata, influence weights are dynamically learned through an attention mechanism to obtain weighted metric metadata, including: An attention mechanism is built using the deep learning framework TensorFlow; The preprocessed metric metadata is input into the constructed attention mechanism. The attention mechanism learns the effects of various types of metrics on the prediction results and dynamically adjusts the metric weights to obtain weighted metric metadata.
4. A software quality prediction system based on an attention mechanism, characterized in that, The system supports the attention-based software quality prediction method as described in any one of claims 1 to 3; the system comprises: The acquisition unit is used to acquire metadata of various test metrics throughout the software lifecycle of a historical project at fixed time intervals. The preprocessing unit is used to preprocess the measurement metadata to obtain preprocessed measurement metadata; The dynamic learning weight unit is used to dynamically learn the influence weights based on the preprocessed metric metadata through an attention mechanism to obtain weighted metric metadata. The GRU prediction model training unit is used to train the GRU network prediction model based on the weighted metric metadata. The new project software quality prediction unit is used to predict the software quality of new projects using a trained GRU network prediction model, and obtain the quality level of the new project. The metric metadata includes test process analysis data and development process historical data; The data analyzed during the testing process includes module defect density, number of defects in the testing phase, number of defects in the trial operation phase, number of defects in the regression phase, number of defects at each severity level, personnel turnover rate, individual work order time, and number of test points per person. The historical data of the development process includes the number of defects during the smoke phase, the number of lines of code modified, the number of new database tables and fields, the number of associated services, and the version interval time. The execution process of the GRU prediction model training unit is as follows: The weighted metric metadata is input into the GRU network prediction model at each time step; The GRU network prediction model calculates the loss value between the actual software quality score and the model's predicted software quality score using the cross-entropy function, and trains the GRU network using the error backpropagation algorithm to obtain the trained GRU network prediction model.
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, it implements the attention-based software quality prediction method as described in any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the attention-based software quality prediction method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Attention mechanism-based GRU deep learning ocean station surface salinity prediction method
CN112288193A
Industrial software vulnerability detection method based on self-attention mechanism
CN113591093A