This repository contains code and resources for predicting heart disease using machine learning and deep learning techniques. The project utilizes the Cleveland Heart Disease dataset and the Statlog (Heart) dataset to train and evaluate models for predicting the presence of heart disease.
Heart disease is one of the leading causes of death globally. Early detection and prevention are crucial in reducing mortality rates. This project aims to develop a predictive model using machine learning and deep learning techniques to identify individuals at risk of heart disease.
The Cleveland dataset is a well-known dataset for heart disease prediction and contains 303 instances with 14 attributes, including age, sex, chest pain type, resting blood pressure, serum cholesterol, fasting blood sugar, resting ECG results, maximum heart rate achieved, exercise-induced angina, oldpeak, the slope of the peak exercise ST segment, number of major vessels colored by fluoroscopy, thalassemia, and the presence of heart disease (target).
The Statlog dataset contains 270 instances with the same attributes as the Cleveland dataset, making it suitable for combining and cross-validation.
To run the project locally, follow these steps:
-
Clone the repository:
git clone https://github.com/satyacasm/Heart-Disease-Prediction.git cd Heart-Disease-Prediction
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the required packages:
pip install -r requirements.txt
-
Ensure you have the datasets (
Heart_disease_cleveland_new.csv
andheart.dat
) in the project directory. -
Run the script to train and evaluate the models:
python main.py
-
The results will be saved in the
model_results.csv
file.
The project includes the following steps:
- Data Preprocessing: Load and preprocess the Cleveland and Statlog datasets.
- Feature Scaling: Normalize the feature values using StandardScaler.
- Model Training: Train a neural network using the Jellyfish Optimization Algorithm to find the best hyperparameters.
- Model Evaluation: Evaluate the model on a test set using metrics such as accuracy, precision, recall, F1 score, and ROC AUC score.
The results of the model, including accuracy, precision, recall, F1 score, and ROC AUC score, are saved in the model_results.csv
file.
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature-name
). - Make your changes.
- Commit your changes (
git commit -am 'Add your message here'
). - Push to the branch (
git push origin feature/your-feature-name
). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.