Software defect prediction method, related device, equipment and storage medium

By extracting the feature set of the reference software and determining the weight factors based on information entropy, and combining the improved gazelle optimization algorithm to optimize the defect prediction model, the problem of strong subjectivity in feature selection in software defect prediction is solved, and higher accuracy and generalization ability are achieved.

CN120994559APending Publication Date: 2025-11-21HEFEI IFLY DIGITAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511133153.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-13
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

Existing software defect prediction technologies suffer from high subjectivity in feature selection, resulting in low accuracy and generalization ability.

Method used

The program code based on the reference software extracts the feature set, measures the information entropy and determines the weight factor of the feature category, and combines the improved gazelle optimization algorithm to optimize the defect prediction model. The feature representation is objectively selected using information entropy and weight factor.

Benefits of technology

It improves the objectivity of feature selection, enhances the accuracy and generalization ability of software defect prediction, and reduces the impact of instability noise.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994559A_ABST
    Figure CN120994559A_ABST
Patent Text Reader

Abstract

The invention discloses a software defect prediction method, a related device, equipment and a storage medium, and the method comprises the steps: extracting a first feature set of reference software based on a program code of the reference software; wherein the first feature set comprises code feature representations of the reference software about a plurality of preset feature categories; based on the first feature set of the reference software, measuring to obtain information entropies of a plurality of preset feature categories in the reference software; based on the information entropies of the same preset feature category in different reference software, determining to obtain a weight factor corresponding to the preset feature category; on the basis of a second feature set extracted from the program code of the to-be-detected software, predicting to obtain a defect detection result of the to-be-detected software; wherein the second feature set comprises code feature representations of the to-be-tested software about a plurality of preset feature categories and weight factors of the code feature representations. According to the scheme, the objectivity of feature selection can be improved, so that the accuracy and generalization ability of software defect prediction are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, in particular to a software defect prediction method and related device, equipment and storage medium. BACKGROUND

[0002] With the continuous improvement of the complexity of software systems, defect prediction plays an increasingly important role in quality control, resource allocation and risk management.

[0003] At present, existing defect prediction technologies such as feature engineering based on artificial features and shallow learning models have achieved certain results in specific scenarios, but they generally have the problem of strong subjectivity in feature selection, which leads to low accuracy and generalization ability of software defect prediction. Therefore, how to improve the objectivity of feature selection to improve the accuracy and generalization ability of software defect prediction has become a problem to be solved. SUMMARY

[0004] The technical problem solved by the present application is to provide a software defect prediction method and related device, equipment and storage medium, which can improve the objectivity of feature selection to improve the accuracy and generalization ability of software defect prediction.

[0005] In order to solve the above technical problem, the first aspect of the present application provides a software defect prediction method, comprising: based on the program code of the reference software, extracting the first feature set of the reference software; wherein the first feature set contains the code feature representation of the reference software about a plurality of preset feature categories; based on the first feature set of the reference software, measuring the information entropy of the plurality of preset feature categories in the reference software respectively; based on the information entropy of the same preset feature category in different reference software, determining the weight factor of the corresponding preset feature category; based on the second feature set extracted from the program code of the to-be-tested software, predicting the defect detection result of the to-be-tested software; wherein the second feature set contains the code feature representation and its weight factor of the to-be-tested software about a plurality of preset feature categories.

[0006] To solve the above technical problems, the second aspect of the present application provides a software defect prediction device, comprising: a feature extraction module, an entropy measurement module, a weight determination module and a defect prediction module, the feature extraction module is used for extracting the first feature set of the reference software based on the program code of the reference software; wherein the first feature set contains the code feature representation of the reference software about several preset feature categories; the entropy measurement module is used for measuring the information entropy of the same preset feature category in the reference software based on the first feature set of the reference software; the weight determination module is used for determining the weight factor of the corresponding preset feature category based on the information entropy of the same preset feature category in different reference software; the defect prediction module is used for predicting the defect detection result of the software to be tested based on the second feature set extracted from the program code of the software to be tested; wherein the second feature set contains the code feature representation of the software to be tested about several preset feature categories and the weight factor thereof.

[0007] To solve the above technical problems, the third aspect of the present application provides an electronic device, at least comprising a memory and a processor coupled with each other, the memory at least stores program instructions, and the processor is used to execute the program instructions to realize the software defect prediction method in the first aspect.

[0008] To solve the above technical problems, the fourth aspect of the present application provides a computer readable storage medium, which stores program instructions capable of being run by a processor, and the program instructions are used to realize the software defect prediction method of the first aspect.

[0009] The above scheme extracts a first feature set of the reference software based on the program code of the reference software, and the first feature set contains code feature representations of the reference software about a plurality of preset feature categories. The information entropy of each preset feature category is measured based on the first feature set of the reference software. The weight factor of the corresponding preset feature category is determined based on the information entropy of the same preset feature category in different reference software. The defect detection result of the software under test is predicted based on a second feature set extracted from the program code of the software under test. The second feature set contains code feature representations of the software under test about a plurality of preset feature categories and their weight factors. Therefore, the weight factor of the preset feature category can be determined as objectively as possible by the distribution characteristics of the information entropy of the preset feature category in different reference software, so that the code feature representations of different preset feature categories can be selectively referenced in different degrees according to the weight factor in the defect prediction process, which helps to avoid introducing unstable noise in the defect prediction process as much as possible, improves the objectivity of feature selection, and because different reference software is referred to in the determination process of the weight factor instead of a single software, the weight factor determined thereby can have stronger adaptability to software data with different distributions. Therefore, the objectivity of feature selection can be improved to improve the accuracy and generalization ability of software defect prediction. BRIEF DESCRIPTION OF DRAWINGS

[0010] Figure 1 FIG. 1 is a flowchart of an embodiment of the software defect prediction method of the present application; Figure 2 FIG. 2 is a framework diagram of an embodiment of the software defect prediction device of the present application; Figure 3 FIG. 3 is a framework diagram of an embodiment of the electronic device of the present application; Figure 4 FIG. 4 is a framework diagram of an embodiment of the computer readable storage medium of the present application. DETAILED DESCRIPTION

[0011] The schemes of the embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0012] In the following description, specific details such as specific system structures, interfaces, techniques, etc. are presented in order to thoroughly understand the present application, but are not intended to limit the present application.

