/Heart-Attack-Prediction-with-ML

The main objective of this project is to develop an app to predict the chance of a person having heart attack.

Primary LanguagePython

badge

Heart Attack Prediction with Machine Learning

1. Summary

The main objective of this project is to develop an app to predict the chance of a patient having heart attack with machine learning model.

2. Datasets

This projects is trained with Heart Attack Analysis & Prediction Dataset. The 'outcome' field refers to the presence of heart disease of the patient. It is integer valued 0 = no disease and 1 = disease.

3. Requirements

This project is created using Spyder as the main IDE. The main frameworks used in this project are Pandas, Matplotlib, Seaborn, Scikit-learn and Streamlit.

4. Methodology

This project contains two .py files. The training and deploy files are heart_attack_train.py and deploy.py respectively. The flow of the projects are as follows:

1. Importing the libraries and dataset

The data are loaded from the dataset and usefull libraries are imported.

2. Exploratory data analysis

The datasets is cleaned with necessary step. The duplicate is removed. The correlation between features are computed.

This is an image

It is shown that chest pain (cp), maximum heart rate achieved (thalach) and slope (slp) have highest corrolation with target. The data are scaled with MinMax Scaler to refine the outliers. Next, the data is splitted into 70:30 train and test ratio.

3. Machine learning model

Few machine learning model suits for binary classfification problem are selected and built into the pipeline such as

  1. Logistic regression
  2. K Neighbors Classifier
  3. Random Forest Classifier
  4. Support Vector Classifier
  5. Decision Tree Classifier

4. Model Prediction and Accuracy

The results with the best accuracy score is K Neighbors Classifier with 84 % accuracy score. The classification report of the training is shown below.

5. Deployment

The data is then tested with few cases.

6. Build the app using Streamlit

An app to predict the chance of a person to get heart attack is then build using Streamlit.