# A-Tuning Ensemble Machine Learning Technique for Cerebral Stroke Prediction
## 3 Materials and Methods
### Methodology  
In this research, we proposed a robust tuning ensemble RXLM from RF, XGBoost, and LightGBM for predicting cerebral stroke, where an open-access dataset for stroke prediction is applied. The dataset was pre-processed by handling missing values using the K-nearest neighbor (KNN) Imputer technique, eliminating outliers, applying the one-hot encoding method, and normalizing the features with different ranges of values. After splitting the dataset, we applied the SMOTE to the training set only to balance the samples of the two classes. Furthermore, we applied the random search technique to tune the hyper-parameters of RF, XGBoost, and LightGBM to get the best parameter values. After tuning, we stacked the three ML models to propose the tuning RXLM. Traditional classifiers and the proposed tuning ensemble RXLM were assessed and compared. The results of the ensemble's accuracy, AUC, recall, precision, F1-score, Kappa, and MCC recorded 95.29%, 99.13%, 96.38%, 94.36%, 95.35%, 90.59%, and 90.63%, respectively. The evaluation of the proposed ensemble showed that the proposed ensemble achieved superior outcomes. The primary achievements of the research are:  
1. We proposed a novel tuning ensemble RXLM from RF, XGBoost, and LightGBM to predict cerebral stroke diseases. 2. We used the open-access Stroke Prediction dataset and the KNN Imputer technique to handle the missing values. 3. We applied the SMOTE on the training set to balance the two classes' samples due to the imbalance of the training subset. 4. We tuned the hyper-parameters of the RF, XGBoost, and LightGBM using the random search technique to get the best parameter values and their high performance. 5. Achieving 95.29%, 99.13%, 96.38%, 94.36%, 95.35%, 90.59%, and 90.63% for accuracy, AUC, recall, precision, F1-score, Kappa, and MCC, respectively, for stroke disease prediction. As depicted in Figure 1, we trained three ML methods (RF, XGBoost, and LightGBM) and stacked them to propose a tuning ensemble RXLM. Each ML model of RF, XGBoost, and LightGBM has some limitations. However, the proposed tuning ensemble achieved a high binary classification success because it combined the advantages of the three ML models to improve the overall accuracy. Figure 1 depicts the steps of the proposed tuning ensemble model: (1) pre-processing of the Stroke Prediction dataset, (2) splitting the dataset, (3) applying the SMOTE on the training set, (4) tuning the three ML techniques, (5) stacking the three tuning ML models, (6) utilizing the measured metrics to evaluate the proposed tuning ensemble model. At the beginning of our experiment, we pre-processed the dataset by replacing missing values, eliminating outliers, applying one-hot encoding, and normalizing the data. In the second step, we split the stroke dataset into a training set with 4088 rows (3901 no-stroke and 187 strokes) (80%) and a test set with 1022 rows (20%). We applied the ten-fold cross-validation technique that used more than one train-test split of the data to evaluate the RF, XGBoost, LightGBM, and the proposed ensemble models. The ten-fold cross-validation uses one fold as a test set and nine folds as train sets. It selected various values for the train-test split function's random state seed parameter. By running multiple training-test splits and then averaging the results, cross-validation provided estimates of how the four models were likely to perform, on average, more stably and reliably than those based solely on a single training set. In the third step, we oversampled the training set using the SMOTE. The SMOTE increased the stroke class to 3901 samples. In the fourth step, we trained the three ML models: RF, XGBoost, and LightGBM, on the training set, and we tuned their parameters using the random search method. In the fourth step, we stacked the three tuning ML techniques, proposed the tuning ensemble RXLM, and trained it on the training set. The random search method tunes the hyper-parameters to get the best parameter values.