Skip to content

Backend for heart disease prediction using machine learning. Processes data, trains models, and provides a RESTful API for predictions. Utilizes AWS S3 for storage, Lambda for serverless execution, and Serverless Framework for deployment. Handles missing data with default values for improved accuracy.

Notifications You must be signed in to change notification settings

Avishek3223/heart-diseases-prediction-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heart Disease Prediction Project

This project aims to predict the likelihood of heart disease using various machine learning models. The application is designed to preprocess data, train models, and make predictions based on user-provided inputs. The project is deployed using AWS Lambda and stores data and models in AWS S3.

Data Flow Diagram

heart diseases drawio

This diagram illustrates the flow of data through the different stages of the project, from data preprocessing to model training and prediction.

Project Structure

  • Preprocessing: Cleans and scales the input data.
  • Training: Trains multiple machine learning models and saves them to S3.
  • Prediction: Loads the trained models and makes predictions based on new data.

Features

  • Supports multiple machine learning models including Logistic Regression, Random Forest, SVM, XGBoost, LightGBM, and CatBoost.
  • Uses AWS S3 for data and model storage.
  • Provides a RESTful API for making predictions.

Setup Instructions

Prerequisites

  • Python 3.8+
  • AWS account with S3 bucket access
  • Serverless framework

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/heart-disease-prediction.git
    cd heart-disease-prediction
  2. Install the required Python packages:

    pip install -r requirements.txt
  3. Install the Serverless framework plugins:

    serverless plugin install -n serverless-python-requirements
    serverless plugin install -n serverless-layers

Deployment

  1. Configure AWS credentials for the Serverless framework.

  2. Deploy the project:

    serverless deploy

Local Testing

You can test the functions locally using the Serverless framework:

  • Preprocess Data:

    serverless invoke local --function preprocess --path mocks/preprocess.json
  • Train Models:

    serverless invoke local --function train_models --path mocks/train_models.json
  • Predict:

    serverless invoke local --function predict --path mocks/predict.json

Usage

Preprocessing Data

The preprocessing function downloads a dataset from S3, fills missing values, scales the data, and uploads the preprocessed data back to S3.

Training Models

The training function downloads the preprocessed data from S3, splits it into training and testing sets, trains multiple machine learning models, and uploads the trained models back to S3.

Making Predictions

The prediction function loads the trained models from S3, scales the user input data, and provides a prediction indicating the likelihood of heart disease.

Prediction Example

Below is an example prediction made by the system: output

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss changes.

Accuracy Result

About

Backend for heart disease prediction using machine learning. Processes data, trains models, and provides a RESTful API for predictions. Utilizes AWS S3 for storage, Lambda for serverless execution, and Serverless Framework for deployment. Handles missing data with default values for improved accuracy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published