In this project, we implement a system that predicts if a patient has a heart disease.
Author: Constandinos Demetriou
Copyright (c) 2021
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/
Over the past decade, heart disease, also known as cardiovascular disease, has remained the leading cause of death worldwide. An estimate from the World Health Organization is that more than 17.9 million deaths occur each year worldwide due to cardiovascular disease and of these deaths, 80% are due to coronary heart disease and stroke. Common risk factors are smoking, excessive alcohol and caffeine consumption, stress and lack of exercise along with other factors such as obesity, hypertension, high cholesterol are predisposing factors for heart disease. Effective and timely medical diagnosis of heart disease plays a crucial role in preventing death.
Machine learning is one of the fastest growing areas of AI. Machine learning algorithms can analyze a huge amount of data from various fields, one of the most important of which is the medical field. Using machine learning we can understand complex and non-linear correlations between various factors, reducing the error in the predicted results. By exploring huge data sets it is possible to extract hidden critical information for decision making. With the machine learning algorithms we can build models which we train with a set of data and after the models "learn" we can perform predictions on new data. In this work, we tested machine learning classification algorithms for predicting heart disease in patients.
This database from UCI Machine learning repository contains 76 attributes, but all published experiments refer to using a subset of 14 of them. In particular, the Cleveland database is the only one that has been used by ML researchers to this date. The "goal" field refers to the presence of heart disease in the patient. It is integer valued from 0 (no presence) to 4. Experiments with the Cleveland database have concentrated on simply attempting to distinguish presence (values 1,2,3,4) from absence (value 0).
Attribute Information:
- age
- sex
- chest pain type (4 values)
- resting blood pressure
- serum cholestoral in mg/dl
- fasting blood sugar > 120 mg/dl
- resting electrocardiographic results (values 0,1,2)
- maximum heart rate achieved
- exercise induced angina
- oldpeak = ST depression induced by exercise relative to rest
- the slope of the peak exercise ST segment
- number of major vessels (0-3) colored by flourosopy
- thal: 3 = normal; 6 = fixed defect; 7 = reversable defect
- Logistic Regression
- k-Nearest Neighbors (kNN)
- Multilayer Perceptron (MLP)
- Decision Tree
- Random Forest
- Gaussian Naive Bayes
Make sure you have python 3.8 installed in your system. The following command clone the repository.
git clone https://github.com/constandinos/heart-disease
cd heart-disease
This class creates a GUI for input data.
cd src/
python main.py
This class read the dataset and process data.
cd src/classes/
python process_dataset.py <dataset directory>
eg. python process_dataset.py ../../data/processed.cleveland.data
This class creates plots to visualize the data.
cd src/classes/
python visualization.py <dataset directory>
eg. python visualization.py ../../data/dataset.csv
This class find the best machine learning model to fit the data.
cd src/classes/
python build_model.py <dataset directory> <num of cpus>
eg. python build_model.py ../../data/dataset.csv 16