Skip to content

Commit

Permalink
Merge pull request #578 from Avdhesh-Varshney/cardio
Browse files Browse the repository at this point in the history
Cardiovascular Disease Analysis and Prediction Model
  • Loading branch information
abhisheks008 authored Feb 10, 2024
2 parents 4cdae8a + 62b59e7 commit 503f46d
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Cardiovascular Disease Analysis and Prediction/Dataset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Cardiovascular Disease Analysis and Prediction Model

The Dataset used here is taken from the Kaggle database website. You can download the file from the link given here, [Cardiovascular Disease Analysis and Prediction](https://www.kaggle.com/datasets/jocelyndumlao/cardiovascular-disease-dataset)

## About the dataset

There are 14 features and 1000 entries in this dataset.


- `patiendid` - **Patient Identification Number**
- `age` - **Age of the patient**
- `gender` - **Gender of the patient** - (0 => Female, 1 => Male)
- `chestpain` - **Chest pain type** - (0 => typical angina, 1 => atypical angina, 2 => non-anginal pain, and 3 => asymptomatic)
- `restingBP` - **Resting Blood Pressure** - (94-200 in mm HG)
- `serumcholestrol` - **Serum Cholesterol** - (126-564 in mg/dl)
- `fastingbloodsugar` - **Fasting blood sugar** - (0, 1 > 120 mg/dl) - (0 => false, 1 => true)
- `restingelectro` - **Resting electrocardiogram results** - (Value 0: normal, Value 1: having ST-T wave abnormality, and Value 2: showing probable or definite left ventricular hypertrophy by Estes' criteria)
- `maxheartrate` - **Maximum heart rate achieved** - (71-202)
- `exerciseangia` - **Exercise induced angina** - (0 => no, 1 => yes)
- `oldpeak` - **Oldpeak=ST** - (0 - 6.2)
- `slope` - **Slope of the peak exercise ST segment** - (1-upsloping, 2-flat, 3-downsloping)
- `noofmajorvessels` - **Number of major vessels** - 0, 1, 2, 3
- `target` - **Classification** - (0 => absence of heart disease, 1 => presence of heart disease)

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions Cardiovascular Disease Analysis and Prediction/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<h1>Cardiovascular Disease Analysis and Prediction</h1>

**GOAL**

The aim of this project is to analyze and predict the disease based on the given dataset.

**DATASET**

https://www.kaggle.com/datasets/jocelyndumlao/cardiovascular-disease-dataset

**DESCRIPTION**

To analyze the dataset of Cardiovascular Disease and build and train the model on the basis of different features and variables.

There are 14 features and 1000 entries in this dataset.


### Visualization and EDA of different attributes:

<img alt="heatmap" src="./Images/correlation_heatmap.png">

<img alt="graph" src="./Images/target_correlation.png">

<img alt="graph" src="./Images/age_feature.png">

<img alt="graph" src="./Images/restingrelectro_feature.png">


**MODELS USED**

| Model | MSE_train | R2_train | MSE_test | R2_test |
|-----------------------------|-----------|----------|-----------|-----------|
| Random Forest Regression | 0.002946 | 0.987915 | 0.023432 | 0.903483 |
| XG Boost Regression | 0.000002 | 0.999993 | 0.027463 | 0.886879 |
| Decision Tree Regression | 0.000000 | 1.000000 | 0.035000 | 0.855834 |
| Ridge Regression | 0.063654 | 0.738905 | 0.059288 | 0.755792 |
| Linear Regression | 0.063654 | 0.738907 | 0.059305 | 0.755721 |
| KNN Regression | 0.094450 | 0.612590 | 0.125600 | 0.482649 |
| Elastic Net Regression | 0.180585 | 0.259287 | 0.155394 | 0.359926 |



**WHAT I HAD DONE**

* Load the dataset which contains 1000 entries in it and having 14 columns in it.
* Checked for missing values and cleaned the data accordingly.
* Analyzed the data, found insights and visualized them accordingly.
* Plotting heatmap using correlation and checking the relation between different features.
* Found detailed insights of different columns with target variable using plotting libraries.
* Train the datasets by different models and saves their accuracies into a dataframe.


**LIBRARIES NEEDED**

1. Pandas
2. Matplotlib
3. Sklearn
4. NumPy
5. XGBoost
6. Sci-py
7. Seaborn


**CONCLUSION**

- Random Forest and XG Boost Regression models show promising performance with lower MSE and higher R2 values.
- Decision Tree Regression achieved perfect R2 on the training set but performed poorly on the test set, indicating overfitting.


**YOUR NAME**

*Avdhesh Varshney*

[![LinkedIn](https://img.shields.io/badge/linkedin-%230077B5.svg?style=for-the-badge&logo=linkedin&logoColor=white)](https://www.linkedin.com/in/avdhesh-varshney-5314a4233/) [![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge&logo=github&logoColor=white)](https://github.com/Avdhesh-Varshney)

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
numpy==1.19.2
pandas==1.4.3
matplotlib==3.7.1
scikit-learn~=1.0.2
scipy==1.5.0
seaborn==0.10.1
xgboost~=1.5.2

0 comments on commit 503f46d

Please sign in to comment.