A machine learning-based multi-class prediction system for cardiovascular disease (CVD) risk (Low / Medium / High) in the Egyptian population, using feedforward artificial neural networks (ANNs) on clinical and biochemical biomarkers.
This repository reproduces the methodology of the study "A Machine Learning-based Prediction System for Cardiovascular Disease for the Egyptian Population" end-to-end in a single Jupyter notebook: data preprocessing, three ANN architectures, evaluation, and SHAP-based interpretability.
Cardiovascular disease is the leading cause of death globally and a major burden in Egypt, yet few prediction systems have been tailored to the Egyptian population. This project trains and compares three feedforward ANN architectures — narrow, bi-layered, and tri-layered — to classify patients into CVD risk categories from nine demographic and biochemical features, then uses SHAP to explain which biomarkers drive the predictions.
- Dataset: 1,000 Egyptian patients (demographic + biochemical records)
- Task: Multi-class classification —
Heart_Risk∈ {Low, Medium, High} - Models: Narrow NN (4), Bi-layered NN (8→4), Tri-layered NN (16→8→4) — ReLU hidden layers, Softmax output, Adam optimizer
- Split: Stratified 70% train / 15% validation / 15% test
- Explainability: SHAP (SHapley Additive exPlanations)
cvd-risk-prediction-egypt/
├── data/
│ └── Egypt_Data.xlsx # Raw dataset (1,000 patients, 13 columns)
├── notebooks/
│ └── CVD_Risk_Prediction_Egypt.ipynb # Full, executed, end-to-end pipeline
├── figures/ # All plots exported from the notebook
│ ├── 01_eda_class_distribution_and_correlation.png
│ ├── 02_model_performance_comparison.png
│ ├── 03_confusion_matrices.png
│ ├── 04_roc_curves.png
│ ├── 05_shap_class_wise_importance.png
│ ├── 06_shap_global_feature_importance.png
│ ├── 07_shap_beeswarm_high_risk.png
│ └── 08_risk_stratification_distribution.png
├── results/ # Tables exported as CSV
│ ├── table1_demographics_clinical.csv
│ ├── table3_model_performance_test_set.csv
│ ├── table4_roc_auc_per_class.csv
│ ├── test_set_predictions_Tri-layered_NN.csv
│ └── best_model.txt
├── requirements.txt
├── LICENSE
└── README.md
data/Egypt_Data.xlsx — 1,000 records, 13 columns. Model inputs are the 9 features defined by the study:
| Category | Features |
|---|---|
| Demographic | Age, Gender |
| Biochemical | HbA1c, HDL, LDL, TG (Triglycerides), Fasting_Insulin |
| Derived | TG_HDL_Ratio, HOMA_IR |
| Target | Heart_Risk (Low / Medium / High) |
Age_Group, Diabetic, and Insulin_Resistant are present in the raw file but excluded from modeling — they are not part of the study's defined feature set and are themselves derived from the biomarkers above.
Cohort summary (Table I):
| Variable | Value (Mean ± SD or n (%)) |
|---|---|
| Age (years) | 44.02 ± 24.45 |
| Gender (Male) | 515 (51.5%) |
| Gender (Female) | 485 (48.5%) |
| HbA1c (%) | 6.89 ± 1.17 |
| HDL (mg/dL) | 45.26 ± 10.27 |
| LDL (mg/dL) | 139.71 ± 27.34 |
| Triglycerides (mg/dL) | 172.40 ± 50.82 |
| Fasting Insulin (µU/mL) | 7.72 ± 3.21 |
| HOMA-IR | 1.89 ± 0.78 |
- Preprocessing — median imputation for missing numeric values, mode imputation for
Gender, Min-Max normalization ([0, 1]) of continuous features, one-hot encoding ofGender. - Split — stratified 70% / 15% / 15% train / validation / test.
- Models — three fully-connected feedforward ANNs (ReLU hidden layers, Softmax output, Adam optimizer), implemented with scikit-learn's
MLPClassifier. Each architecture is trained from multiple random initializations, and the best is selected by validation accuracy + macro F1-score — matching the study's described hyperparameter/model-selection procedure. - Evaluation — Accuracy, Sensitivity (Recall), Specificity, Precision, F1-score, and Matthews Correlation Coefficient (MCC), all macro-averaged across the three risk classes; confusion matrices; per-class and macro-average ROC/AUC.
- Explainability — SHAP analysis on the best-performing model to rank the clinical/biochemical features driving CVD risk predictions.
Table III — Model performance on the held-out test set:
| Metric | Narrow NN | Bi-layered NN | Tri-layered NN |
|---|---|---|---|
| Accuracy | 95.33% | 95.33% | 97.33% |
| Sensitivity (Recall) | 95.89% | 95.62% | 97.98% |
| Specificity | 97.67% | 97.57% | 98.76% |
| Precision | 95.10% | 95.32% | 97.03% |
| F1-Score | 95.45% | 95.46% | 97.43% |
| MCC | 92.90% | 92.83% | 96.01% |
Macro-average AUC: Narrow NN 0.997 · Bi-layered NN 0.996 · Tri-layered NN 0.994 (all classes AUC > 0.98)
See results/ for the full CSV tables and figures/ for confusion matrices, ROC curves, and SHAP plots.
git clone https://github.com/ahmedsal95/cvd-risk-prediction-egypt.git
cd cvd-risk-prediction-egypt
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
jupyter notebook notebooks/CVD_Risk_Prediction_Egypt.ipynbThe notebook is self-contained and runs top-to-bottom without external dependencies beyond requirements.txt.
Note on implementation: the original study trained its ANNs with TensorFlow/Keras; this notebook uses scikit-learn's
MLPClassifier(same architectures, activations, and optimizer) so the pipeline runs without a deep-learning framework dependency. Reported metrics may therefore differ slightly from the source article, and the SHAP feature-importance ranking obtained here reflects this implementation's models rather than being copied from the paper.
- Single-center dataset of 1,000 subjects; no external/multi-center validation.
- Only demographic and biochemical features — no ECG, imaging, lifestyle, or genetic data.
- Cross-sectional data; no modeling of temporal risk progression.
Released under the MIT License.
If you use this repository, please cite the following article
Abdel Rahman Shaaban, Neven Saleh, and Ahmed M. Salaheldin. "A Machine Learning-based Prediction System for Cardiovascular Disease for the Egyptian Population." Menoufia Journal of Electronic Engineering Research 35.2 (2026): 217-228.



