ABM Research Lab Data Lab / 01
Powered by ABM Group Download .py

Artificial Intelligence Assignment 01

Exploring the
Heart UCI dataset.

A compact exploratory data analysis built with Python. This report inspects the dataset, summarizes its numerical features, and visualizes age, maximum heart rate, and cholesterol across the target groups.

303patient records
14dataset columns
0missing values
4visualizations

02 / Data preview

Load and inspect the data

The CSV is loaded directly from its public GitHub source. Viewing the first ten rows confirms the column names and the kind of values stored in each feature.

Python
import pandas as pd

url = "https://raw.githubusercontent.com/sharmaroshan/Heart-UCI-Dataset/master/heart.csv"

data = pd.read_csv(url)  # Load the CSV into a Pandas DataFrame.
data.head(n=10)       # Display the first ten patient records.
Output

First 10 rows

DataFrame
#agesexcptrestbpscholfbsrestecgthalachexangoldpeakslopecathaltarget
063131452331015002.30011
137121302500118703.50021
241011302040017201.42021
356111202360117800.82021
457001203540116310.62021
557101401920114800.41011
656011402940015301.31021
744111202630117300.02031
852121721991116200.52031
957121501680117401.62021

03 / Structure

Check shape and data types

Before plotting, the dataset structure is checked for dimensions, data types, and completeness. This guards against silent errors later in the analysis.

Python
data.shape  # Return (rows, columns).

data.info() # Show data types and non-null counts.
Rows303
×
Columns14
Output · data.info()0 missing
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 303 entries, 0 to 302
Data columns (total 14 columns):

 #   Column     Non-Null   Dtype
 0   age        303        int64
 1   sex        303        int64
 2   cp         303        int64
 3   trestbps   303        int64
 4   chol       303        int64
 5   fbs        303        int64
 6   restecg    303        int64
 7   thalach    303        int64
 8   exang      303        int64
 9   oldpeak    303        float64
10   slope      303        int64
11   ca         303        int64
12   thal       303        int64
13   target     303        int64

dtypes: float64(1), int64(13)

04 / Statistics

Describe the numerical features

describe() gives the count, center, spread, and range of every numerical column. The complete output is preserved below.

Python
data.describe()  # Summarize every numerical column.
Output

Descriptive statistics

Rounded to 2 decimals
agesexcptrestbpscholfbsrestecgthalachexangoldpeakslopecathaltarget
count303.00303.00303.00303.00303.00303.00303.00303.00303.00303.00303.00303.00303.00303.00
mean54.370.680.97131.62246.260.150.53149.650.331.041.400.732.310.54
std9.080.471.0317.5451.830.360.5322.910.471.160.621.020.610.50
min29.000.000.0094.00126.000.000.0071.000.000.000.000.000.000.00
25%47.500.000.00120.00211.000.000.00133.500.000.001.000.002.000.00
50%55.001.001.00130.00240.000.001.00153.000.000.801.000.002.001.00
75%61.001.002.00140.00274.500.001.00166.001.001.602.001.003.001.00
max77.001.003.00200.00564.001.002.00202.001.006.202.004.003.001.00
0154.37 years

Average age in the dataset.

02149.65 bpm

Average maximum heart rate.

03246.26 mg/dL

Average cholesterol value.

05 / Visualization 01

Age distribution

A histogram groups the 303 ages into six equal-width intervals to reveal where most observations fall.

Python
import matplotlib.pyplot as plt

data["age"].hist(
    bins=6,
    color="#277a78",
    edgecolor="white"
)
plt.xlabel("Age")
plt.ylabel("Number of patients")
plt.title("Age distribution")
plt.show()

# Most patients are between
# 53 and 61 years old.
Figure 01Histogram · 6 bins
Histogram showing the age distribution of 303 patients
The distribution peaks around the mid-to-late fifties.

06 / Visualization 02

Maximum heart rate by target

The box plot compares the center, spread, and possible outliers of thalach for Target 0 and Target 1.

Figure 02Box plot · thalach
Box plot comparing maximum heart rate for target zero and target one
Target 1 is centered at a higher maximum heart rate.
Python
data.boxplot(
    column="thalach",
    by="target"
)
plt.xlabel("Target")
plt.ylabel(
    "Maximum heart rate achieved (bpm)"
)
plt.title(
    "Maximum Heart Rate (thalach) by Target"
)
plt.suptitle("")  # Remove default text.
plt.show()

# Target 1 has a higher median
# thalach than Target 0.

07 / Visualization 03

Age vs. maximum heart rate

Each point represents one patient. Color separates the target groups and exposes how the two variables move together.

Python
plt.scatter(
    data["age"],
    data["thalach"],
    c=data["target"],
    cmap="coolwarm",
    alpha=0.6
)
plt.xlabel("Age (years)")
plt.ylabel(
    "Maximum heart rate achieved (bpm)"
)
plt.title(
    "Age vs. Maximum Heart Rate, Colored by Target"
)
plt.show()

# Maximum heart rate tends to
# decrease as age increases.
Figure 03Scatter · colored by target
Scatter plot of age against maximum heart rate colored by target
Target 0Target 1
Older ages are generally associated with lower achieved heart rates.

08 / Visualization 04

Cholesterol by target

The final box plot adds the cholesterol analysis and uses the same target-group comparison as the heart-rate plot.

Figure 04Box plot · cholesterol
Box plot comparing cholesterol for target zero and target one
The distributions overlap substantially, with several high outliers.
Python
data.boxplot(
    column="chol",
    by="target"
)
plt.xlabel("Target")
plt.ylabel("Cholesterol (mg/dL)")
plt.title("Cholesterol by Target")
plt.suptitle("")  # Remove default text.
plt.show()

# The groups overlap strongly;
# Target 0 has a slightly higher median.

Conclusion

What the exploration shows

In this sample, Target 1 has a higher median maximum heart rate, while cholesterol values overlap strongly between the two groups. Age and maximum heart rate show a moderate negative relationship. These charts describe patterns in the sample; they do not establish medical causation.