Skip to main content
. 2025 Jun 9;15(12):1467. doi: 10.3390/diagnostics15121467
Algorithm 1. Stacked Ensemble for Prediction
Step 1: Split the data set
 • X = The attributes
 • Y = The Status
Step 2: Balance the dataset using SMOTE
Step 3: Split the Dataset into training and testing set
• x_train, x_test, y_train, y_test, stratify y and test_size = 0.3
Step 4: Import stacking classifier from Sklearn Library
Step 5: Import all the classifiers also from Sklearn Library
 • Import SVM
 • Import K-neighbor classifier
 • Import LR
 • Import RF Classifier
Step 6: Initiate the hyper parameters of the Classifiers
Step 7: Stacked the classifiers and initiate LR as the final estimator
Step 8: Train the Stacked Ensemble with x_train and y_train
Step 9: Predict using x_test
Step 10: Print the Confusion matrix, Classification report and accuracy score.
Step 11: End
Abbreviations—SMOTE: Synthetic Minority Oversampling Technique; SVM: Support Vector Machine; LR: Logistic Regression; RF: Random Forest