MLScent: A tool for Anti-pattern detection in ML projects

Karthik Shivashankar, Antonio Martini · 2025

Read MLScent: A tool for Anti-pattern detection in ML projects by Karthik Shivashankar, Antonio Martini (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2502-18466.txt.

Introduction

Karthik Shivashankar and Antonio Martini build a sniffing tool for the code smells that are born of machine learning work. Stock sniffing tools miss ML-only flaws that hurt quality, repeat runs, and upkeep. Their 2025 tool, MLScent, reads code trees for 76 tells. Tells span four big frameworks, two data libraries, and wide ML craft, plus preparation and training flows.

Counts run 13, 12, 9, and 10 by framework, with 16 wide tells in the set. Grades come in two kinds: counts on real projects, and talks with ML practitioners. Both back a high hit grade on framework tells, data flaws, and wide smells. The tool aims at shops whose ML code grows past hand watch.

Catalog record

CREATORKarthik Shivashankar, Antonio Martini
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE54 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2502-18466

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

MLScent: A tool for Anti-pattern detection in ML projects Karthik Shivashankar, Antonio Martini Abstract Machine learning (ML) codebases face unprecedented challenges in maintaining code quality and sustainability as their complexity grows exponentially. While traditional code smell detection tools exist, they fail to address ML-specific issues that can significantly impact model performance, reproducibility, and maintainability. This paper introduces MLScent, a novel static analysis tool that leverages sophisticated Abstract Syntax Tree (AST) analysis to detect anti-patterns and code smells specific to ML projects. MLScent implements 76 distinct detectors across major ML frameworks including TensorFlow (13 detectors), PyTorch (12 detectors), Scikit-learn (9 detectors), and Hugging Face (10 detectors), along with data science libraries like Pandas and NumPy (8 detectors each). The tool’s architecture also integrates general ML smell detection (16 detectors), and specialized analysis for data preprocessing and model training workflows. Our evaluation demonstrates MLScent’s effectiveness through both quantitative classification metrics and qualitative assessment via user studies feedback with ML practitioners. Results show high accuracy in identifying framework-specific anti-patterns, data handling issues, and general ML code smells across real-world projects. I Introduction The software development landscape has undergone a dramatic transformation with the integration of Machine Learning (ML). Recent statistics from Gartner highlight this shift, revealing a striking 270% increase in ML adoption within enterprise software projects over the last four years [ 1 ] . This growth spans multiple sectors, with healthcare leading the charge [ 2 ] . This rapid adoption, however, brings its own set of complexities. Traditional software development practices have had to evolve significantly to accommodate ML’s unique requirements, including the need for extensive datasets, sophisticated algorithms, and iterative development cycles [ 3 ] . These fundamental differences have catalyzed a complete reimagining of software development methodologies, from initial design through testing and maintenance [ 4 , 5 ] which is also highlighted by Tang et al. [ 6 ] in their empirical study of ML systems refactoring and technical debt. ML projects introduce distinct code quality challenges that set them apart from conventional software development. The complexity stems from their inherent characteristics: intricate mathematical operations, extensive data preprocessing requirements, and sophisticated model architectures that challenge traditional code maintenance approaches [ 7 ] . The iterative nature of ML development, where models undergo continuous refinement based on performance metrics, often results in code that becomes increasingly difficult to maintain and understand. The consequences of subpar code quality in ML projects can be particularly severe. Beyond the usual software maintenance issues, poor code quality can compromise model performance, hinder result reproducibility, and create significant obstacles during production deployment [ 8 ] . O’Brien et al. [ 9 ] further elaborate on these challenges through their comprehensive study of self-admitted technical debt in ML software, identifying 23 distinct patterns of technical debt specific to ML systems. These challenges can severely impact team collaboration and make model updates problematic as new data becomes available [ 10 ] . ML code smells represent unique indicators of potential system design or implementation issues that traditional metrics might miss [ 11 ] . Zhang et al. [ 12 ] have extensively documented these ML-specific smells, which often manifest in ways distinct from conventional software development – such as the inappropriate use of default hyperparameters or improper data splitting techniques for training and testing. The spectrum of ML-specific code smells extends to various critical areas, as documented by Oort et al. [ 13 ] in their study of code smell prevalence in ML projects. These include inadequate handling of data imbalances, lack of proper feature scaling, and the selection of inappropriate evaluation metrics [ 14 ] . Sculley et al. [ 7 ] further emphasize how these issues can lead to hidden technical debt in ML systems. While traditional code analysis tools excel in general software development, they often prove inadequate for ML codebases due to their lack of domain-specific understanding [ 15 ] . This limitation is particularly evident in the context of ML-specific issues, as demonstrated by Cruz et al. [ 16 ] in their empirical study of bad smell detection techniques. For instance, these tools might overlook critical ML-specific issues, such as the inappropriate use of classification accuracy metrics on imbalanced datasets [ 5 ] . This limitation in existing tools underscores the pressing need for ML-specific code quality analysis solutions. Tsoukalas et al. [ 17 ] emphasize the importance of specialized tools that must comprehend ML-specific constructs, workflows, and best practices [ 18 , 19 ] . Alahdab and Çalıklı [ 20 ] further support this through their empirical analysis of hidden technical debt patterns in ML software. MLScent is tailored for ML development, designed to detect and address ML-specific code smells and anti-patterns. Unlike general-purpose code quality tools, MLScent provides context-aware suggestions and detection of ML specific smells and anti-patterns may cater to ML workflows, helping practitioners improve code quality, maintainability, and development efficiency. II Background and Related Work Code smells, initially conceptualized by Kent Beck and popularized by Martin Fowler [ 21 ] , have evolved beyond traditional software development concerns to encompass machine learning-specific challenges. While traditional code smells focus on issues like duplicated code, oversized classes, and inappropriate coupling [ 22 , 23 ] , ML systems present unique quality challenges that existing detection tools like SonarQube [ 24 ] and PMD [ 25 ] fail to adequately address [ 26 , 13 ] . These traditional tools, while effective for conventional software development [ 27 ] , lack the capability to comprehend ML-specific contexts and the nuances of ML frameworks and libraries. ML-specific code smells, as documented by Sculley et al. [ 28 , 29 ] , include data leakage issues, improper feature scaling, and inadequate cross-validation practices. These issues, identified through empirical studies by Tang et al. [ 6 ] and O’Brien et al. [ 9 ] , can significantly impact model performance and reliability. Additional concerns include improper train-test split implementations, the use of hardcoded hyperparameters without proper tuning, and poor handling of imbalanced datasets, as highlighted by Takeuchi et al. [ 30 ] and Washizaki et al. [ 31 ] . The limitations of traditional code smell detection tools in understanding ML-specific contexts [ 16 ] emphasize the need for specialized quality assurance approaches in ML development, particularly as ML systems become more complex and widespread. This growing challenge, further elaborated by Tsoukalas et al. [ 17 ] and Alahdab and Çalıklı [ 20 ] , underscores the importance of developing new tools and methodologies specifically designed to address the unique quality concerns in ML software development. II-A Current State of ML Code Quality Tools The evolution of code quality tools has primarily focused on traditional software development, leaving a significant gap in tools specifically designed for machine learning applications. While several tools offer partial solutions for ML code quality assessment, they fall short of providing comprehensive coverage for the unique challenges posed by ML development. In the current ML quality landscape, tools like MLlint [ 32 ] provide project-level quality analysis focusing on code, data, and configuration aspects. While valuable for general project assessment, it lacks the deep framework-specific analysis that MLScent offers. Data Linter [ 33 ] and Datalab [ 34

Read the complete text