[0013] The terms "system" and "network" are often used interchangeably herein. The term "and / or", whether used in the context of "comprising", "containing", "including", "having" or any other variation thereof, is used to mean a total of any one of the listed possibilities or a total of any combination of at least two of the listed possibilities. In addition, the term "a" or "an" is used herein to mean one or more than one of the referenced item. Further, the term "plurality" is used herein to mean two or more than two.

[0014] Referring to Figure 1 , Figure 1 is a flowchart of an embodiment of the software defect prediction method. Specifically, it can include the following steps: Step S11: Based on the program code of the reference software, a first feature set of the reference software is extracted.

[0015] In the embodiments of the present disclosure, the first feature set contains code feature representations of the reference software with respect to a plurality of preset feature categories. It should be noted that the plurality of preset feature categories can include but are not limited to code feature categories such as cyclomatic complexity, comment ratio, function length, etc., and the specific categories covered by the plurality of preset feature categories are not limited herein.

[0016] In one implementation scenario, the reference software and the software to be tested can belong to the same project domain. It should be noted that different software belonging to the same project domain can have the same software architecture, code language environment and program code specification; conversely, different software belonging to different project domains can differ in at least one of software architecture, code language environment and program code specification.

[0017] In one implementation scenario, as one possible example, the program code of the reference software can be first subjected to feature extraction to obtain an original feature set of the reference software, and the original feature set can contain original code feature representations of the reference software with respect to a plurality of preset feature categories. Then, the original feature set is subjected to normalization processing, and the first feature set is obtained. It should be noted that at this time, the first feature set can specifically contain code feature representations of the reference software after normalization with respect to a plurality of preset feature categories, so as to eliminate dimensional influence and scale bias as much as possible. Of course, as another possible example, the program code of the reference software can also be directly subjected to feature extraction to obtain the first feature set of the reference software, i.e., normalization processing can also not be performed.

[0018] Step S12: Based on the first feature set of the reference software, the information entropy of the plurality of preset feature categories in the reference software is measured.

[0019] Specifically, for each preset feature category in the first feature set, the information entropy of the preset feature category in the reference software can be calculated based on the code feature representation of the preset feature category. It should be noted that the information entropy is used to quantify the uncertainty or randomness of information. In addition, the calculation process of the information entropy of the preset feature category in the reference software can refer to the technical details of the information entropy, which will not be described here.

[0020] Step S13: determining the weight factor of the corresponding preset feature category based on the information entropy of the same preset feature category in different reference software.

[0021] In one implementation scenario, different reference software can belong to the same project domain (for example, can have the same software architecture, code language environment and program code specification), or can belong to different project domains (for example, at least one of the different reference software about software architecture, code language environment (for example, Java, C++, Python, etc.), program code specification can be different), whether the different reference software belongs to the same project domain is not limited here.

[0022] In one implementation scenario, as a possible implementation, the entropy dispersion of the corresponding preset feature category can be measured based on the information entropy of the same preset feature category in different reference software, and the entropy dispersion of the preset feature category represents the uncertainty degree of the information entropy of the preset feature category in different reference software. On this basis, the weight factor of the preset feature category can be determined based on the entropy dispersion of the preset feature category, and the weight factor is negatively related to the entropy dispersion. That is, the greater the entropy dispersion of the preset feature category (at this time, the uncertainty degree is higher), the smaller the weight factor of the preset feature category, so as to inhibit the code feature representation of the preset feature category in defect prediction; on the contrary, the smaller the entropy dispersion of the preset feature category (at this time, the uncertainty degree is lower), the greater the weight factor of the preset feature category, so as to enhance the code feature representation of the preset feature category in defect prediction. The above-mentioned manner, by measuring the entropy dispersion of the preset feature category based on the information entropy of the preset feature category in different reference software, determines the weight factor of the preset feature category, which helps to avoid introducing uncertain noise as much as possible, and at the same time analyzes the dispersion of the preset feature category in different reference software, which can also prevent performance degradation caused by feature bias as much as possible when migration learning is needed, especially when different reference software belongs to different project domains, so as to improve the cross-software generalization ability.

[0023] In a specific implementation scenario, in order to measure the entropy dispersion, the variance can be calculated based on the information entropy of the same preset feature category in different reference software, so as to serve as the entropy dispersion. It should be noted that the greater the variance, the more dispersed the information entropy of the same preset feature category in different reference software, that is, the higher the degree of uncertainty of the preset feature category about the information entropy in different reference software, and therefore the greater the entropy dispersion. Conversely, the smaller the variance, the more concentrated the information entropy of the same preset feature category in different reference software, that is, the lower the degree of uncertainty of the preset feature category about the information entropy in different reference software, and therefore the smaller the entropy dispersion. Of course, the above example is only one possible example of measuring the entropy dispersion, and other possible measurement methods are not limited herein, nor will they be exemplified one by one.

[0024] In a specific implementation scenario, the negative correlation between the entropy dispersion and the weight factor can be a linear relationship or a nonlinear relationship, and the specific expression of the negative correlation between the entropy dispersion and the weight factor is not limited herein.

[0025] In another implementation scenario, as another possible implementation, for the information entropy of the same preset feature category in different reference software, the upper quartile and the lower quartile can be extracted first, and then the difference between the upper quartile and the lower quartile is calculated. The difference can measure the degree of uncertainty of the preset feature category about the information entropy in different reference software, for example, the greater the difference, the higher the degree of uncertainty, and vice versa, the smaller the difference, the lower the degree of uncertainty. On this basis, the weight factor of the preset feature category can be determined based on the above difference of the preset feature category. It should be noted that the weight factor of the preset feature category is negatively correlated with the above difference of the preset feature category. That is, the greater the above difference of the preset feature category, the smaller the weight factor of the preset feature category, and vice versa, the smaller the above difference of the preset feature category, the greater the weight factor of the preset feature category.

[0026] It should be noted that the above two implementation methods are only two possible examples of determining the weight factor of the preset feature category based on the information entropy of the preset feature category, and other possible implementation methods are not limited herein, nor will they be exemplified one by one. In addition, the determination method of the above weight factor can be flexibly embedded in the existing data flow, whether in a traditional software system or in a micro-service or DevOps scenario module-level defect detection. Of course, in actual application, the weight factor can also be determined by referring to only a single reference software. For example, the greater the information entropy of the preset feature category in a single reference software, the greater the weight factor of the preset feature category, and vice versa, the smaller the information entropy of the preset feature category in a single reference software, the smaller the weight factor of the preset feature category, so as to select the preset feature category with high information entropy as the specific preset feature category with high weight factor.

