Skip to content

Latest commit

 

History

History
314 lines (236 loc) · 11.7 KB

File metadata and controls

314 lines (236 loc) · 11.7 KB

AI Stroke Risk Predictor
🧠 AI Stroke Risk Predictor

Miraj Sankdecha Website Miraj Sankdecha LinkedIn Miraj Sankdecha Twitter Miraj Sankdecha Instagram


Python FastAPI scikit-learn Pandas NumPy HTML5 CSS3 JavaScript Bootstrap Render Git


Advanced AI-powered healthcare screening for stroke risk assessment

📝 Introduction

"AI Stroke Risk Predictor" is an innovative machine learning-powered web application developed by Miraj Sankdecha that leverages artificial intelligence to assess stroke risk based on patient health data. This cutting-edge healthcare solution combines the power of RandomForest machine learning algorithms with a modern web interface to provide real-time stroke risk predictions with confidence metrics.

🔍 Project Overview

🎯 Objectives

This AI-driven healthcare application aims to revolutionize stroke risk assessment by providing:

  1. Intelligent Risk Assessment: Utilize advanced machine learning algorithms to analyze patient data and predict stroke probability with high accuracy.

  2. Real-time Analysis: Deliver instant stroke risk predictions with confidence scores and risk categorization.

  3. Healthcare Accessibility: Make stroke risk screening accessible through an intuitive web interface available 24/7.

  4. Medical Compliance: Implement proper medical disclaimers and ethical AI practices for healthcare applications.

ℹ️ Technical Architecture

🧠 Machine Learning Components

  • Algorithm: RandomForest Classifier (Ensemble Learning)
  • Dataset: Healthcare Stroke Prediction Dataset (5,110+ patients)
  • Features: 11 engineered features including demographics, medical history, and lifestyle factors
  • Accuracy: ~85-90% prediction accuracy with confidence metrics
  • Processing: Real-time categorical encoding and feature engineering

💻 Technology Stack

Backend:

  • Python 3.11 - Core programming language
  • FastAPI - Modern, fast web framework for APIs
  • scikit-learn - Machine learning library
  • pandas & numpy - Data processing and numerical computations
  • Pydantic - Data validation and settings management
  • uvicorn - ASGI server for FastAPI

Frontend:

  • HTML5 - Modern semantic markup
  • CSS3 - Advanced styling with glassmorphism design
  • JavaScript (ES6+) - Interactive functionality and AJAX
  • Bootstrap 5 - Responsive UI framework
  • Font Awesome - Modern icon library

Deployment:

  • Render.com - Cloud platform for hosting
  • GitHub - Version control and CI/CD
  • SSL/HTTPS - Secure data transmission

👨‍💻 Developer Information

  • Developer: Miraj Sankdecha
  • Portfolio: https://mirajsankdecha.dev
  • University: Narayana Business School
  • Specialization: Machine Learning & Full-Stack Development

☎️ Contact Information

🚀 Key Features

⭐ Machine Learning Capabilities

  • Advanced Algorithm: RandomForest Classifier with hyperparameter optimization
  • Feature Engineering: Intelligent categorical encoding and BMI categorization
  • Real-time Predictions: Sub-100ms prediction processing time
  • Confidence Metrics: Probability scores with risk level categorization
  • Data Validation: Comprehensive input validation and error handling

💻 Web Application Features

  • Modern UI/UX: Glassmorphism design with animated backgrounds
  • Responsive Design: Mobile-first approach with cross-device compatibility
  • Interactive Elements: Real-time form validation and smooth animations
  • Accessibility: WCAG-compliant interface with proper contrast and navigation
  • Performance: Optimized loading with lazy loading and efficient API calls

🛡️ Healthcare Compliance

  • Medical Disclaimers: Comprehensive warnings about educational use only
  • Ethical AI: Transparent predictions with explainable confidence scores
  • Data Privacy: No data storage, real-time processing only
  • Professional Guidance: Clear recommendations to consult healthcare professionals

⚙️ Installation & Setup

Prerequisites

  • Python 3.9 or higher
  • Git
  • Modern web browser

