Learn practical skills, build real-world projects, and advance your career

Heart Attack - Data analysis

alt

A heart attack is a medical emergency. A heart attack usually occurs when a blood clot blocks blood flow to the heart. Without blood, tissue loses oxygen and dies. A heart attack occurs when the flow of blood to the heart is blocked. The blockage is most often a buildup of fat, cholesterol and other substances, which form a plaque in the arteries that feed the heart. Sometimes, a plaque can rupture and form a clot that blocks blood flow. The interrupted blood flow can damage or destroy part of the heart muscle. A heart attack, also called a myocardial infarction, can be fatal, but treatment has improved dramatically over the years. It's crucial to call 911 or emergency medical help if you think you might be having a heart attack.

The objective of this project is to provide insight about how people are affected by heart attacks and what are the conditions they face.

The dataset was taken from kaggle- Heart attack,the tools for data analysis used in this project are the packages Numpy and Pandas, and to visualize and explore the data Matplotlib and Seaborn.
Thanks to Data Analysis with Python: Zero to Pandas course I was able to learn all the tools required properly.

Features of data

  1. age - age in years

  2. sex - sex (1 = male; 0 = female)

  3. cp - chest pain type (1 = typical angina; 2 = atypical angina; 3 = non-anginal pain; 0 = asymptomatic)

  4. trestbps - resting blood pressure (in mm Hg on admission to the hospital)

  5. chol - serum cholestoral in mg/dl

  6. fbs - fasting blood sugar > 120 mg/dl (1 = true; 0 = false)

  7. restecg - resting electrocardiographic results (1 = normal; 2 = having ST-T wave abnormality; 0 = hypertrophy)

  8. thalach - maximum heart rate achieved

  9. exang - exercise induced angina (1 = yes; 0 = no)

  10. oldpeak - ST depression induced by exercise relative to rest

  11. slope - the slope of the peak exercise ST segment (2 = upsloping; 1 = flat; 0 = downsloping)

  12. ca - number of major vessels (0-3) colored by flourosopy

  13. thal - 2 = normal; 1 = fixed defect; 3 = reversable defect

  14. num - the predicted attribute - diagnosis of heart disease (angiographic disease status) (Value 0 = < diameter narrowing; Value 1 = > 50% diameter narrowing)

How to run the code

This is an executable Jupyter notebook hosted on Jovian.ml, a platform for sharing data science projects. You can run and experiment with the code in a couple of ways: using free online resources (recommended) or on your own computer.

Option 1: Running using free online resources (1-click, recommended)

The easiest way to start executing this notebook is to click the "Run" button at the top of this page, and select "Run on Binder". This will run the notebook on mybinder.org, a free online service for running Jupyter notebooks. You can also select "Run on Colab" or "Run on Kaggle".

Option 2: Running on your computer locally
  1. Install Conda by following these instructions. Add Conda binaries to your system PATH, so you can use the conda command on your terminal.

  2. Create a Conda environment and install the required libraries by running these commands on the terminal:

conda create -n zerotopandas -y python=3.8 
conda activate zerotopandas
pip install jovian jupyter numpy pandas matplotlib seaborn opendatasets --upgrade
  1. Press the "Clone" button above to copy the command for downloading the notebook, and run it on the terminal. This will create a new directory and download the notebook. The command will look something like this:
jovian clone notebook-owner/notebook-id
  1. Enter the newly created directory using cd directory-name and start the Jupyter notebook.
jupyter notebook

You can now access Jupyter's web interface by clicking the link that shows up on the terminal or by visiting http://localhost:8888 on your browser. Click on the notebook file (it has a .ipynb extension) to open it.

Downloading the Dataset

You will need your kaggle username and key to download the data

!pip install jovian opendatasets --upgrade --quiet