# An Empirical Evaluation of Ensemble Models for Python Code Smell Detection
## 1 Introduction  
Code smells propose weak design and execution choices, which could prevent code comprehension while increasing change and error proneness [1]. A code smell (CS) is a distinctive feature in the source code of a program that indicates the presence of a more significant issue. Code smells manifest when the coding process lacks adherence to ethical principles [2]. Software developers encounter a challenging endeavor when it comes to identifying code smells. Unlike Java, Python features dynamic typing, indentation-based scoping, and a more compact syntax. These language-specific characteristics affect how code smells manifest and challenge traditional detection techniques. Thus, machine-learning (ML)-based detection approaches validated on Java code may not directly translate to Python environments, underscoring the need for a dedicated study. Software development may encounter technical hurdles and design obstacles as it strives to meet deadlines and adapt to changing requirements [3]. According to [PERSON] et al. [4], technical issues may be described as the act of compromising one developmentcriterion in favor of another, such as software quality, in order to fulfill a certain deadline. The presence of code smells may have a significant negative influence on the overall quality of a program. [PERSON] and [PERSON] [5] define code smells as instances of suboptimal code design or implementation, characterized by the presence of intricate or extensive classes. Examples of code smells include a class that has an excessive number of responsibilities (Large Class) or a function with an excessive number of arguments (Long Method). Code smells may occur at several levels, including the class, method, and statement levels. However, code smells affect the system's quality rather than its functioning. Thus, the early detection of code smells improves the quality of code and system efficiency [6; 7]. Code smells can be found either automatically or manually in system designs or source code. Three primary methods for detecting code smells are rule-based, ML-based, and metrics-based. A rule-based method involves software engineers optimizing a rule to describe each code smell. However, this process of defining rules needs to be standardized and occasionally performed by hand, which can lead to inconsistencies and arbitrary interpretations [8]. Metrics-based detection involves code metrics such as lines of code or cyclomatic complexity but lacks standard thresholds, reducing accuracy [9; 10; 11]. ML-based techniques, especially ensemble models, have proven effective in automating code smell detection by capturing complex patterns in source code [12]. However, most existing research focuses on Java-based, object-oriented systems, leaving dynamically typed languages like Python relatively underexplored. Given Python's growing popularity and its unique language characteristics, such as dynamic typing and indentation-based scoping, there is a clear need for further research in this area [13]. To address this gap, the present study proposes a Python-specific ensemble-based detection framework that incorporates SMOTE (Synthetic Minority Oversampling Technique) for class balancing, Chi-square Feature Selection Technique (FST) for dimensionality reduction, and five ensemble classifiers. While some of these methods were applied in our previous Java-based research [14], this study adapts and evaluates them in the Python context, introducing new empirical insights into their cross-language generalizability. Unlike the Java-centric datasets used previously, this study utilizes two Python-specific code smell datasets, Large Class (LC) and Long Method (LM), collected from real-world open-source Python repositories. We investigate the performance of multiple ensemble models in this new context and assess whether established techniques retain their effectiveness. Challenges such as imbalanced datasets, noisy or irrelevant features, and overfitting are further exacerbated in Python due to limited tooling and benchmark datasets.