随着移动应用的快速发展,代码异味问题日益凸显,严重影响了软件的质量和性能。本文提出了一种基于机器学习的缓慢循环异味检测方法,旨在提高Android应用中代码异味的检测效率和准确性。研究首先构建了一个包含7000个样本的数据集,然后采用决策树(C4.5)、朴素贝叶斯(NB)、逻辑回归(LR)、随机森林(RF)和基于规则的归纳算法(JRip)五种机器学习算法进行缓慢循环异味的检测。实验结果表明,随机森林算法在查准率、查全率和F1值上均表现优异,其次是JRip算法。本研究的方法和结果为Android应用开发中代码异味的自动检测提供了有效的技术支持。With the rapid development of mobile applications, the issue of code smells has become increasingly prominent, severely affecting the quality and performance of software. This paper proposes a machine learning-based method for detecting slow loop smells, aiming to improve the efficiency and accuracy of detecting code smells in Android applications. The study first constructed a dataset containing 7000 samples, and then used five machine learning algorithms, including Decision Tree (C4.5), Naive Bayes (NB), Logistic Regression (LR), Random Forest (RF), and Rule-based Inductive Algorithm (JRip), to detect slow loop smells. The experimental results show that the Random Forest algorithm performed excellently in terms of precision, recall, and F1 score, followed by the JRip algorithm. The methods and results of this study provide effective technical support for the automatic detection of code smells in the development of Android applications.