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家公司来评估我们的方法。机器学习模型在公司本地训练,随后所有模型更新的权重被传输至服务器。最终,经过10家公司100轮训练后所得到的全局模型准确率达到98.34%。结果显示,全局模型准确率与集中式模型的最高准确率之间仅存在微小差异,这一微小差异可忽略不计,因为全局模型具备更全面的知识、更低的训练成本、对数据隐私的保护,并能避免技术债务问题。