Datasets:
image
imagewidth (px) 800
4.17k
|
|---|
Diabetes Dataset — Exploratory Data Analysis (EDA)
This repository contains a diabetes-related tabular dataset and a complete Exploratory Data Analysis (EDA).
The main objective of this project was to learn how to conduct a structured EDA, apply best practices, and extract meaningful insights from real-world health data.
The analysis includes correlations, distributions, group comparisons, class balance exploration, and statistical interpretations that illustrate how different features relate to diabetes risk.
Project Goals
The purpose of this project is to perform a complete and structured Exploratory Data Analysis (EDA) on a large synthetic diabetes dataset. The objectives include:
- Understanding the dataset’s structure, distributions, and data quality
- Identifying key patterns and relationships between clinical, lifestyle, and demographic variables
- Using clear visualizations to present insights, trends, and comparisons
- Evaluating feature importance and understanding which factors are most strongly associated with diabetes
- Learning how to extract meaningful insights from data and communicate them effectively through visual and statistical analysis
Dataset Description
This dataset contains 100,000 synthetic patient records related to diabetes risk.
It includes demographic, lifestyle, and clinical variables commonly used in medical risk assessment.
The main features are:
- age
- bmi
- physical_activity_minutes_per_week
- diet_score
- family_history_diabetes
- glucose_fasting
- hba1c
- diabetes_risk_score
- diagnosed_diabetes (target variable)
The dataset is structured, clean, and contains no missing values, making it suitable for exploratory data analysis and modeling.
EDA Workflow Overview
This project follows a structured and professional Exploratory Data Analysis workflow.
Below is a summary of the key steps performed:
1. Initial Data Inspection
- Loaded the dataset and reviewed its structure (
.info(),.head()). - Verified column types and dataset dimensions.
- Confirmed that the dataset contains no missing values.
- Checked for duplicate rows (none were found).
2. Data Cleaning & Preprocessing
Although the dataset was already complete — with no missing values, no duplicates, and valid column formats — additional cleaning checks were performed to demonstrate good analytical practice:
Missing values check:
Confirmed zero nulls across all columns.Outlier exploration:
Identified a small number of extreme fasting-glucose values.
These outliers were not removed for the overall EDA, since they represent only ~0.02% of the dataset and do not meaningfully affect distributions or correlations.Educational outlier removal (for one specific question only):
To demonstrate correct preprocessing techniques, we removed 21 extreme glucose outliers in one analysis step only.
This did not affect the broader EDA results.Validated distributions, checked ranges, and ensured logical consistency across features.
3. Univariate Analysis
- Explored each feature independently to understand its distribution.
- Produced histograms and boxplots for age, BMI, activity levels, glucose, HbA1c, and diet score.
- Identified normal vs. skewed variables and examined clinically relevant ranges.
4. Bivariate Analysis
Investigated relationships between individual features and diabetes diagnosis:
- Grouped means and prevalence differences (
groupby) - Barplots for categorical variables
- Scatterplots & trendlines for continuous variables
- Pearson correlation matrix for numeric features
5. Multivariate Analysis
To understand combined effects of multiple risk factors:
- Built a simple logistic regression (glucose + HbA1c)
- Built a full logistic model including major predictors
- Calculated and visualized odds ratios
- Tested multicollinearity using Variance Inflation Factors (VIF)
6. Advanced Checks
- Calculated Spearman correlations for monotonic, non-linear relationships
- Compared results with Pearson to validate consistency
7. Summary & Interpretation
All insights were consolidated into clear, data-backed conclusions about the strongest predictors of diabetes and the contribution of lifestyle, demographic, and clinical variables.
Key Questions & Insights
1️⃣ How do clinical markers (Glucose & HbA1c) differ between diagnosed and non-diagnosed individuals?
Insight
- Diagnosed individuals show substantially higher fasting glucose and higher HbA1c.
- These variables are the strongest clinical indicators of diabetes in the dataset.
- Clear separation between groups appears in both distributions and boxplots.
Visualizations
1. HbA1c vs Fasting Glucose (after removing extreme outliers)
This scatterplot demonstrates the strong positive association between fasting glucose and HbA1c.
The clean linear pattern shows that both markers reflect the same underlying metabolic state and jointly act as the strongest predictors of diabetes.
2. Fasting Glucose by Diabetes Status
The boxplots show a clear separation between diabetic and non-diabetic individuals.
Both fasting glucose and HbA1c are substantially higher among those diagnosed.
3. Odds Ratios (Logistic Regression)
HbA1c shows the strongest independent effect, followed by fasting glucose.
Both are highly predictive even when controlling for other features.
4. Standardized Logistic Regression Coefficients
Standardizing both features reveals that HbA1c contributes more strongly to classification than glucose — consistent with clinical expectations.
2️⃣ Is BMI higher among individuals diagnosed with diabetes?
Insight
- The diabetes group has a slightly higher mean BMI, but the difference is modest.
- BMI is a moderate but consistent risk factor, with clear upward trends across weight classes.
1. Boxplot of BMI
The BMI distribution shows a realistic spread, with most individuals in Normal or Overweight ranges.
A few high-BMI outliers appear but do not distort the overall pattern.
2. Diabetes Rate by BMI Group and Abdominal Obesity
Diabetes rates increase across BMI categories.
Within each BMI group, individuals with abdominal obesity show slightly higher diabetes prevalence, but the effect is modest.
3️⃣ Is lower physical activity associated with diabetes?
Insight
- Individuals with diabetes engage in less weekly physical activity on average.
- The protective effect of physical activity is consistent across BMI categories, though not extremely strong.
1. BMI × Physical Activity – Diabetes Rate Heatmap
Across all BMI groups, higher physical activity levels are associated with lower diabetes prevalence.
This indicates that physical activity provides a protective effect regardless of body weight.
4️⃣ Does Age Influence Diabetes Diagnosis?
Insight
- Individuals diagnosed with diabetes tend to be older on average.
- Age shows a clear, monotonic increase in diabetes prevalence.
1. Distribution of Age
Diagnosed individuals tend to be older.
The dataset contains many middle-aged and older adults, contributing to the relatively high overall diabetes rates.
2. Diabetes Rate by Age Group
Diabetes rates increase consistently across age brackets.
Younger adults have much lower prevalence, while older groups show substantially higher rates.
5️⃣ Does diet quality differ between groups?
Insight
- Better diet quality is associated with slightly lower diabetes prevalence.
- The effect is modest, suggesting diet alone is not a strong predictor.
1. Diet Score and Diabetes Rate
Diabetes rates gradually decline as diet scores increase.
The relationship is clear but relatively small.
6️⃣ Are there demographic differences (gender, ethnicity, smoking, alcohol, income)?
Insight
Demographic and socioeconomic factors show only very small differences in diabetes prevalence.
None exhibit a meaningful or clinically relevant effect in this dataset.
No detailed visualization was added because effects were minor.
7️⃣ Does Family History Increase Diabetes Risk?
Insight
- Individuals with a family history of diabetes show a much higher diabetes rate.
- This is one of the strongest and most clinically meaningful predictors in the dataset.
1. Diabetes Rate by Family History
Individuals with a family history display substantially higher diabetes prevalence — reinforcing the importance of genetic factors.
8️⃣ What do Pearson correlations reveal about the strongest predictors?
Insight
Strongest correlations with diabetes:
- HbA1c
- Fasting glucose
- Diabetes Risk Score
- Age (moderate)
Lifestyle factors show only weak linear relationships.
1. Correlation Matrix
HbA1c and fasting glucose emerge as the strongest correlates of diabetes.
2. Feature Correlation with Diabetes (Spearman)
Spearman correlation helps detect monotonic but non-linear relationships.
Results confirm:
- HbA1c and glucose are strongest
- Age and family history contribute meaningfully
- Lifestyle factors remain weak predictors
9️⃣ What is the class balance between diagnosed and non-diagnosed participants?
Insight
- 60% diagnosed vs. 40% non-diagnosed.
- Not representative of real-world prevalence, but acceptable for EDA.
1. Class Balance Plot
🔟 Outlier Handling: Why remove glucose outliers in one analysis?
Insight
- Dataset is clean and required minimal preprocessing.
- Outliers were removed only for one visualization to improve clarity.
- Removal had no impact due to the large sample size.
1. HbA1c vs Fasting Glucose (Without Outliers)
Extreme glucose outliers (visible on the far right) were removed to improve interpretability for one specific plot.
Summary of Findings
- Clinical variables (HbA1c, glucose) are the dominant predictors of diabetes.
- Age and BMI contribute moderately.
- Lifestyle factors show small effects.
- Dataset is slightly imbalanced (60/40).
- Outlier removal was minimal and educational.
- Pearson + Spearman correlations reinforce feature importance.
If you wish to explore the analysis further, the full notebook is included in the repository.
video walkthrough
you can watch the full video walkthrough here: https://drive.google.com/file/d/1KHWK6dW7j_v_ezFjsBT2IMxAtiuxIzEI/view?usp=sharing
- Downloads last month
- 321














