## 2 Materials and Methods
### Stacking Models Using Ridge Regressor  
To leverage the strengths of multiple machine learning models and enhance predictive performance, a stacking ensemble approach was employed. This method integrates the predictions from multiple base models as inputs into a metamodel, which learns to optimally combine these predictions to produce a final, more robust output. In this study, a ridge regressor was selected as the metamodel, and a 10-fold cross-validation procedure with 30 repetitions was applied to mitigate overfitting. Given that different base models may capture similar patterns in the data, their predictions tend to be correlated. The ridge regressor was chosen as the metamodel due to its ability to handle multicollinearity among base model predictions. By incorporating an L2 penalty term into its cost function, the ridge regressor shrinks the coefficients towards zero, reducing model variance and improving generalization capacity. Additionally, it is computationally efficient and requires the tuning of only a single hyperparameter (alpha).  
To systematically evaluate the impact of different model combinations, four stacking configurations were proposed:  
* Stacking 1: uses the two best base models.  
Stacking 2: uses the three best base models.
* Stacking 3: uses the four best base models.
* Stacking 4: uses the five best base models.  
To ensure a fair comparison, each ML-based model--selected based on its optimal hyperparameters--was benchmarked against these four stacking configurations. The training, testing, and validation performances of these stacking models were evaluated following the same validation methodology described in the previous section. The workflow for constructing, training, testing, and validating the stacking models is presented in Pseudocode 3.  
**Input**\(X_{train-transformed}\); \(y_{train}\) (or \(y_{train-transformed}\)); \(X_{test-transformed}\); \(y_{test}\) (or \(y_{test-transformed}\)); all \(\textit{Best Model}_{i}\in I\); \(\textit{Seed}\); \(\textit{Metrics}\).  
Regardless of whether there is a transformation or not, they will be called \(y_{train}\) and \(y_{test}\) here.  
**Stacking:**  
Let \(\textit{Stacking}_{j}\in J\) be the metamodels to be built.  
**For**\(\textit{Stacking}_{j}\in J\):  
\(\textit{Set}_{j}=\) A certain number of the best models in \(\textit{Best Model}_{i}\in I\).  
\(\textit{Stacking}_{j}=\textit{Ridge\;Regressor}(\textit{Set}_{j})\).  
**end**  
**Training and Testing Metrics:**  
**For**\(\textit{Stacking}_{j}\in J\):  
Back Transformation of the data.  
\(\textit{Train\;Metrics}_{j}=\textit{Stacking}_{j}\Big{(}X_{train-transformed},y_{train},\textit{Seed}\Big{)}\).  
\(\textit{Test\;Metrics}_{j}=\textit{Stacking}_{j}\Big{(}X_{test-transformed},y_{test},\textit{Seed}\Big{)}\).  
**end**  
**Validation Metrics:**  
Let \(r\in R\) be the repetitions, where \(R=30\).  
**For**\(\textit{Stacking}_{j}\in J\):  
**For**\(r\in R\):  
\(\textit{Scores}_{j(r)}=\textit{Stacking}_{j}\Big{(}X_{train-transformed},y_{train},k-fold=10,\textit{Seed}\Big{)}\).  
**end**  
\(\textit{Validation\;Metrics}_{j}=\overline{\textit{Scores}_{j(r)}}\).  
**end**  
**Output**: \(\textit{Stacking}_{j}\forall j\in J\); \(\textit{Train\;Metrics}_{j}\); \(\textit{Test\;Metrics}_{j}\); \(\textit{Validation\;Metrics}_{j}\).