[0027] Step S14: predicting a defect detection result of the software under test based on the second feature set extracted from the program code of the software under test.

[0028] In the embodiments of the present disclosure, the second feature set can include code feature representations of the software under test with respect to a plurality of preset feature categories and weight factors thereof. It should be noted that the plurality of preset feature categories can refer to the foregoing related description, which will not be repeated here. As a possible example, the code feature representations of the plurality of preset feature categories in the software under test can be weighted based on the weight factors of the plurality of preset feature categories to obtain weighted feature representations, and the weighted feature representations can be used for prediction to obtain the defect detection result. For example, a defect prediction model including network layers such as a fully connected layer can be used to predict the weighted feature representations to obtain the defect detection result. Alternatively, as another possible example, the second feature set can be directly predicted based on a defect prediction model to obtain the defect detection result of the software under test. Of course, the above examples are only two possible examples of defect prediction based on the second feature set, and other possible implementations are not limited here, nor will they be exemplified one by one. In addition, the defect detection result can at least include whether the software under test has a defect. For example, the defect detection result of the software under test can at least include that the software under test has a defect, or the defect detection result of the software under test can at least include that the software under test has no defect. In addition, as a possible example, in the case where the defect detection result includes that the software under test has a defect, the defect detection result can also include the type of defect of the software under test, such as a functional defect (missing function, unavailable function, etc.), an interface defect (interaction logic defect, display error, etc.), a performance defect (slow response, resource leakage, etc.), and a compatibility defect (platform compatibility, hardware compatibility, etc.). The possible cases of the defect type are not limited here, nor will they be exemplified one by one.

[0029] In one implementation scenario, as described above, the defect detection result can be obtained by predicting the second feature set based on a defect prediction model. The defect prediction model can include but is not limited to network layers such as convolution layers, fully connected layers, attention layers, etc., and the network structure of the defect prediction model is not limited here. For example, the defect prediction model can use a neural network model including but not limited to AlexNet, VGG, ResNet, InceptionNet, etc.

[0030] In one implementation scenario, as mentioned previously, the defect detection result can be predicted by the defect prediction model on the second feature set, and the defect prediction model can include a language-neutral code representation layer (LNRL). The code representation layer can be used to: abstract the static metric features and the code nesting structure into a semantic graph, and then fuse the semantic graph and the code feature representation for the network layer after the code representation layer in the defect prediction model to continue processing. In this way, embedding the language-neutral code representation layer in the defect prediction model can bridge the distribution gap caused by language differences.

[0031] In one implementation scenario, as mentioned previously, the defect detection result can be predicted by the defect prediction model on the second feature set, and the hyperparameters of the defect prediction model can be optimized based on an improved gazelle optimization algorithm (IGOA). To facilitate understanding, the general process of the improved gazelle optimization algorithm (hereinafter referred to as IGOA) is briefly described as follows. (1) First, initialize the population: initialize the gazelle individuals using the elite inverse learning strategy, which generates inverse individuals opposite to the original individuals in some way, selects the better individual as the elite inverse individual, and combines it with the original population, thereby improving the quality of the initial solution and increasing the diversity of the population; (2) Then set the algorithm parameters: set the maximum number of iterations, the related parameters of the two-stage nonlinear inertia weight, the parameters of the survival rate guided Cauchy disturbance strategy, etc.; (3) Next, perform iterative optimization: in the early stage of algorithm iteration, the two-stage nonlinear inertia weight can be used to guide the position update of the population, i.e., according to the relationship between the current iteration number and the total iteration number, the inertia weight is dynamically adjusted, so that the algorithm pays more attention to global search in the early stage and gradually shifts to local search in the later stage, to improve the accuracy of the algorithm and balance the global search and local search capabilities of the algorithm; (4) Then update the position: in the exploration stage, the survival rate guided Cauchy disturbance strategy is introduced into the position update formula of the population, i.e., the strength of the Cauchy disturbance is determined according to the survival rate of the individual, and the population position is updated, so that the algorithm can jump out of the local optimum and enhance the global search capability of the algorithm; (5) Then judge the termination condition: check whether the maximum number of iterations is reached or other termination conditions are met, such as the change of the optimal solution being less than a certain threshold after continuous iterations, etc. If the termination condition is met, the algorithm is stopped, otherwise, return to step (3) to continue iterative optimization; (6) Finally, output the result: after the algorithm stops, the optimal solution found can be output. Of course, the above description is only a general introduction to the process of IGOA, and specific technical details of IGOA can be referred to, which will not be described here. The following describes the adaptive improvements made by IGOA when applied to hyperparameter optimization of the defect prediction model.

[0032] In a specific implementation scenario, during the initial stage of IGOA, the hyperparameter solution space of the defect prediction model can be mapped to vector form, serving as individual position vectors. It should be noted that the hyperparameter solution space can involve both model structural parameters and model training parameters. As one possible example, model structural parameters are the hyperparameters that affect the model structure, specifically including but not limited to: kernel size, stride, number of convolutional layers, number of fully connected layers, etc. Here, we do not limit the scope of model structural parameters. As another possible example, model training parameters are the hyperparameters that affect model training, specifically including but not limited to: learning rate, dropout rate, etc. Here, we do not limit the scope of model training parameters. Furthermore, the specific process of mapping the hyperparameter solution space to vector form can be found in the technical details of individual initialization in IGOA, and will not be elaborated upon here.

[0033] In a specific implementation scenario, during hyperparameter optimization based on IGOA, the population fitness distribution can be mapped using a weighted adaptive transformation function to obtain the global search ratio and the local search ratio. It should be noted that the global search ratio constrains a broad search across the entire search space, while the local search ratio constrains a fine-grained search around the current optimal solution. Furthermore, the independent variable of the weighted adaptive transformation function is the population fitness distribution, and the dependent variables are the global search ratio and the local search ratio. In other words, the weighted adaptive transformation function can automatically adjust the global and local search ratios according to the population fitness distribution. This approach, by mapping the population fitness distribution using the weighted adaptive transformation function to obtain the global and local search ratios, enables a two-stage dynamic escape mechanism for both global and local searches. During the exploration-dominant phase, it encourages broad exploration by employing a large-step perturbation search strategy to minimize the risk of a homogeneous population distribution due to insufficient early exploration. During the convergence-focusing phase, it gradually introduces a directional migration mechanism to guide individuals towards the current optimal region, minimizing the risk of getting trapped in local minima later on, which could negatively impact the optimization convergence quality. Therefore, IGOA can be restructured from the perspective of structural improvement of search strategy to better adapt to the needs of deep learning.

