Early-Stage Diabetes Risk Prediction
Supervised machine learning on questionnaire-based patient data (UCI, 520 records) to predict early-stage diabetes risk. A Random Forest reached 96.1% test accuracy (F1 0.94), well ahead of a Logistic Regression baseline (80.4%, F1 0.76).
External links have not been published for this project.
Overview
A complete supervised learning pipeline on the UCI Early Stage Diabetes Risk Prediction dataset, collected at Sylhet Diabetes Hospital, Bangladesh: exploratory data analysis, preprocessing, model training, GridSearchCV hyperparameter tuning, evaluation and feature-importance analysis, written up as a full report with a literature review.
The problem
Early detection of diabetes is hard for people who are not regularly screened, and many prediction systems depend on clinical data that may not be available. The goal was a reliable model that predicts diabetes risk from simple, non-invasive questionnaire answers (age, gender and 14 yes/no symptoms such as polyuria and polydipsia).
Objectives
- Explore the dataset's characteristics and distributions through EDA
- Apply suitable preprocessing: duplicate removal, missing-value handling, encoding and outlier treatment
- Train and compare Logistic Regression and Random Forest classifiers
- Evaluate with accuracy, precision, recall and F1-score, and identify the most important predictors
Intended users
Early screening and clinical decision-support settings
Features
- EDA: class distribution, age distribution and outliers, symptom frequencies and correlation analysis
- Removal of 269 duplicate records (520 → 251 unique samples)
- Simulated missing values handled with median (age) and mode (gender) imputation
- Categorical encoding and IQR-based capping of age outliers
- Stratified 80/20 train/test split, 5-fold cross-validation and class weighting for the imbalance
- GridSearchCV hyperparameter tuning and Random Forest feature importance
Architecture & implementation
Python (pandas, scikit-learn) in a Jupyter notebook. Logistic Regression (class-weighted) as an interpretable baseline and a Random Forest ensemble, evaluated on a stratified 80/20 split with 5-fold cross-validation and tuned with GridSearchCV. PCA was deliberately not used: with 16 mostly binary features, it would cost interpretability without benefit, so Random Forest feature importance was used instead.
My contribution
Individual assignment for CCS2213 Machine Learning (Semester 2, 2025/2026) at Albukhary International University, under Professor Dr. Zurinahni Zainol.
Challenges & solutions
Challenge
269 of the 520 records were exact duplicates, which would inflate results and cause overfitting.
Solution
Removed them before modelling, leaving 251 unique samples.
Challenge
Class imbalance (68.9% positive in the de-duplicated data).
Solution
Stratified train/test splitting, class weighting for Logistic Regression, and evaluation with precision, recall and F1 rather than accuracy alone.
Challenge
Outliers in the Age feature.
Solution
Capped using the interquartile range (IQR) method.
Outcomes & evaluation
Before tuning: Random Forest 96.1% accuracy (precision 0.94, recall 0.95, F1 0.94) against Logistic Regression 80.4% (F1 0.76), with about 94% cross-validation accuracy for Random Forest. After GridSearchCV tuning: Random Forest 92.2% (F1 0.93) and Logistic Regression 82.4% (F1 0.78). Random Forest was selected as the best model. The most important predictors were Polyuria (23%), Polydipsia (18%) and Age (15%), consistent with known diabetes symptoms.
Lessons learned
- Duplicate removal matters: over half of this dataset's records were duplicates
- Ensembles like Random Forest capture non-linear symptom interactions that a linear baseline misses
- With only 251 unique samples the test set is small (about 51 records), so single-split accuracy figures vary noticeably; cross-validation gives a steadier estimate
- In healthcare settings, interpretable feature importance can matter more than reducing dimensions
Continue reading
AI / Machine Learning
ThreatLens AI — Explainable Phishing URL Detection
A web application that classifies a submitted URL as likely benign, suspicious or high risk with a trained machine-learning model, explains exactly why, and gives proportionate safety guidance — without ever contacting the destination website.
Case studyAI / Machine Learning
Student Performance Prediction
A Linear Regression model on a 1,000-record dataset achieving R² = 0.8875 and MAE = 4.07, benchmarked against a tuned Random Forest (R² = 0.860).
Case study