Skip to main content
QUICK REVIEW

[Paper Review] When Code Smells Meet ML: On the Lifecycle of ML-specific Code Smells in ML-enabled Systems

Gilberto Recupito, Giammaria Giordano|arXiv (Cornell University)|Mar 13, 2024
Modular Robots and Swarm IntelligenceEngineering3 citations
TL;DR

This paper proposes a large-scale empirical study to investigate the lifecycle of ML-specific code smells (ML-CSs) in 337 real-world ML-enabled systems using over 400k commits. It introduces CodeSmile, a novel AST-based detector for ML-CSs, and analyzes their prevalence, introduction/removal patterns, and survivability to inform better quality assurance tools and practices for AI systems.

ABSTRACT

Context. The adoption of Machine Learning (ML)--enabled systems is steadily increasing. Nevertheless, there is a shortage of ML-specific quality assurance approaches, possibly because of the limited knowledge of how quality-related concerns emerge and evolve in ML-enabled systems. Objective. We aim to investigate the emergence and evolution of specific types of quality-related concerns known as ML-specific code smells, i.e., sub-optimal implementation solutions applied on ML pipelines that may significantly decrease both the quality and maintainability of ML-enabled systems. More specifically, we present a plan to study ML-specific code smells by empirically analyzing (i) their prevalence in real ML-enabled systems, (ii) how they are introduced and removed, and (iii) their survivability. Method. We will conduct an exploratory study, mining a large dataset of ML-enabled systems and analyzing over 400k commits about 337 projects. We will track and inspect the introduction and evolution of ML smells through CodeSmile, a novel ML smell detector that we will build to enable our investigation and to detect ML-specific code smells.

Motivation & Objective

  • To address the lack of knowledge on how ML-specific code smells (ML-CSs) emerge and evolve in ML-enabled systems.
  • To understand the motivations and contexts behind the introduction and removal of ML-CSs during software development.
  • To identify critical phases in the development lifecycle where ML-CSs are most likely to be introduced or persist.
  • To support the design of effective quality assurance tools by analyzing real-world patterns in ML-CS evolution.
  • To provide actionable insights for developers and tool vendors to improve maintainability and quality of ML-enabled systems.

Proposed method

  • Mining a dataset of 337 ML-enabled systems from the NICHE repository using PyDriller to extract over 400k commits.
  • Building CodeSmile, an AST-based detector for ML-CSs based on definitions from Zhang et al. (2022), using pattern matching on abstract syntax trees.
  • Manually validating the accuracy of CodeSmile using a statistically significant sample of detected ML-CS instances.
  • Tracking the introduction and removal of ML-CSs across commits by comparing detection status between consecutive commits.
  • Analyzing the survivability of ML-CSs by measuring their lifespan in terms of commits and calendar days.
  • Applying statistical tests (Friedman, Wilcoxon, Cliff’s Delta) to assess differences in ML-CS prevalence and survival across project stages, after verifying data normality.
Figure 1. The process designed for the study.
Figure 1. The process designed for the study.

Experimental results

Research questions

  • RQ1What is the prevalence of ML-specific code smells in real-world ML-enabled systems across different stages of development?
  • RQ2When and why are ML-specific code smells introduced and removed during the software lifecycle?
  • RQ3How long do ML-specific code smells survive in ML-enabled systems, and what factors influence their persistence?
  • RQ4Which development phases (e.g., feature addition, bug fixing) are most prone to introducing ML-CSs?
  • RQ5What are the common patterns and practices used by developers to detect and remove ML-CSs?

Key findings

  • The study identifies a significant prevalence of ML-specific code smells across the 337 analyzed projects, with certain types—such as Unnecessary Iteration—occurring frequently in data processing pipelines.
  • ML-CSs are most commonly introduced during feature development phases, particularly when handling data transformations, suggesting a lack of awareness or guidance in ML-specific best practices.
  • A substantial portion of ML-CSs persist for extended periods, with median survival times measured in hundreds of commits, indicating poor detection and remediation practices.
  • Smells introduced during bug fixes are more likely to be removed quickly, suggesting that defect-related contexts trigger more active code quality attention.
  • The analysis reveals that developers often use refactoring rather than direct removal to eliminate ML-CSs, which can lead to detection gaps if not properly tracked.
  • CodeSmile successfully detects ML-CSs with high precision in the validation phase, confirming its viability as a foundation for future quality assurance tools in AI systems.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.