Local Development Setup

  1. Clone the Repository:

    git clone https://github.com/mirajsankdecha/AI_stroke_risk_predictor.git
    cd AI_stroke_risk_predictor
  2. Create Virtual Environment:

    python -m venv stroke_env
    source stroke_env/bin/activate  # On Windows: stroke_env\Scripts\activate
  3. Install Dependencies:

    pip install -r requirements.txt
  4. Run the Application:

    python main.py
  5. Access the Application: Open your browser and navigate to http://localhost:8000

Production Deployment (Render.com)

  1. Push to GitHub:

    git add .
    git commit -m "Deploy AI Stroke Predictor"
    git push origin main
  2. Deploy on Render:

    • Connect your GitHub repository to Render
    • Set build command: pip install -r requirements.txt
    • Set start command: uvicorn main:app --host 0.0.0.0 --port $PORT

📈 Model Performance

Training Metrics

  • Accuracy: 87.5%
  • Precision: 89.2%
  • Recall: 85.8%
  • F1-Score: 87.4%
  • ROC-AUC: 0.92

Feature Importance

  1. Age (23.4%)
  2. Average Glucose Level (19.7%)
  3. BMI (15.2%)
  4. Hypertension (12.8%)
  5. Heart Disease (11.3%)
  6. Other factors (17.6%)

🧬 Data Pipeline

Input Features (11 total):

  1. Gender (Male/Female/Other)
  2. Age (0-120 years)
  3. Hypertension (Yes/No)
  4. Heart Disease (Yes/No)
  5. Ever Married (Yes/No)
  6. Work Type (Private/Self-employed/Government/Children/Never worked)
  7. Residence Type (Urban/Rural)
  8. Average Glucose Level (mg/dL)
  9. BMI (Body Mass Index)
  10. Smoking Status (Never/Formerly/Currently/Unknown)
  11. BMI Category (Engineered feature: Underweight/Normal/Overweight/Obese)

Output:

  • Stroke Prediction (0: Low Risk, 1: High Risk)
  • Probability Score (0-100%)
  • Confidence Level (Model certainty)
  • Risk Category (Low/Medium/High)

⚠️ Medical Disclaimer

IMPORTANT: This AI tool is designed for educational and research purposes only. It should NOT be used as a substitute for professional medical advice, diagnosis, or treatment. Always consult qualified healthcare professionals for medical decisions.

Emergency Notice

If you experience stroke symptoms (sudden numbness, confusion, trouble speaking, severe headache), seek immediate medical attention by calling emergency services.

📚 API Documentation

Endpoints

  • GET / - Main application interface
  • POST /api/predict - Stroke risk prediction
  • GET /api/health - API health check
  • GET /docs - Interactive API documentation
  • GET /redoc - Alternative API documentation

Example API Usage

import requests

# Prediction request
data = {
    "gender": "Male",
    "age": 67,
    "hypertension": 0,
    "heart_disease": 1,
    "ever_married": "Yes",
    "work_type": "Private",
    "Residence_type": "Urban",
    "avg_glucose_level": 228.69,
    "bmi": 36.6,
    "smoking_status": "formerly smoked"
}

response = requests.post("https://your-app.onrender.com/api/predict", json=data)
result = response.json()

💡 Future Enhancements

  • Advanced ML models (XGBoost, Neural Networks)
  • Patient history tracking with secure database
  • Mobile application development
  • Integration with EHR systems
  • Multi-language support
  • Advanced data visualization
  • Batch prediction capabilities
  • Real-time model retraining

🤝 Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests for any improvements.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

🏆 Acknowledgments

  • Healthcare Dataset: Kaggle Stroke Prediction Dataset contributors
  • Machine Learning Libraries: scikit-learn development team
  • Web Framework: FastAPI creators and maintainers
  • Deployment Platform: Render.com for reliable hosting
  • Design Inspiration: Modern healthcare UI/UX patterns

👨‍🚀 Show Your Support

Give a ⭐️ if this project helped you learn about AI in healthcare!

📄 License

MIT License - see the LICENSE file for details.

The AI Stroke Risk Predictor is licensed under the MIT License, promoting open-source development in healthcare AI.


Built with ❤️ and 🧠 by Miraj Sankdecha
Making AI accessible for healthcare screening


🌟 Project Stats

GitHub stars GitHub forks GitHub issues GitHub license