1 of 11

Heart Disease Diagnostic Analysis

EXPLORATORY DATA ANALYSIS AND KEY FINDINGS

​

By: Raghav Kartik Bhardwaj

Dated: 27-May-2024

UNID: UMIP8460

2 of 11

Table of Contents

  • Introduction
  • Data Extraction
  • Data Transformation
  • Data Loading
  • Exploratory Data Analysis (EDA)
  • Summary Statistics
  • Visualizations
  • Key Findings
  • Conclusion
  • References

3 of 11

Introduction

  • Objective: To analyze heart disease data and identify key metrics and factors affecting heart disease.
  • Dataset: Heart disease diagnostic database from UCI Machine Learning Repository.
  • Methodology: ETL process followed by EDA using Python.

4 of 11

Data Extraction

  • Description: This section describes the process of extracting the dataset from a given CSV file.

import pandas as pd

�# Load dataset

df = pd.read_csv('heart_disease.csv')

�# Display the first few rows

df.head()

�

​

5 of 11

Data Transformation

  • Description: This section covers the data cleaning and preprocessing steps.
  • Steps:
  • Handling missing values.
  • Converting data types.
  • Encoding categorical variables.

# Data Cleaning

df.replace('?', pd.NA, inplace=True)

df = df.apply(pd.to_numeric, errors='ignore')

df.fillna(df.median(), inplace=True)

df['sex'] = df['sex'].map({0: 'female', 1: 'male'})

df['target'] = df['target'].map(lambda x: 1 if x > 0 else 0)

�# Display cleaned data

df.info()

�

​

6 of 11

Exploratory Data Analysis (EDA)

Summary Statistics

Description: Provide summary statistics for the dataset.

# Summary statistics

df.describe()

�

​

7 of 11

Visualizations

Description: Visualize the data to understand distributions and relationships.

Heart Disease by Gender:

plt.figure(figsize=(8, 6))

sns.countplot(x='sex', hue='target', data=df)

plt.title('Heart Disease by Gender')

plt.show()

�

​

8 of 11

Heart Disease by Age:

plt.figure(figsize=(10, 6))

sns.histplot(data=df, x='age', hue='target', multiple='stack')

plt.title('Heart Disease by Age')

plt.show()

�

​

9 of 11

Interactive Plots:

import plotly.express as px

�fig = px.histogram(df, x='age', color='target', marginal='box', nbins=50, title='Age Distribution by Heart Disease')

fig.show()

�fig = px.histogram(df, x='chol', color='target', marginal='box', nbins=50, title='Cholesterol Distribution by Heart Disease')

fig.show()

�

​

10 of 11

KEY FINDINGS

  • Description: Summarize the key insights from the EDA.
  • Gender and Heart Disease: Higher prevalence in males.
  • Age and Heart Disease: Older age groups have higher risk.
  • Cholesterol Levels: Elevated cholesterol associated with heart disease.
  • Blood Pressure: Higher resting blood pressure linked to heart disease.
  • Max Heart Rate: Lower max heart rate in heart disease patients.

​

11 of 11

Conclusion �

In this report, we analyzed the heart disease diagnostic dataset to identify key metrics and factors influencing heart disease. Through the ETL process and Exploratory Data Analysis (EDA), we derived the following insights:

​

Gender and Heart Disease: Males show a higher prevalence of heart disease compared to females.

Age and Heart Disease: Older individuals are at a greater risk of developing heart disease.

Cholesterol Levels: Elevated cholesterol levels are strongly associated with heart disease.

Blood Pressure: Higher resting blood pressure is linked to an increased risk of heart disease.

Max Heart Rate: Lower maximum heart rate is indicative of heart disease presence.