[0034] In one specific implementation scenario, in the process of optimizing the hyperparameters based on IGOA, a preset feature category can be selected as a perturbation feature category based on the information entropy of each of the preset feature categories, and the information entropy of the perturbation feature category can be higher than an entropy threshold. When the code feature representation of the perturbation feature category is processed by the defect prediction model, the individual position vector representing the combination of the hyperparameters can be modified. For example, the preset feature category with the information entropy higher than the entropy threshold can be selected as the perturbation feature category (i.e., a perturbation trigger factor). In this way, the individual position vector can be fine-tuned in a specific search stage to help the optimization algorithm better adapt to the perturbation feature category or jump out of a local optimum. In the above manner, by selecting the preset feature category with the information entropy higher than the entropy threshold as the perturbation feature category and triggering the modification of the individual position vector representing the combination of the hyperparameters when the code feature representation of the perturbation feature category is processed by the defect prediction model, a data-driven dynamic feedback mechanism can be introduced, and the internal synergy between the model structure optimization and the data features can be achieved to effectively enhance the jumping ability of the optimization algorithm in a high-dimensional non-convex space.

[0035] In one specific implementation scenario, in the process of optimizing the hyperparameters based on IGOA, the historical optimal solution of the individual position vector can be recorded in the iteration process of the individual position vector representing the combination of the hyperparameters, and the migration direction of the historical optimal solution can be dynamically adjusted based on the global fitness gradient. For example, each individual position vector can record its historical optimal solution in the iteration process, and the migration direction of the historical optimal solution can be dynamically adjusted according to the global fitness gradient. In the above manner, the historical optimal solution of the individual position vector is recorded in the iteration process, and the migration direction of the historical optimal solution is dynamically adjusted based on the global fitness gradient. The local memory strategy can be introduced based on the recorded historical optimal solution, which can help improve the convergence stability of the model and automatically activate the "annealing search" mode when the population diversity is too low to avoid falling into a global optimum.

[0036] It should be noted that the above examples are only a few possible examples of improvements to IGOA, and do not limit other improvements to IGOA. For example, in the case where the hyperparameter solution space involves model structure parameters and model training parameters, integrated optimization from "structure-training-regularization" can be implemented, so that the defect prediction model can automatically configure the optimal structure according to different data set characteristics, and as much as possible avoid redundant adjustment and repeated training cost in the migration scenario. For another example, a lightweight parallel processing structure can be implemented for IGOA, and the population evaluation and fitness update process can be processed in threads to significantly reduce the runtime while maintaining higher accuracy, which is helpful for large-scale code library or real-time defect scanning scenarios. Other possible improvement methods are not exemplified one by one.

[0037] In one specific implementation scenario, as mentioned above, the hyperparameter solution space can involve model structure parameters, and therefore, based on IGOA, a dynamic mechanism of model structure can be introduced at the structure level to adaptively configure model structure parameters such as the number of convolutional layers, the number of channels per layer, and the kernel size, so that the model can evolve into an optimal structure form according to the current input feature dimension and data complexity. For example, when processing small module datasets with low feature dimension but high semantic density, the model tends to have a shallow convolutional structure, while when processing medium or large system data with high code complexity and redundant dimension, the model automatically evolves into a deeper structure to enhance the feature extraction capability.

[0038] In one specific implementation scenario, the defect prediction model can adjust the learning rate decay strategy in real time based on the training error convergence trend, the weight gradient change amount, and the iterative feedback information of IGOA during the training process, so that the defect prediction model can maintain a dynamic balance between convergence speed and stability at different training stages. It should be noted that the iterative feedback information of IGOA can include but is not limited to the current solution of the hyperparameter combination, and the like, which are not limited herein.

[0039] In one specific implementation scenario, the defect prediction model can use a segmented dropout rate self-adjusting mechanism during the training process to avoid information flow interruption caused by excessive random dropout as much as possible, while also alleviating the risk of overfitting. It should be noted that dropout is a regularization technique in deep learning, which randomly discards neuron outputs with a certain probability during training to reduce the cooperative dependence between neurons and suppress overfitting. The segmented dropout rate self-adjusting mechanism divides the training process into multiple stages according to conditions such as sequence stage, model state, and data characteristics, and dynamically adjusts the dropout rate in each stage. For example, in the early training stage (e.g., the first 10% of training rounds), a high dropout rate (e.g., 0.8, etc.) can be used to enhance model robustness and prevent early overfitting; in the middle training stage (e.g., 10% to 80% of training rounds), a medium dropout rate (e.g., 0.5, etc.) can be used to balance generalization and convergence speed; in the late training stage (e.g., the last 20% of training rounds), a low dropout rate (e.g., 0.2) or no dropout can be used to accelerate model convergence to the optimal solution. Of course, the above is only one possible example of segmentation based on training rounds in actual application, and the like, which are not limited herein, such as segmentation based on loss function or accuracy, and the like, which will not be exemplified one by one.

[0040] In a specific implementation scenario, the defect detection model can also be embedded with a lightweight residual module and a channel attention mechanism, i.e., a simplified SE (Squeeze-and-Excitation) structure can be introduced, such as embedding a simplified SE structure on the basis of the original structure of AlexNet to dynamically re-label the importance of channels, thereby improving the selective expression of convolutional features, and thus greatly enhancing the model's ability to recognize "minority class" defect samples under unbalanced data distribution, and avoiding the "masking" of key defect information by dominant features as much as possible.

