Exploratory Data Analysis on Stroke Dataset
By: Zhe Chyuan Yeap
Tags: Python, Kaggle, Data Science, Data Cleaning, Exploratory Data Analysis

Exploratory Data Analysis

Numerical attributes

Let’s start by plotting the correlation matrix on the numerical attributes.

Fig. 6: The correlation matrix

Insight #1: It seemed like both BMI and Age were positively correlated, though the association was not strong.

For numerical attributes, histogram was plotted to discover any potential relationship between the variable and stroke. A function was created to avoid duplication of codes. It takes in the name of the column and outputs the histogram.

In addition, 100% stacked bar charts were plotted to discover any potential relationship between the variable and stroke. With little tweak, a new yet similar function was created to avoid duplication of codes. It takes in the name of the column and outputs the 100% stacked bar chart.

a) Age

Fig. 7: Histogram (top) and 100% stacked bar chart (down) of age variable.

The risk of experiencing a stroke increased as patient’s age advanced.

Insight #2: Older patient was more likely to suffer a stroke than a younger patient.

b) BMI

Fig. 8: Histogram (top) and 100% stacked bar chart (down) of bmi variable.

Percentage of patient who had BMI between 25 and 35 was the highest to suffer a stroke than patients from other groups.

Insight #3: Higher BMI does not increase the stroke risk.

c) Average glucose level

Fig. 9: Histogram (top) and 100% stacked bar chart (down) of avg_glucose_level variable.

Fig. 9 visualises that stroke incidence occurred to some patients regardless of the average glucose level measured after meal. Although there was no stroke incidence reported on the last two columns on the right, these columns were represented by only 3 patients, i.e. not significant. Nevertheless, higher proportion of patient who had average glucose level measured after meal of more than 150mg/dL (milligrams per decilitre) suffered a stroke. This observation can be explained by the presence of diabetes. Diabetes was present in patient who had reading of more than 200mg/dL. Pre-diabetes was also considered in patient if the reading was between 140–199mg/dL.

Insight #4: Diabetes is one of the risk factors for stroke occurrence and prediabetes patients have an increased risk of stroke.

2. Categorical attributes

a) Hypertension, Heart disease

Fig. 10: 100% stacked bar chars for hypertension (top) and heart_disease (down).

Insight #5: Higher proportion of patients who suffered from hypertension or heart disease experienced a stroke, all else being equal.

b) Gender, Residence type

Fig. 11: 100% stacked bar chars for gender (top) and Residence_type (down).

Insight #6: Regardless of patient’s gender, and where they stayed, they have the same likelihood to experience stroke.

3. Age-related variables

a) Work type

Fig. 12: Record grouped by work type and age (top), & 100% stacked bar chart by work type (bottom).

Fig. 12 shows an interesting observation. At first glance, proportion of patient who was self-employed and suffered a stroke was relatively higher than other categories. However, this variable was highly associated with age.

Both never worked and children categories were pretty self-explanatory. Almost non-existent stroke was recorded due to lower average age. On the other hand, the mean age of patients who were self-employed was 59.3 years old. It was the highest among all categories.

Insight #7: Work type variable was highly associated with age.

b) Ever married

Fig. 13: Record grouped by ever_married and age (top), & 100% stacked bar chart by ever_married variable (bottom).

Bottom chart of Fig. 13 shows a similar observation as the work type variable. However, the top chart displays the stark difference in mean of age of both categories.

Insight #8: Marital status variable was highly associated with age.