Skip to content

The Project Helps in detecting Stroke in a Patient by using parameters specified , thereby helping early prediction.

Notifications You must be signed in to change notification settings

abhinavdev369/Stroke_Predictor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stroke Predictor Project

Overview

The Stroke Predictor is a machine learning-based web application that predicts stroke risk based on health data inputs like age, gender, BMI, and smoking status. It includes two core scripts:

  • train.py: Trains a TensorFlow neural network, preprocesses data, and saves model artifacts (model, scaler, encoders, SHAP explainer).
  • app.py: A Flask web app with a user-friendly interface for input collection, stroke risk prediction, and interpretable results with lifestyle recommendations.

The model uses a neural network with dropout regularization, SHAP for interpretability, and Flask with CSRF protection for secure web deployment.

Features

  • Data Preprocessing: Handles missing values, encodes categorical features, and scales numerical features.
  • Model Training: Trains a neural network for binary classification (stroke/no stroke).
  • Web Interface: Validates user inputs and displays predictions, risk scores, and top risk factors.
  • Interpretability: Uses SHAP to identify key risk factors (e.g., high glucose, smoking).
  • Recommendations: Offers personalized lifestyle advice based on user inputs.

Prerequisites

  • Python 3.8+
  • Required packages (listed in requirements.txt):
    • pandas
    • numpy
    • scikit-learn
    • tensorflow
    • flask
    • flask-wtf
    • joblib
    • shap
  • A web browser for accessing the Flask app.

Project Structure

stroke_predictor/ ├── dataset/ │ └── stroke_data1.csv # Input dataset for training ├── model/ │ ├── stroke_predictor_model.h5 # Trained neural network model │ ├── label_encoders.pkl # Label encoders for categorical features │ ├── scaler.pkl # StandardScaler for numerical features │ ├── shap_explainer.pkl # SHAP explainer for interpretability │ └── feature_names.pkl # Feature names for SHAP explanations ├── templates/ │ └── index.html # HTML template for Flask app ├── app.py # Flask web application ├── train.py # Model training and preprocessing script ├── requirements.txt # Python dependencies └── README.md # Project documentation

Installation

Clone the Repository: git clone cd stroke_predictor python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt

Instructions for Use

  1. Open VSCode and navigate to your stroke_predictor/ directory.
  2. Create or open README.md in the project root.
  3. Copy the entire content above and paste it into README.md.
  4. Save the file.
  5. Stage and commit to Git: git add README.md git commit -m "Add README for Stroke Predictor project" git push origin main

About

The Project Helps in detecting Stroke in a Patient by using parameters specified , thereby helping early prediction.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published