# A Novel Approach for Software Defect prediction Based on the Power Law Function
## 3 Experimental  
### Case Study  
To conduct a case study, we selected the public Camel1.6 dataset. The Camel1.6 dataset has 965 instances, of which 188 were defective and 777 were defect-free [43]. Defective instances accounted for 19.48% of the total instances. Each instance had 20 metric parameters and the label of each instance was removed in advance. Followingly, the power law function was established for each metric and correlation coefficients were calculated.  
The power law function, correlation coefficient, and transformation value in the maximal curvature point are shown in Table 1.  
Boldface indicates that the correlation coefficients were smaller than 0.3, which didn't exhibit the characteristics of power law function.  
Most of the metric parameters can be described well with power law functions. The correlation coefficients were mostly larger than 0.7, indicating that the power law function effectively described the metrics parameters distribution. Although two metrics were not well described by the power law functions, the ratio was relatively small. Figure 5 shows comparisons between the actual metrics data scatter and corresponding power law functions. Good consistencies were obtained for different metrics.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Metrics** & **Power Law Function** & **Correlation Coefficient** & **Transformation Value** \\ \hline wmc & 1013.8x\({}^{-0.892}\) & 0.8466 & 41.31 \\ dit & 34.841x\({}^{-0.516}\) & 0.7909 & 13.51 \\ noc & 110.68x\({}^{-1.012}\) & 0.9479 & 10.30 \\ doo & 915.03x\({}^{-0.83}\) & 0.854 & 45.82 \\ rfc & 4273x\({}^{-0.996}\) & 0.7247 & 66.07 \\ lcom & 3473x\({}^{-1.816}\) & 0.8994 & 58.94 \\ ca & 834.42x\({}^{-1.015}\) & 0.9684 & 27.93 \\ ce & 554.53x\({}^{-0.821}\) & 0.7765 & 35.63 \\ npm & 994.19x\({}^{-0.894}\) & 0.8752 & 36.86 \\ lcom3 & 19.53x\({}^{-0.518}\) & 0.5518 & 9.19 \\ loc & 12950x\({}^{-1.355}\) & 0.6554 & 120.88 \\ dam & 1.3429x\({}^{-0.083}\) & **0.0434** & **1.56** \\ moa & 23.007x\({}^{-0.504}\) & 0.8905 & 9.44 \\ mfa & 2.327x\({}^{-0.219}\) & **0.2977** & **2.73** \\ cam & 6.9114x\({}^{-0.473}\) & 0.6928 & 4.91 \\ ic & 3.5344x\({}^{-0.201}\) & 0.7184 & 3.80 \\ chm & 68.343x\({}^{-0.257}\) & 0.9308 & 12.73 \\ amc & 463.68x\({}^{-0.671}\) & 0.8869 & 47.49 \\ max\_cc & 108.78x\({}^{-0.713}\) & 0.9187 & 18.20 \\ avg\_cc & 11.099x\({}^{-0.401}\) & 0.8648 & 7.21 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Power law function, correlation coefficient, and transformation value in the maximal curvature point. The metrics and their descriptions can be seen in Appendix A.  
Figure 5: Power law functions with respect to different metrics. (**a**) wmc: weighted methods per class; (**b**) noc: number of children of a given class in an inheritance tree; (**c**) cbo: number of classes that are coupled to a given class; (**d**) lcom: number of method pairs in a class that do not share access to any class attributes; (**e**) ca: afferent coupling, which measures the number of classes that depend on a given class; (**f**) npm: number of public methods in a given class.  
Based on the calculated transformation values in each power law function's maximal curvature point, each entity with a value larger than the transformation value was identified as defective and set as 1 and others were identified as defect-free and set as 0. Following this, the total number of defective entities in each instance was calculated and listed. Finally, instances were labeled by clustering into two groups, a top half and a bottom half. Therefore, the instances in the top half of the clusters were labeled as defective and the others were labeled as defect-free. The number of defects predicted by the proposed approach was 94 and the number of actual defects was 188. Therefore, the precision of the proposed approach with respect to the Camel1.6 dataset was 0.276.