Skip to main content
QUICK REVIEW

[论文解读] Estimating defectiveness of source code: A predictive model using GitHub content

Ritu Kapur, Balwinder Sodhi|arXiv (Cornell University)|Mar 21, 2018
Software Engineering ResearchComputer Science参考文献 16被引用 4
一句话总结

本文提出了一种基于从GitHub仓库中提取的编程风格特征来预测源代码缺陷性的模型。通过挖掘20个开源项目(涵盖C、C++、Java和Python)中的30,400个源文件,并整合14,950份错误报告,作者训练了一个机器学习模型,采用NuSVM方法实现了0.914的平均F1分数,表明基于编码风格模式的缺陷预测具有优异性能。

ABSTRACT

Two key contributions presented in this paper are: i) A method for building a dataset containing source code features extracted from source files taken from Open Source Software (OSS) and associated bug reports, ii) A predictive model for estimating defectiveness of a given source code. These artifacts can be useful for building tools and techniques pertaining to several automated software engineering areas such as bug localization, code review, and recommendation and program repair. In order to achieve our goal, we first extract coding style information (e.g. related to programming language constructs used in the source code) for source code files present on GitHub. Then the information available in bug reports (if any) associated with these source code files are extracted. Thus fetched un(/ semi)-structured information is then transformed into a structured knowledge base. We considered more than 30400 source code files from 20 different GitHub repositories with about 14950 associated bug reports across 4 bug tracking portals. The source code files considered are written in four programming languages (viz., C, C++, Java, and Python) and belong to different types of applications. A machine learning (ML) model for estimating the defectiveness of a given input source code is then trained using the knowledge base. In order to pick the best ML model, we evaluated 8 different ML algorithms such as Random Forest, K Nearest Neighbour and SVM with around 50 parameter configurations to compare their performance on our tasks. One of our findings shows that best K-fold (with k=5) cross-validation results are obtained with the NuSVM technique that gives a mean F1 score of 0.914.

研究动机与目标

  • 开发一种基于编程风格特征预测源代码缺陷性的模型。
  • 从非结构化的GitHub源代码及其关联的错误报告中构建结构化知识库。
  • 探究编程风格与软件缺陷性之间的相关性。
  • 在大规模、多语言数据集上评估多种机器学习算法在缺陷预测中的表现。
  • 支持自动化软件工程任务,如错误定位、代码审查和程序修复。

提出的方法

  • 从20个GitHub仓库中的源文件中提取编程风格特征(例如,代码构造计数、标识符长度、嵌套深度)。
  • 从4个错误跟踪门户(Apache、Eclipse等)收集并解析错误报告,将缺陷元数据与源文件关联。
  • 将非结构化的代码和错误报告数据转换为结构化的关联知识库,以减少偏差并提升模型训练效果。
  • 在数据集上训练8种机器学习模型(包括随机森林、SVM、KNN),每种模型配置50组超参数。
  • 使用5折交叉验证评估模型性能,重点关注F1分数作为主要指标。
  • 基于多种评估场景下的平均F1分数,选择表现最佳的模型(NuSVM)。

实验结果

研究问题

  • RQ1特定的编程风格特征与源代码缺陷可能性之间是否存在显著相关性?
  • RQ2基于GitHub源代码和错误报告训练的机器学习模型能否准确预测某个源文件是否具有缺陷?
  • RQ3在多种编程语言和项目类型中,哪种机器学习算法在缺陷预测任务中表现最佳?
  • RQ4不同的特征表示方式(例如,代码构造频率、标识符长度)对缺陷预测准确率有何贡献?
  • RQ5该模型能否有效区分高优先级缺陷文件与低优先级或未指定优先级的缺陷文件?

主要发现

  • NuSVM模型在5折交叉验证中实现了0.914的最高平均F1分数,优于其他模型。
  • 该模型基于来自20个开源仓库、涵盖4种编程语言(C、C++、Java、Python)的30,400个源文件的大规模数据集进行训练。
  • 该数据集包含来自4个主要错误跟踪门户(Apache、Eclipse等)的14,950份相关错误报告。
  • 使用径向基核的SVM在将文件分类为潜在缺陷或非缺陷时,平均F1得分为0.807。
  • 使用7个估计器的随机森林模型在预测高优先级缺陷时,F1得分为0.694。
  • 本研究表明,代码构造频率、标识符长度和嵌套深度等编程风格特征是缺陷性的强预测因子。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。