[0041] In a specific implementation scenario, the defect prediction model can dynamically adjust the L2 regularization strength based on sample distribution during training and combine information entropy to suppress the expansion trend of the weight factor. Specifically, first, sample distribution evaluation can be performed, such as evaluating the distribution characteristics (e.g., sample class imbalance degree, feature value dispersion degree, etc.) of the current training batch or global samples in the training iteration. Then, L2 regularization strength dynamic adjustment can be performed, such as dynamically increasing or decreasing the L2 regularization coefficient based on the evaluation results of the sample distribution (e.g., when it is detected that the model performs well on the training set but poorly on the validation set, the sample distribution is extremely imbalanced, etc., and the overfitting risk is high, the L2 regularization strength can be increased). Finally, entropy value feedback combination can be performed, such as introducing the relevant description of information entropy and weight factor from the foregoing, for the pre-set feature categories that are judged as "high uncertainty" or "redundant", the defect prediction model can be controlled to combine the weight factor during the training process, and use the entropy value feedback (such as through an additional loss term or penalty term) to suppress its influence on the decision of the defect prediction model, and avoid its weight expansion. The above-mentioned method not only improves the model's generalization ability, but also makes the training process more robust, and can still maintain stable performance when facing sample noise or defect labeling bias.

[0042] It should be noted that the above implementation examples are only the differences between the IGOA and the traditional IGOA when optimizing the defect prediction model based on the IGOA in the actual application process, and the rest of the same or similar places, please refer to the technical details of the IGOA, which will not be repeated here.

[0043] In one implementation scenario, as described above, the defect detection result can be predicted by the defect prediction model on the second feature set, and the defect prediction model can be trained based on the program code of the sample software (for details, please refer to the foregoing description), and the sample software can belong to the source project. Then, if the defect prediction model needs to predict defects of the target software (i.e., belonging to a different project domain than the sample software) of the target project before, the distribution similarity of the information entropy in the source project and the target project based on the same preset feature category can be used to determine whether to select the preset feature category as the target feature category of the target project, and then the defect prediction model can be fine-tuned based on the third feature set extracted from the program code of the sample software belonging to the target project to obtain a defect prediction model suitable for the target project. It should be noted that the third feature set can at least include the code feature representation of the sample software belonging to the target project with respect to each target feature category, and the source project can be different from the target project in at least one of software architecture, code language environment, and program code specification. The above method determines whether to select the preset feature category as the target feature category of the target project according to the distribution similarity of the information entropy of the preset feature category in the source project and the target project, and fine-tunes the defect prediction model based on the third feature set extracted from the program code of the sample software belonging to the target project to obtain a defect prediction model suitable for the target project, which can eliminate feature dimensions with high noise and low contribution, and thus can significantly improve the transferability in the case of inconsistent feature distribution and reduce the structural distortion caused by redundant features.

[0044] In one specific implementation scenario, the information entropy of each preset feature category in the source project can be calculated, and the information entropy of each preset feature category in the target project can be calculated. On this basis, the information entropy of the preset feature category in the above two projects can be compared. If the information entropy of the preset feature category in the source project is similar to that in the target project (e.g., the difference between them is close to 0), the preset feature category in the source project can be corresponding or aligned with the preset feature category in the target project (i.e., as the target feature category), to ensure that they are in consistent positions in the feature space after migration. Otherwise, if the information entropy of the preset feature category in the source project is not similar to that in the target project, it can be considered as noise elimination.

[0045] In one specific implementation scenario, during the pre-training phase of migration fine-tuning, the network layers of the defect prediction model (i.e., the defect prediction model trained based on the program code of the sample software belonging to the source project, i.e., the defect prediction model obtained based on the aforementioned IGOA) can be selectively inherited based on the data characteristics of the target project, so as to obtain a base model suitable for the target project, and then the base model is fine-tuned to obtain a defect prediction model suitable for the target project. It should be noted that selective inheritance can include at least one of the following: the convolutional layer and the attention layer remain unchanged, and the fully connected layer is reconstructed based on the label distribution of the target project. For example, the convolutional layer and the attention layer have strong universality for the underlying features, so they can be completely migrated, i.e., they can be completely preserved. Or, for example, the fully connected layer can be reconstructed and fine-tuned according to the specific label distribution of the target project to ensure that the discrimination ability of the output layer is consistent with the target task as much as possible (for example, the number of neurons of the original fully connected layer, especially the output layer, can be replaced according to the number of defect categories of the target project, so that the number of neurons is consistent with the number of labels of the target project), so as to balance the efficiency and adaptability of migration as much as possible, and avoid the instability problem of the model caused by "hard migration".

[0046] In a specific implementation scenario, after determining the base model applicable to the target project in the pre-training stage of transfer fine-tuning, a small amount of labeled data of the target project (e.g., program codes of sample software belonging to the target project and sample defect results labeled thereby) can be used to train the base model at a small learning rate, especially for the network layers of the base model that are different from the defect prediction model of the source project (i.e., the network layers that are transferred in the aforementioned pre-training stage of transfer fine-tuning), so that the weights thereof can be adapted to the specific label distribution of the target task when the defect classification needs to be output, thereby ensuring accurate classification output. In addition, in order to further improve the accuracy of the transfer or, the predicted labels output by the defect prediction model on the third feature set and the actual labels of the sample software belonging to the target project regarding software defects can be obtained at the beginning of the training of the transfer fine-tuning. It should be noted that when the output result of the defect prediction model needs to include the defect type, the predicted labels and the actual labels represent the defect type; or when the output result of the defect prediction model needs to include whether there is a software defect, the predicted labels and the actual labels represent whether there is a software defect (e.g., a number "1" can represent that there is a software defect, and a number "0" can represent that there is no software defect). On this basis, at least one of the fine-tuning weight and the fine-tuning range of the transfer fine-tuning of the defect prediction model can be determined based on the entropy consistency loss between the predicted labels and the actual labels. It should be noted that the fine-tuning weight can be used to control the fine-tuning intensity. For example, when the difference between the predicted labels and the actual labels is large, the fine-tuning weight can be appropriately increased and the fine-tuning range can be expanded; conversely, when the difference between the predicted labels and the actual labels is small, a freezing strategy can be used to maintain the stability of the model. In this way, the potential distribution deviation can be corrected at the beginning of the transfer fine-tuning, thereby improving the convergence efficiency and prediction robustness of the model.

[0047] In a specific implementation scenario, after obtaining the defect prediction model applicable to the target project, in order to evaluate the evaluability and scalability of the transfer mechanism, cross-project evaluation can also be performed. Specifically, cross-validation and transfer testing can be performed based on a plurality of typical software defect data sets (e.g., NASA, AEEEM, PROMISE, etc.). Experiments show that the defect prediction model obtained by the above method can still maintain high prediction performance under the premise that the source project has never seen the target project data.

