# An Empirical Evaluation of Ensemble Models for Python Code Smell Detection
## 5 Discussion  
This study evaluated the applicability and effectiveness of ensemble learning techniques for Python-specific code smell detection, guided by three research questions. Five ensemble models, Bagging, Gradient Boost, Max Voting, AdaBoost, and XGBoost, were evaluated on two real-world Python datasets (LC and LM) using six performance metrics. The models were further enhanced through the application of chi-square-based FST and the SMOTE technique for class balancing. The outcomes of these implementations are discussed in Sections 4.1 and 4.2.  
For Research Question 1, the Max Voting method achieved the highest accuracy score of 0.96 and an MCC score of 0.85 for the LC dataset, while the Gradient Boost method achieved the highest accuracy score of 0.9845 and an MCC score of 0.94 for the LM dataset. This variation demonstrates that ensemble model performance depends on the code smell type and dataset characteristics. The results affirm the adaptability of ensemble models to Python, though optimal model choice varies by context.  
For Research Question 2, the chi-square FST enhances performance accuracy across most models for both datasets. This validates its effectiveness in filtering irrelevant or noisy metrics, a critical advantage in Python's dynamically typed, metric-diverse environment. The gains were especially notable in boosting models such as Gradient Boost and AdaBoost.  
For Research Question 3, SMOTE consistently improved recall and MCC without degrading precision, indicating enhanced detection of minority-class instances (i.e., smelly code) and reducing false negatives. This effect was particularly strong in the imbalanced LC dataset, mirroring success observed in Java-based studies and confirming SMOTE's transferability.  
Thus, the experiments show that applying chi-square FST improves model accuracy by reducing irrelevant features, while SMOTE boosts recall by addressing data imbalance. When used in combination, these techniques not only raise classification accuracy but also improve generalizability and robustness across both LC and LM datasets, thereby answering RQs in a more comprehensive and scientifically grounded manner. This study can be viewed as a domain transfer validation effort.  
Importantly, this study can be understood as a domain transfer validation effort, evaluating whether ML-based code smell detection methods originally optimized for Java, a statically typed, strongly structured language, retain their effectiveness when applied to Python, which is dynamically typed and relies on indentation-based scoping. Given differences in type declaration, structural conventions, and metric distributions, this transfer is non-trivial.  
Our findings suggest that while core techniques such as ensemble learning, FST, and SMOTE are effective across both languages, their performance and behavior vary depending on language-specific characteristics. This insight underscores the necessity of programming language-aware adaptation when designing ML-based software quality assurance tools.  
By offering a comprehensive evaluation of two Python datasets and comparing results with prior Java-focused work, this study contributes empirical evidence toward the portability, limitations, and tuning needs of ML models across programming languages. Future work should extend this analysis to other languages (e.g., C++, JavaScript) andexplore additional code smell types and model architectures to delineate the boundaries of cross-language model transfer further.