Skip to content

AryanDhanuka10/Heart-Failure-Prediction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heart Failure Prediction System

Overview

This project implements a dual-model approach for heart failure prediction using both clinical data and MRI images. The system combines a Random Forest model for analyzing clinical parameters and a Convolutional Neural Network (CNN) for processing medical imaging data, providing medical professionals with comprehensive diagnostic support.

heartimage

Visit Deployed App

Features

  • Dual Prediction Methods:
    • Clinical data analysis using Random Forest
    • MRI image analysis using CNN
  • Interactive Web Interface:
    • User-friendly Streamlit application
    • Real-time predictions

Project Structure

heart_failure_pred/
├── artifacts/
│   ├── data/
│   │   ├── img_data/
│   │   │   ├── normal/
│   │   │   └── failure/
│   │   └── tabular_data/
│   │       └── heart_failure.csv
│   └── models/
│       ├── cnn/
│       │   ├── cnn_model.keras
│       │   └── cnn_score.json
│       └── rf/
│           ├── rf_model.pkl
│           └── rf_score.json
├── main.py
├── utils.py
├── app.py
├── requirements.txt
└── README.md

Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Setup

  1. Clone the repository:
git clone https://github.com/AryanDhanuka10/Heart-Failure-Prediction.git
cd heart_failure_pred
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows, use: venv\Scripts\activate
  1. Install required packages:
pip install -r requirements.txt

Model Training

Train Models

To train both the Random Forest and CNN models:

python main.py

This script will:

  • Load and preprocess the data
  • Train the Random Forest model with hyperparameter tuning
  • Train the CNN model
  • Save the trained models and their performance metrics

Using the Web Interface

Start the Application

streamlit run app.py

Making Predictions

Clinical Data Prediction

  1. Navigate to the "Clinical Data Prediction" tab
  2. Enter the required clinical parameters:
    • Age
    • Anaemia status
    • Creatinine phosphokinase level
    • Diabetes status
    • Ejection fraction
    • High blood pressure status
    • Platelets count
    • Serum creatinine level
    • Serum sodium level
    • Sex
    • Smoking status
    • Follow-up period
  3. Click "Predict" to get results

MRI Image Prediction

  1. Navigate to the "MRI Image Prediction" tab
  2. Upload a DICOM format MRI image
  3. View the prediction results

Technical Details

Data Format Requirements

Clinical Data

  • All numerical inputs should be non-negative
  • Binary inputs (anaemia, diabetes, high blood pressure, sex, smoking) use 0/1 encoding
  • Input ranges:
    • Age: 0-100 years
    • Ejection Fraction: 0-100%
    • Platelets: typical range 150,000-450,000 per μL
    • Time: measured in days

Image Data

  • Format: DICOM (.dcm)
  • Processed to 224x224 pixels
  • Normalized to [0,1] range

Models

Random Forest Model

  • Features: 12 clinical parameters
  • Hyperparameter tuning via GridSearchCV
  • Optimization metric: Accuracy
  • Output: Binary classification with probability scores

CNN Model

  • Architecture: Sequential model with multiple convolutional layers
  • Input shape: (224, 224, 1)
  • Training: Adam optimizer with sparse categorical crossentropy
  • Output: Binary classification (normal/failure)

Performance Metrics

The system saves performance metrics for both models:

  • For Random Forest: accuracy, F1 score, and detailed classification report
  • For CNN: loss and accuracy metrics

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

Acknowledgments

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published