YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Stroke Prediction using Machine Learning
Project Overview
This project develops a machine learning pipeline to predict the likelihood of strokes using the Kaggle Stroke Prediction Dataset. The goal is to accurately classify individuals into stroke or non-stroke categories while addressing challenges such as class imbalance.
Dataset
The dataset contains the following features:
- age: Age of the patient.
- avg_glucose_level: Average glucose level in the blood.
- bmi: Body Mass Index of the individual.
- gender, work_type, smoking_status: Categorical attributes describing patient demographics.
- stroke: Target variable indicating whether the patient had a stroke (1) or not (0).
Data Source
Workflow Pipeline
Data Preparation:
- Missing values in
bmiwere imputed with the mean value. - Irrelevant columns like
idwere dropped.
- Missing values in
Exploratory Data Analysis (EDA):
- Visualized distributions of numerical features (
age,avg_glucose_level,bmi). - Analyzed class distributions and correlations between features.
- Visualized distributions of numerical features (
Feature Engineering:
- Applied one-hot encoding for categorical variables.
- Standardized numerical features for consistent scaling.
Model Development:
- Implemented and evaluated multiple models:
- Logistic Regression
- Random Forest
- XGBoost
- Gradient Boosting
- Addressed class imbalance using SMOTE to oversample the minority class.
- Models were evaluated using metrics such as Accuracy, Precision, Recall, F1-Score, and ROC-AUC.
- Implemented and evaluated multiple models:
Software Engineering Best Practices:
- Integrated unit tests to validate pipeline components.
- Enhanced logging for debugging and workflow traceability.
Deployment:
- [Optional] Model deployment details go here if you’ve deployed it.
Results
| Model | Accuracy | Precision | Recall | F1-Score | ROC-AUC |
|---|---|---|---|---|---|
| Logistic Regression | 0.75 | 0.60 | 0.40 | 0.48 | 0.82 |
| Random Forest (SMOTE) | 0.88 | 0.14 | 0.26 | 0.18 | 0.77 |
| XGBoost (SMOTE) | 0.89 | 0.13 | 0.22 | 0.17 | 0.78 |
| Gradient Boosting (SMOTE) | 0.80 | 0.14 | 0.60 | 0.23 | 0.79 |
Key Findings:
- Gradient Boosting with SMOTE performed best in detecting the minority class (
stroke = 1), achieving the highest recall (0.60) and ROC-AUC (0.79).
Usage Instructions
Prerequisites
- Python 3.10.0
- Libraries:
pandas,numpy,matplotlib,seaborn,scikit-learn,imbalanced-learn,xgboost
Steps to Run the Pipeline
Clone the repository: bash git clone https://github.com/your-repo/stroke-prediction.git cd stroke-prediction
Install dependencies: bash pip install -r requirements.txt
Run the pipeline: bash python pipeline.py
Run tests: bash pytest test_pipeline.py
Future Enhancements
- Hyperparameter tuning for better model performance.
- Deployment of the best model using Flask or FastAPI.
- Integration of additional datasets for improved generalization.
Contributors
- Salah Dabor
- Downloads last month
- 5