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.
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.
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.
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:
The data are loaded from the dataset and usefull libraries are imported.
The datasets is cleaned with necessary step. The duplicate is removed. The correlation between features are computed.
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.
Few machine learning model suits for binary classfification problem are selected and built into the pipeline such as
- Logistic regression
- K Neighbors Classifier
- Random Forest Classifier
- Support Vector Classifier
- Decision Tree Classifier
The results with the best accuracy score is K Neighbors Classifier with 84 % accuracy score. The classification report of the training is shown below.
The data is then tested with few cases.
An app to predict the chance of a person to get heart attack is then build using Streamlit.