信息网络安全 ›› 2026, Vol. 26 ›› Issue (7): 1012-1027.doi: 10.3969/j.issn.1671-1122.2026.07.002

• AI安全防御 • 上一篇    下一篇

基于多视角剪枝与优化随机森林的软件缺陷预测方法

张大伟1,2, 周扬1(), 杜晔1,2, 唐宇1   

  1. 1北京交通大学网络空间安全学院北京100044
    2北京交通大学唐山研究院唐山 063000
  • 收稿日期:2026-01-26 出版日期:2026-07-10 发布日期:2026-09-03
  • 通讯作者: 周扬 E-mail:2521664181@qq.com
  • 作者简介:张大伟(1974—),男,辽宁,副教授,博士,主要研究方向为应用密码学|周扬(2001—),女,辽宁,硕士研究生,主要研究方向为软件缺陷预测|杜晔(1978—),男,黑龙江,教授,博士,主要研究方向为云安全、空天地一体化网络安全、网络攻防与漏洞检测|唐宇(1998—),男,河北,博士研究生,主要研究方向为群智能优化算法、软件缺陷预测
  • 基金资助:
    北京市自然科学基金(L254063);中央引导地方科技发展资金(246Z0705G);中央高校基本科研业务费(2024JBZX018)

Software defect prediction method based on multi-view pruning and optimized random forest

Zhang Dawei1,2, Zhou Yang1(), Du Ye1,2, Tang Yu1   

  1. 1School of Cyberspace Science and Technology, Beijing Jiaotong University, Beijing100044, China
    2Tangshan Research Institute of Beijing Jiaotong University, Tangshan 063000, China
  • Received:2026-01-26 Online:2026-07-10 Published:2026-09-03
  • Contact: Zhou Yang E-mail:2521664181@qq.com

摘要:

针对传统随机森林应用于软件缺陷预测领域存在结构冗余度高、可解释性差以及参数优化与结构剪枝相割裂导致预测性能受限的问题,文章提出一种融合多视角结构冗余剪枝(MSRP)机制与改进麻雀搜索算法(SCSSA)的随机森林优化模型(POMRF)。首先,构建多视角冗余评估体系,通过特征使用向量与加权结构向量融合语义相似度和结构距离,精准识别并剔除冗余决策树;然后,对麻雀搜索算法进行改进,引入正弦协同更新机制与混合变异策略优化随机森林核心参数,进而提升算法全局寻优能力与鲁棒性;最后,将POMRF模型应用于软件缺陷预测任务,在6个公开软件缺陷数据集上与多种对比算法开展实验验证。实验结果表明,POMRF模型在多种评价指标上均优于其他对比算法,不仅有效解决了传统方法单视角冗余评估不精准的问题,提升了模型可解释性与结构紧凑性,还通过参数优化与剪枝的协同联动突破了两者割裂的局限,显著提升了预测精度与稳定性,为软件缺陷预测领域提供了兼顾精度与可解释性的高效可靠解决方案。

关键词: 随机森林, 结构剪枝, 多视角冗余, 可解释性增强

Abstract:

Aiming at the problems that traditional random forests applied in the field of software defect prediction suffer from high structural redundancy, poor interpretability, and limited prediction performance caused by the separation of parameter optimization and structural pruning, this paper proposed an optimized random forest model (POMRF) integrating a multi-view structural redundancy pruning mechanism (MSRP) and an improved sparrow search algorithm (SCSSA). Firstly, a multi-view redundancy evaluation system was constructed, which fused semantic similarity and structural distance through feature usage vectors and weighted structural vectors to accurately identify and eliminate redundant decision trees; Secondly, the Sparrow Search Algorithm was improved by introducing a sine cooperative update mechanism and a hybrid mutation strategy to optimize the core parameters of the random forest, thereby enhancing the global optimization capability and robustness of the algorithm; Finally, the POMRF model was applied to software defect prediction tasks, and experimental verification was carried out on 6 public software defect datasets in comparison with various state-of-the-art algorithms. The experimental results show that the POMRF model outperforms other comparison algorithms in multiple evaluation metrics. It not only effectively solves the problem of inaccurate single-view redundancy evaluation of traditional methods, improves the interpretability and structural compactness of the model, but also breaks through the limitation of the separation between parameter optimization and pruning through their collaborative linkage, significantly enhancing the prediction accuracy and stability. This model provide an efficient and reliable solution that balanced accuracy and interpretability for the field of software defect prediction.

Key words: random forest, structural pruning, multi-view redundancy, interpretability enhancement

中图分类号: