Lab2: Univariate Analysis

Course: INF-604: Data Analysis I
Lecturer: Sothea HAS, PhD


Objective: In this lab, you will explore the columns of a dataset according to their data types. Your task is to employ various techniques, including statistical values and graphical representations, to understand the dataset before conducting deeper analysis.


1. Kaggle Heart Failure Dataset

Cardiovascular diseases (CVDs) are the leading cause of death globally, taking an estimated 17.9 million lives each year (WHO). CVDs are a group of disorders of the heart and blood vessels and include coronary heart disease, cerebrovascular disease, rheumatic heart disease and other conditions. More than four out of five CVD deaths are due to heart attacks and strokes, and one third of these deaths occur prematurely in people under 70 years of age. Heart failure is a common event caused by CVDs and this dataset contains 11 features that can be used to predict a possible heart disease.

The following Heart Failure dataset is obtained by combining 5 different heart disease datasets, consisting of 11 features and a target column indicating heart disease status of the patients. We will build a classification model to predict the heart status of the patients.

We will explore Kaggle Heart Failure Dataset. Load the dataset into the environment.

Code
import kagglehub
import pandas as pd

# Download latest version
path = kagglehub.dataset_download("fedesoriano/heart-failure-prediction")
data = pd.read_csv(path + "/heart.csv")
data.head()
Age Sex ChestPainType RestingBP Cholesterol FastingBS RestingECG MaxHR ExerciseAngina Oldpeak ST_Slope HeartDisease
0 40 M ATA 140 289 0 Normal 172 N 0.0 Up 0
1 49 F NAP 160 180 0 Normal 156 N 1.0 Flat 1
2 37 M ATA 130 283 0 ST 98 N 0.0 Up 0
3 48 F ASY 138 214 0 Normal 108 Y 1.5 Flat 1
4 54 M NAP 150 195 0 Normal 122 N 0.0 Up 0

A. What’s the dimension of the data? Which variables are considered quantitative and which are qualitative?

# To do

Answer: . . .

B. Qualitative variables:

  • Create statistical summary of column ChestPainType. Describe it.

  • Create statistical summary of other qualitative columns. Describe them and get to know your data more.

  • Create graphical representation of these qualitative columns to understand them better.

  • Get to know your data better by answering the following questions:

    • Which chest pain category is the most frequent?
    • Are the heart disease cases balanced across the dataset?
    • What percentage of the patients are diabetic?
    • What percentage of patients experience chest pain during exercise?

C. Quantitative variables:

  • Create statistical summary of column age. Describe it briefly.

  • Create stistical summary for all other quantitative columns and try to understand those columns.

  • Create graphical representation of these quantitative columns to confirm your thoughts from the previous questions and understand them better.

  • Are there any columns with outliers? How about weird data points?

Further Reading