This paper proposes a Federated Learning Code Smell Detection (FedCSD) approach that allows organizations to collaboratively train federated ML models while preserving their data privacy. These assertions have been supported by three experiments that have significantly leveraged three manually validated datasets aimed at detecting and examining different code smell scenarios. In experiment 1, which was concerned with a centralized training experiment, dataset two achieved the lowest accuracy (92.30%) with fewer smells, while datasets one and three achieved the highest accuracy with a slight difference (98.90% and 99.5%, respectively). This was followed by experiment 2, which was concerned with cross-evaluation, where each ML model was trained using one dataset, which was then evaluated over the other two datasets. Results from this experiment show a significant drop in the model's accuracy (lowest accuracy: 63.80\%) where fewer smells exist in the training dataset, which has a noticeable reflection (technical debt) on the model's performance. Finally, the last and third experiments evaluate our approach by splitting the dataset into 10 companies. The ML model was trained on the company's site, then all model-updated weights were transferred to the server. Ultimately, an accuracy of 98.34% was achieved by the global model that has been trained using 10 companies for 100 training rounds. The results reveal a slight difference in the global model's accuracy compared to the highest accuracy of the centralized model, which can be ignored in favour of the global model's comprehensive knowledge, lower training cost, preservation of data privacy, and avoidance of the technical debt problem.
翻译:本文提出了一种联邦学习代码异味检测(FedCSD)方法,该方法允许组织在保护数据隐私的同时协同训练联邦机器学习模型。这些论断得到了三项实验的支持,这些实验显著利用了三个经人工验证的数据集,旨在检测和检验不同的代码异味场景。实验一为集中式训练实验,其中数据集二在异味较少的情况下取得了最低准确率(92.30%),而数据集一和数据集三取得了最高准确率,两者差异微小(分别为98.90%和99.5%)。随后是实验二,涉及交叉评估,其中每个机器学习模型使用一个数据集进行训练,然后在另外两个数据集上进行评估。该实验结果显示,当训练数据集中存在较少异味时,模型准确率显著下降(最低准确率:63.80%),这对模型性能产生了明显的反映(技术债务)。最后,第三个实验通过将数据集划分为10家公司来评估我们的方法。机器学习模型在公司站点上训练,然后将所有模型更新的权重传输至服务器。最终,经过100轮训练,由10家公司训练出的全局模型取得了98.34%的准确率。结果显示,全局模型的准确率与集中式模型的最高准确率之间差异微小,可以忽略不计,而这得益于全局模型的全面知识、更低的训练成本、数据隐私保护以及避免了技术债务问题。