[0048] The above scheme is based on the program code of the reference software to extract the first feature set of the reference software, and the first feature set contains code feature representations of the reference software about a plurality of preset feature categories, and based on the first feature set of the reference software, the information entropy of the plurality of preset feature categories in the reference software is measured, so as to determine the weight factor of the corresponding preset feature category based on the information entropy of the same preset feature category in different reference software, and then based on the second feature set extracted from the program code of the to-be-tested software, the defect detection result of the to-be-tested software is predicted, and the second feature set contains code feature representations and weight factors of the to-be-tested software about a plurality of preset feature categories, so the weight factor of the preset feature category can be determined as objectively as possible through the distribution characteristics of the information entropy of the preset feature category in different reference software, so that the code feature representations of different preset feature categories are selectively referred to in different degrees in the defect prediction process according to the weight factor, which helps to avoid introducing unstable noise as much as possible in the defect prediction process, improves the objectivity of feature selection, and since different reference software is referred to in the determination process of the weight factor instead of a single software, the weight factor determined thereby can have stronger adaptability to software data with different distributions. Therefore, the objectivity of feature selection can be improved to improve the accuracy and generalization ability of software defect prediction.

[0049] Please refer to Figure 2 , Figure 2 is a schematic diagram of an embodiment of the software defect prediction device. The software defect prediction device 20 comprises a feature extraction module 21, an entropy measurement module 22, a weight determination module 23 and a defect prediction module 24. The feature extraction module 21 is configured to extract a first feature set of the reference software based on the program code of the reference software. The first feature set contains code feature representations of the reference software about a plurality of preset feature categories. The entropy measurement module 22 is configured to measure the information entropy of the plurality of preset feature categories in the reference software based on the first feature set of the reference software. The weight determination module 23 is configured to determine the weight factor of the corresponding preset feature category based on the information entropy of the same preset feature category in different reference software. The defect prediction module 24 is configured to predict the defect detection result of the to-be-tested software based on the second feature set extracted from the program code of the to-be-tested software. The second feature set contains code feature representations and weight factors of the to-be-tested software about a plurality of preset feature categories.

[0050] The above scheme, the software defect prediction device 20 extracts the first feature set of the reference software based on the program code of the reference software, and the first feature set contains the code feature representation of the reference software about several preset feature categories, and measures the information entropy of the several preset feature categories in the reference software based on the first feature set of the reference software, so as to determine the weight factor of the corresponding preset feature category based on the information entropy of the same preset feature category in different reference software, and then predict the defect detection result of the to-be-tested software based on the second feature set extracted from the program code of the to-be-tested software, and the second feature set contains the code feature representation and its weight factor of the to-be-tested software about several preset feature categories, so the weight factor of the preset feature category can be determined as objectively as possible through the distribution characteristics of the information entropy of the preset feature category in different reference software, so that the code feature representation of different preset feature categories is selectively referenced in different degrees in the defect prediction process according to the weight factor, which helps to avoid introducing unstable noise in the defect prediction process as much as possible, improves the objectivity of feature selection, and because different reference software is referred to in the determination process of the weight factor instead of a single software, the weight factor determined thereby can have stronger adaptability to software data with different distributions. Therefore, the objectivity of feature selection can be improved to improve the accuracy and generalization ability of software defect prediction.

[0051] In some disclosed embodiments, the weight determination module 23 includes a dispersion metric module for measuring the entropy dispersion of the preset feature category based on the information entropy of the same preset feature category in different reference software; wherein the entropy dispersion of the preset feature category represents the uncertainty degree of the preset feature category about the information entropy in different reference software; the weight determination module 23 includes a weight determination submodule for determining the weight factor of the preset feature category based on the entropy dispersion of the preset feature category; wherein the weight factor is negatively correlated with the entropy dispersion.

[0052] In some disclosed embodiments, the defect detection result is obtained by predicting the second feature set by the defect prediction model, and the hyperparameters of the defect prediction model are optimized based on the improved goat optimization algorithm (IGOA).

[0053] In some disclosed embodiments, the software defect prediction device 20 includes a function mapping module for mapping the population fitness distribution based on the weight adaptive transfer function in the process of optimizing the hyperparameters based on IGOA to obtain the global search ratio and the local search ratio; wherein the global search ratio is used to constrain the breadth search in the entire search space, and the local search ratio is used to constrain the fine search around the current optimal solution.

[0054] In some disclosed embodiments, the software defect prediction apparatus 20 comprises a category selection module configured to select a preset feature category as a perturbation feature category based on an information entropy of each of the preset feature categories during the process of optimizing the hyperparameters based on the IGOA; wherein the information entropy of the perturbation feature category is higher than an entropy threshold; and the software defect prediction apparatus 20 comprises a modification triggering module configured to trigger a modification of an individual position vector representing a combination of the hyperparameters when the defect prediction model processes the code feature representation of the perturbation feature category.

[0055] In some disclosed embodiments, the software defect prediction apparatus 20 comprises a record adjustment module configured to record a historical optimal solution of the individual position vector during an iteration process of the individual position vector representing the combination of the hyperparameters, and dynamically adjust a migration direction of the historical optimal solution based on a global fitness gradient during the process of optimizing the hyperparameters based on the IGOA.

[0056] In some disclosed embodiments, the defect prediction model adjusts a learning rate decay strategy in real time based on a training error convergence trend, a weight gradient change amount, and an iteration feedback information of the IGOA during a training process; and / or, the defect prediction model adopts a segmented dropout rate self-adjusting mechanism during the training process; and / or, the defect prediction model dynamically adjusts an L2 regularization strength based on a sample distribution and combines an information entropy to suppress an expansion trend of a weight factor during the training process.

[0057] In some disclosed embodiments, the defect detection result is obtained by predicting the second feature set by the defect prediction model, the defect prediction model is trained based on program codes of sample software, the sample software belongs to a source project, the software defect prediction apparatus 20 comprises a selection and determination module configured to determine whether to select a preset feature category as a target feature category of a target project based on a distribution similarity of information entropy of the same preset feature category in the source project and the target project before defect prediction of target software belonging to the target project is performed based on the defect prediction model; and the software defect prediction apparatus 20 comprises a migration fine-tuning module configured to fine-tune the defect prediction model based on a third feature set extracted from program codes of sample software belonging to the target project to obtain a defect prediction model applicable to the target project; wherein the third feature set at least contains code feature representations of the sample software belonging to the target project with respect to each target feature category, and the source project and the target project are different in at least one of software architecture, code language environment, and program code specification.

