Diabetes Prediction Analysis

Python
Machine Learning
Healthcare
Author

Emi Rivera

Published

March 17, 2026

Overview

In this project, I analyzed the Pima Indians Diabetes Dataset to explore risk factors associated with diabetes and built a machine learning model to predict diabetes outcomes.

Dataset

The dataset contains 768 patients with 9 features including glucose levels, BMI, age, and blood pressure.

Key Findings

  • Glucose is the strongest predictor of diabetes (correlation: 0.47)
  • Diabetic patients have significantly higher BMI (median ~35 vs ~30)
  • Diabetic patients tend to be older (median age ~36 vs ~27)

Visualizations

Glucose Distribution

BMI and Age Analysis

Correlation Heatmap

Machine Learning Model

Using Logistic Regression with an 80/20 train/test split, the model achieved 74.68% accuracy in predicting diabetes outcomes.

Statistical Analysis

To validate the findings, I conducted t-tests comparing diabetic and non-diabetic groups.

Statistical Significance

Key findings:

  • Glucose showed the strongest difference (p < 0.0001) by far the most important predictor
  • BMI and Age were also highly significant (p < 0.0001)
  • Insulin was significant (p = 0.0003)
  • BloodPressure was the only non-significant feature (p = 0.0715) This is suggesting it may not be a reliable standalone diagnostic indicator

PCA Analysis

PCA applied to key clinical features reveals partial separation between diabetic and non-diabetic patients.

PCA of Diabetes Clinical Features

PC1 and PC2 together explain 49.5% of the variance. Compared to the PCOS dataset, the separation between groups is less distinct, reflecting the more complex and multifactorial nature of diabetes.

Tools Used

  • Python, pandas, matplotlib, seaborn, scikit-learn

View full code on GitHub