{"id":25881068,"url":"https://github.com/pjaiswalusf/stroke-prediction","last_synced_at":"2025-07-25T08:07:54.585Z","repository":{"id":278598613,"uuid":"934362760","full_name":"pjaiswalusf/Stroke-Prediction","owner":"pjaiswalusf","description":"This project leverages machine learning to predict stroke risk using XGBoost, Random Forest, and Logistic Regression. It incorporates advanced data preprocessing, class imbalance handling with SMOTE, and hyperparameter optimization using Optuna. Model interpretability is enhanced with SHAP to identify key risk factors.","archived":false,"fork":false,"pushed_at":"2025-02-20T17:12:15.000Z","size":3683,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-20T17:24:54.896Z","etag":null,"topics":["data-science","datapreprocessing","logistic-regression","machine-learning","optuna","random-forest","shap","smote","xgboost"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pjaiswalusf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-17T17:47:58.000Z","updated_at":"2025-02-20T17:12:18.000Z","dependencies_parsed_at":"2025-02-20T17:35:06.857Z","dependency_job_id":null,"html_url":"https://github.com/pjaiswalusf/Stroke-Prediction","commit_stats":null,"previous_names":["pjaiswalusf/stroke-prediction"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjaiswalusf%2FStroke-Prediction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjaiswalusf%2FStroke-Prediction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjaiswalusf%2FStroke-Prediction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pjaiswalusf%2FStroke-Prediction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pjaiswalusf","download_url":"https://codeload.github.com/pjaiswalusf/Stroke-Prediction/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241521197,"owners_count":19976015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","datapreprocessing","logistic-regression","machine-learning","optuna","random-forest","shap","smote","xgboost"],"created_at":"2025-03-02T14:30:36.007Z","updated_at":"2025-03-02T14:31:17.791Z","avatar_url":"https://github.com/pjaiswalusf.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Optimized Stroke Prediction with Machine Learning 🚀\n\n## 📌 Overview\nThis project aims to predict the likelihood of stroke using **machine learning models** such as **XGBoost, Random Forest, and Logistic Regression**. The dataset consists of patient health records with various risk factors, and the model is optimized using **Optuna** for hyperparameter tuning. Additionally, **SHAP (Shapley Additive Explanations)** is utilized to enhance model interpretability by identifying the top contributing features.\n\n## 🛠️ Technologies Used\n- **Python** (Core programming language)\n- **Scikit-learn** (Machine Learning Library)\n- **XGBoost** (Boosted Decision Trees)\n- **Random Forest** (Ensemble Learning)\n- **Optuna** (Hyperparameter Tuning)\n- **SHAP** (Explainable AI)\n- **SMOTE** (Handling Class Imbalance)\n- **Pandas \u0026 NumPy** (Data Manipulation)\n- **Matplotlib \u0026 Seaborn** (Visualization)\n\n## 📊 Dataset\n- The dataset used in this project contains **5,110 patient records** with features like **age, hypertension, heart disease, smoking status, glucose level, BMI, and stroke occurrence**.\n- Data Source: [Healthcare Stroke Prediction Dataset](https://www.kaggle.com/fedesoriano/stroke-prediction-dataset)\n\n## 🔥 Key Features\n✅ **Data Preprocessing \u0026 Feature Engineering**: Missing value imputation, outlier detection, encoding, and scaling.\n\n✅ **Class Imbalance Handling**: Augmented minority class representation using **SMOTE** to balance stroke cases.\n\n✅ **Model Optimization \u0026 Evaluation**: Fine-tuned **Random Forest \u0026 XGBoost**, achieving **97.4% accuracy**.\n\n✅ **Explainable AI**: Used **SHAP** to highlight the **top 5 stroke risk factors**.\n\n✅ **Hyperparameter Tuning**: Optimized model performance using **Optuna**, improving prediction precision and recall.\n\n## ⚙️ Installation\nTo run this project locally, follow these steps:\n\n1. **Clone the repository**:\n   ```bash\n   git clone https://github.com/pjaiswalusf/Stroke-Prediction\n   cd stroke-prediction-ml\n   ```\n\n2. **Create and activate a virtual environment (optional but recommended):**\n   ```bash\n   python -m venv venv  # Create virtual environment\n   source venv/bin/activate  # For Mac/Linux\n   venv\\Scripts\\activate  # For Windows\n   ```\n\n3. **Install dependencies:**\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n4. **Run the Jupyter Notebook or Python script:**\n   ```bash\n   jupyter notebook\n   ```\n   Open `stroke_prediction.ipynb` and execute the cells.\n\n## 📌 Usage\n- **Exploratory Data Analysis (EDA):** Run the provided notebook to generate insights and visualize key features.\n- **Train the Model:** Train different models using the dataset and compare performance metrics.\n- **Hyperparameter Tuning:** Fine-tune the models using Optuna for the best results.\n- **Explainability:** Use SHAP to analyze feature importance and understand model predictions.\n\n## 📈 Model Performance\n| Model | Accuracy | Precision | Recall | F1-score |\n|--------|------------|------------|---------|----------|\n| **XGBoost** | **97.4%** | 95.8% | 96.1% | 96.0% |\n| **Random Forest** | 96.7% | 94.2% | 95.0% | 94.6% |\n| **Logistic Regression** | 85.6% | 81.0% | 83.2% | 82.1% |\n\n## 📊 Feature Importance (Top 5 Features by SHAP Analysis)\n1️⃣ **Age** 🡆 Higher age increases stroke risk.\n2️⃣ **Hypertension** 🡆 People with hypertension have a significantly higher probability of stroke.\n3️⃣ **Heart Disease** 🡆 Patients with pre-existing heart disease are more likely to have a stroke.\n4️⃣ **Glucose Level** 🡆 Elevated blood sugar levels strongly correlate with stroke occurrences.\n5️⃣ **BMI** 🡆 Obesity is a contributing factor to stroke risk.\n\n## 📌 Future Improvements\n🚀 **Deploy the model as an API** using **Flask/FastAPI** for real-time stroke prediction.\n🚀 **Improve class balancing techniques** to handle data skewness more effectively.\n🚀 **Try deep learning models** (e.g., LSTMs or Neural Networks) for better accuracy.\n\n## 🤝 Contributing\nFeel free to **fork** this repository, **open issues**, or submit **pull requests**. Contributions are always welcome!\n\n## 📜 License\nThis project is **open-source** and available under the **MIT License**.\n\n## 📬 Contact\nFor any questions or collaborations, reach out to me at **jaiswalpratik49@gmail.com** or connect via [LinkedIn](https://linkedin.com/in/yourprofile](https://www.linkedin.com/in/pratik-jaiswal-468315197/)). 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpjaiswalusf%2Fstroke-prediction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpjaiswalusf%2Fstroke-prediction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpjaiswalusf%2Fstroke-prediction/lists"}