Heart Disease Diagnostic Analysis
EXPLORATORY DATA ANALYSIS AND KEY FINDINGS
By: Raghav Kartik Bhardwaj
Dated: 27-May-2024
UNID: UMIP8460
Table of Contents
Introduction
Data Extraction
import pandas as pd
�# Load dataset
df = pd.read_csv('heart_disease.csv')
�# Display the first few rows
df.head()
�
Data Transformation
# 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()
�
Exploratory Data Analysis (EDA)
Summary Statistics
Description: Provide summary statistics for the dataset.
# Summary statistics
df.describe()
�
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()
�
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()
�
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()
�
KEY FINDINGS
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.