[0058] In some disclosed embodiments, the software defect prediction apparatus 20 comprises a selection and inheritance module configured to selectively inherit network layers of the defect prediction model based on data characteristics of the target project during a pre-training stage of the migration fine-tuning; wherein the selective inheritance comprises at least one of the following: a convolution layer and an attention layer remain unchanged, and a full connection layer is reconstructed based on a label distribution of the target project.

[0059] In some disclosed embodiments, the software defect prediction apparatus 20 comprises a label obtaining module configured to obtain, at the beginning of the transfer fine-tuning, the predicted labels output by the defect prediction model on the third feature set, and obtain the actual labels of the sample software belonging to the target project on software defects; the software defect prediction apparatus 20 comprises a model fine-tuning module configured to determine at least one of the fine-tuning weight and the fine-tuning range for the transfer fine-tuning of the defect prediction model based on the entropy consistency loss between the predicted labels and the actual labels.

[0060] In some disclosed embodiments, the defect detection result at least comprises whether the to-be-tested software has defects; and / or, the defect detection result is obtained by the defect prediction model predicting the second feature set, and the defect prediction model comprises a language-independent code representation layer, which is configured to abstract the static metric features and the code nesting structure into a semantic graph, and then fuse the semantic graph and the code feature representation for the code representation layer and the subsequent network layer of the defect prediction model to continue processing.

[0061] Please refer to Figure 3 , Figure 3 is a frame schematic diagram of an embodiment of the electronic device. The electronic device 30 at least comprises a memory 31 and a processor 32 coupled with each other, the memory 31 at least stores program instructions, and the processor 32 is configured to execute the program instructions to implement the steps in any of the above software defect prediction method embodiments. For details, please refer to the foregoing disclosed embodiments, which will not be repeated here. As a possible example, the electronic device 30 can include but is not limited to a mobile phone, a tablet computer, a learning machine, a smart large screen, a server, etc. The specific type of the electronic device 30 is not limited here.

[0062] Specifically, the processor 32 is configured to control itself and the memory 31 to implement the steps in any of the above software defect prediction method embodiments. The processor 32 can also be referred to as a CPU (Central Processing Unit). The processor 32 can be an integrated circuit chip with processing capability. The processor 32 can also be a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. In addition, the processor 32 can be implemented by an integrated circuit chip together.

[0063] The above scheme, the electronic device 30 extracts the first feature set of the reference software based on the program code of the reference software, and the first feature set contains the code feature representation of the reference software about several preset feature categories, and measures the information entropy of the several preset feature categories in the reference software based on the first feature set of the reference software, thereby determining the weight factor of the corresponding preset feature category based on the information entropy of the same preset feature category in different reference software, and then predicting the defect detection result of the to-be-tested software based on the second feature set extracted from the program code of the to-be-tested software, and the second feature set contains the code feature representation of the to-be-tested software about several preset feature categories and its weight factor, so that the weight factor of the preset feature category can be determined as objectively as possible through the distribution characteristics of the information entropy of the preset feature category in different reference software, so that the code feature representation of different preset feature categories is selectively referenced in different degrees according to the weight factor in the defect prediction process, which helps to avoid introducing unstable noise as much as possible in the defect prediction process, improves the objectivity of feature selection, and because different reference software is referred to in the determination process of the weight factor instead of a single software, the weight factor determined thereby can have stronger adaptability to software data with different distributions. Therefore, the objectivity of feature selection can be improved to improve the accuracy and generalization ability of software defect prediction.

[0064] Please refer to Figure 4 , Figure 4 is a framework schematic diagram of an embodiment of the computer readable storage medium of the present application. The computer readable storage medium 40 stores program instructions 41 capable of being run by the processor, and the program instructions 41 are used to implement the steps in any of the software defect prediction method embodiments.

[0065] The above scheme, the computer readable storage medium 40 extracts the first feature set of the reference software based on the program code of the reference software, and the first feature set contains the code feature representation of the reference software about several preset feature categories, and based on the first feature set of the reference software, the information entropy of the several preset feature categories in the reference software is measured, so as to determine the weight factor of the corresponding preset feature category based on the information entropy of the same preset feature category in different reference software, and then the second feature set extracted from the program code of the to-be-tested software is used to predict the defect detection result of the to-be-tested software, and the second feature set contains the code feature representation of the to-be-tested software about several preset feature categories and the weight factor, so the weight factor of the preset feature category can be determined as objectively as possible through the distribution characteristics of the information entropy of the preset feature category in different reference software, so that the code feature representation of different preset feature categories is selectively referred to in different degrees in the defect prediction process according to the weight factor, which helps to avoid introducing unstable noise as much as possible in the defect prediction process, improves the objectivity of feature selection, and since different reference software is referred to in the determination process of the weight factor instead of a single software, the weight factor determined thereby can have stronger adaptability to software data with different distributions. Therefore, the objectivity of feature selection can be improved to improve the accuracy and generalization ability of software defect prediction.

[0066] In some embodiments, the apparatus provided by the embodiments of the present disclosure has functions or includes modules that can be used to perform the methods described in the above method embodiments, and the specific implementation can refer to the description of the above method embodiments. For brevity, details are not repeated here.

[0067] The above description of each embodiment tends to emphasize the differences between the embodiments, and the same or similar parts can be mutually referred to. For brevity, details are not repeated here.

[0068] In several embodiments provided in the present application, it should be understood that the disclosed methods and apparatuses can be implemented in other ways. For example, the above-described apparatus implementation is only schematic, for example, the division of modules or units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the shown or discussed mutual ones can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.

[0069] The units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, i.e., may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the present embodiment scheme.

[0070] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0071] If the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical scheme of the present application or the part that contributes to the prior art or the whole or part of the technical scheme can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the method of each embodiment of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.

