A machine learning project that analyzes patient health data to predict stroke risk using feature engineering, clustering, and classification models.
This project explores a dataset of ~15,000 patient records containing symptoms and health indicators to:
- Engineer meaningful risk indices from raw symptom data
- Segment patients into risk profiles using clustering
- Build and compare classification models for stroke risk prediction
The dataset (strokeX.csv) contains patient-level health indicators:
| Feature | Description |
|---|---|
age |
Patient age (years) |
gender |
Male/Female |
| 15 symptom indicators | Binary (0/1): chest_pain, high_bp, irregular_heartbeat, short_breath, fatigue, dizziness, swelling, neckjaw_pain, excess_sweating, persistent_cough, nausea_vomiting, chest_discomfort, cold_extremities, sleep_apnea, anxiety |
stroke_risk_pct |
Estimated stroke risk (0-100%) |
at_risk |
Binary target variable (1 = at risk, 0 = not at risk) |
Three custom risk indices were developed:
| Index | Formula | Purpose |
|---|---|---|
| ANRI | stroke_risk_pct / age | Identifies patients with unusually high risk for their age |
| SBI | Sum of all symptoms | Quantifies total symptom burden |
| CHRI | 0.4×high_bp + 0.4×irregular_heartbeat + 0.2×ANRI | Composite cardiovascular risk score |
Key Finding: SBI shows strong correlation (r=0.68) with stroke risk. Patients with 7+ symptoms have 99.3% average risk.
K-Means clustering (k=3) segmented patients into distinct risk profiles:
- Low Risk: Younger patients, fewer symptoms
- Medium Risk: Middle-aged, moderate symptom burden
- High Risk: Older patients, high symptom count
GMM clustering validated these groupings with ARI > 0.8.
Seven classification models were evaluated:
| Model | AUC | F1 Score | Accuracy |
|---|---|---|---|
| CatBoost | 1.000 | 0.993 | 0.991 |
| HistGradientBoosting | 0.999 | 0.992 | 0.990 |
| XGBoost | 0.999 | 0.989 | 0.986 |
| Gradient Boosting | 0.998 | 0.982 | 0.978 |
| Logistic Regression | 0.998 | 0.980 | 0.975 |
| Random Forest | 0.997 | 0.977 | 0.972 |
| KNN | 0.950 | 0.891 | 0.870 |
Best Model: CatBoost achieved near-perfect classification.
- SBI (Symptom Burden Index)
- Age
- Total symptoms
- Sleep apnea, chest pain, high BP
pip install -r requirements.txt
Key dependencies: pandas, numpy, scikit-learn, catboost, xgboost, matplotlib, seaborn
Open and run stroke_risk.ipynb in Jupyter Notebook or JupyterLab.
- Symptom count is the strongest predictor - Patients with 7+ symptoms have near-certain stroke risk
- Age amplifies risk - Older patients with multiple symptoms face significantly higher risk
- Gradient boosting models excel - CatBoost outperformed traditional ML approaches
- Clustering validates clinical intuition - Risk stratification aligns with low/medium/high groupings