# An Empirical Evaluation of Ensemble Models for Python Code Smell Detection
## 3 Proposed Research Framework
### Data Selection  
This study used two Python datasets (LM and LC) from [PERSON] et al. [3], accessible at [[https://doi.org/10.5281/zenodo.7512516](https://doi.org/10.5281/zenodo.7512516)]([https://doi.org/10.5281/zenodo.7512516](https://doi.org/10.5281/zenodo.7512516)). The datasets were constructed using four widely adopted open-source Python libraries: Scipy-V0.16.0b2, Matplotlib-V1.4.3, Django-V1.8.2, and Numpy-V1.9.2. These libraries were chosen for their widespread use in the Python community and their relevance to the code smell detection problem.  
The selection of Python code was based on a number of factors, including its Python writing language, open-source status, and the PySmell dataset's assessment of its smelliness or non-smelliness. The data collection process involved a rigorous sampling strategy. In the LC dataset, 1000 samples were randomly chosen from a total of 10,000, while in the LM dataset, 1000 samples were randomly selected from a pool of 40,000. Each sample that was chosen was categorized as \"smelly\" or \"non-smelly\" according to predetermined code smell detection standards using well-known tools (like PySmell).  
Although we utilized PySmell to categorize \"smelly\" and \"non-smelly\" labels, it is important to recognize that automated labeling tools may introduce bias. Mislabeling can occur if the tool inaccurately interprets ambiguous or context-dependent code constructs, potentially impacting the quality of the ground truth.  
Figure 1: Proposed Research Work.  
Among the selected samples, only 200 samples in the LC and approximately 900 samples in the LM were found to meet the criteria for classification as'smelly,' resulting in a class imbalance (roughly 20% smelly to 80% non-smelly). To address this, we applied SMOTE to augment the minority class while preserving the dataset's statistical integrity. This step was crucial to mitigate the inherent skewness typical in code smell detection problems [40].  
While the datasets are relatively small, each was specifically designed to identify two common and well-known classes of code smells in Python. These two types are critical indicators of poor code quality, rendering them appropriate for our analysis. Working with these two categories enables us to concentrate on resolving essential issues in code smell detection, including class imbalance and feature selection. Moreover, analysis indicates that despite the limited dataset, we attained superior performance across various ensemble models (e.g., Max Voting and Gradient Boost), highlighting the efficacy of the proposed methods in identifying code smells.  
Nonetheless, we acknowledge that the scope and size of the datasets may limit the generalizability of our findings. Future work will explore the extension of this framework to larger and more diverse datasets to validate its effectiveness across a broader range of Python code smells.  
The choice to focus on two specific code smells, LC and LM, was based on their practical significance and frequent manifestation in actual software projects. Although broadening the scope to encompass additional categories of code smells is essential, concentrating on these two establishes a robust basis for subsequent research in Python code smell detection. This emphasis assures that the methodologies and techniques employed are tailored to these particular issues, providing a comprehensive understanding of the challenges associated with identifying these code smells in Python.