[0072] If the technical scheme of the present application involves personal information, the product applying the technical scheme of the present application has been explicitly informed of the personal information processing rules before processing the personal information, and has obtained the personal independent consent. If the technical scheme of the present application involves sensitive personal information, the product applying the technical scheme of the present application has obtained the personal independent consent before processing the sensitive personal information, and at the same time meets the requirement of "explicit consent". For example, at the personal information collection device such as a camera, a clear and prominent sign is set to inform that the personal information collection range has been entered and the personal information will be collected. If the person voluntarily enters the collection range, it is considered to agree to collect the personal information. Or, on the device for processing personal information, through the pop-up information or by uploading the personal information by the person himself, the personal authorization is obtained under the condition that the obvious sign / information informs the personal information processing rules. The personal information processing rules can include personal information processor, personal information processing purpose, processing method, and personal information type, etc.

Claims

1. A software defect prediction method, characterized in that, include: Based on the program code of the reference software, a first feature set of the reference software is extracted; wherein, the first feature set contains the code feature representation of the reference software with respect to several preset feature categories; Based on the first feature set of the reference software, the information entropy of the several preset feature categories in the reference software is measured. Based on the information entropy of the same preset feature category in different reference software, the weight factor corresponding to the preset feature category is determined. Based on the second feature set extracted from the program code of the software under test, the defect detection result of the software under test is predicted; wherein, the second feature set includes the code feature representation of the software under test with respect to the several preset feature categories and their weight factors.

2. The method according to claim 1, characterized in that, The step of determining the weight factor corresponding to the preset feature category based on the information entropy of the same preset feature category in different reference software includes: Based on the information entropy of the same preset feature category in different reference software, the entropy dispersion of the corresponding preset feature category is measured; wherein, the entropy dispersion of the preset feature category characterizes the degree of uncertainty of the preset feature category with respect to the information entropy in different reference software; Based on the entropy dispersion of the preset feature category, a weight factor for the preset feature category is determined; wherein the weight factor is negatively correlated with the entropy dispersion.

3. The method according to claim 1, characterized in that, The defect detection result is obtained by the defect prediction model predicting the second feature set, and the hyperparameters of the defect prediction model are optimized based on the improved gazelle optimization algorithm (IGOA).

4. The method according to claim 3, characterized in that, In the process of optimizing the hyperparameters based on the IGOA, the method further includes: The population fitness distribution is mapped based on a weighted adaptive transfer function to obtain the global search ratio and the local search ratio; wherein, the global search ratio is used to constrain a breadth search across the entire search space, and the local search ratio is used to constrain a fine search around the current optimal solution.

5. The method according to claim 3, characterized in that, In the process of optimizing the hyperparameters based on the IGOA, the method further includes: Based on the information entropy of each of the several preset feature categories, a preset feature category is selected as the perturbation feature category; wherein, the information entropy of the perturbation feature category is higher than the entropy threshold. When the defect prediction model processes the code feature representation of the perturbation feature category, it triggers a modification of the individual position vector representing the hyperparameter combination.

6. The method according to claim 3, characterized in that, In the process of optimizing the hyperparameters based on the IGOA, the method further includes: During the iteration of the individual position vector representing the hyperparameter combination, the historical optimal solution of the individual position vector is recorded, and the migration direction of the historical optimal solution is dynamically adjusted based on the global fitness gradient.

7. The method according to claim 3, characterized in that, The defect prediction model adjusts the learning rate decay strategy in real time during training based on the training error convergence trend, weight gradient change, and iterative feedback information of the IGOA. And / or, the defect prediction model employs a segmented dropout rate self-adjustment mechanism during training; And / or, the defect prediction model dynamically adjusts the L2 regularization strength based on the sample distribution during training and combines the information entropy to suppress the expansion trend of the weight factors.

8. The method according to claim 1, characterized in that, The defect detection result is obtained by a defect prediction model predicting the second feature set. The defect prediction model is trained based on the program code of the sample software, which belongs to the source project. Before performing defect prediction on the target software belonging to the target project based on the defect prediction model, the method further includes: Based on the similarity of the distribution of information entropy between the source item and the target item with the same preset feature category, determine whether to select the preset feature category as the target feature category of the target item; The defect prediction model is fine-tuned based on the third feature set extracted from the program code of the sample software belonging to the target project to obtain a defect prediction model applicable to the target project; wherein the third feature set contains at least the code feature representations of the sample software belonging to the target project for each of the target feature categories, and the source project and the target project differ in at least one of the following: software architecture, code language environment, and program code specifications.

9. The method according to claim 8, characterized in that, In the pre-training phase of the transfer fine-tuning, the method further includes: Based on the data characteristics of the target project, the network layers of the defect prediction model are selectively inherited; wherein, the selective inheritance includes at least one of the following: the convolutional layer and the attention layer remain unchanged, and the fully connected layer is reconstructed based on the label distribution of the target project.

10. The method according to claim 8, characterized in that, In the initial training phase of the transfer fine-tuning, the method further includes: Obtain the predicted labels output by the defect prediction model for the third feature set, and obtain the actual labels of the sample software belonging to the target project regarding software defects; Based on the entropy consistency loss between the predicted label and the actual label, at least one of the fine-tuning weight and fine-tuning range is determined for the migration fine-tuning of the defect prediction model.

11. The method according to any one of claims 1 to 10, characterized in that, The defect detection results include at least whether the software under test has defects; And / or, the defect detection result is obtained by the defect prediction model predicting the second feature set. The defect prediction model includes a language-independent code representation layer. The code representation layer is used to: abstract static metric features and code nesting structures into a semantic graph, and then fuse the semantic graph with the code feature representation for further processing by the network layer after the code representation layer in the defect prediction model.

12. A software defect prediction device, characterized in that, include: The feature extraction module is used to extract a first feature set of the reference software based on the program code of the reference software; wherein the first feature set contains code feature representations of the reference software with respect to several preset feature categories; The entropy measurement module is used to measure the information entropy of the several preset feature categories in the reference software based on the first feature set of the reference software. The weight determination module is used to determine the weight factor corresponding to the preset feature category based on the information entropy of the same preset feature category in different reference software. The defect prediction module is used to predict the defect detection result of the software under test based on a second feature set extracted from the program code of the software under test; wherein the second feature set includes the code feature representation of the software under test with respect to the several preset feature categories and their weight factors.

13. An electronic device, characterized in that, It includes at least a memory and a processor, wherein the memory stores at least program instructions, and the processor is used to execute the program instructions to implement the software defect prediction method according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that, The system stores program instructions that can be executed by a processor, the program instructions being used to implement the software defect prediction method according to any one of claims 1 to 11.