Skip to content

Repository files navigation

🩺 Diabetes Prediction – Healthcare AI Systems Capstone

This project develops two production‑ready AI systems—one Machine Learning (ML) and one Deep Learning (DL)—to predict Type 2 Diabetes using structured clinical data from the Pima Indians Diabetes Dataset. The work emphasizes clinical validity, responsible AI practices, and real‑world deployment workflows.


📌 1. Project Overview

Diabetes is a rapidly growing global health challenge, affecting over 500 million adults worldwide. Early detection is critical for preventing complications such as cardiovascular disease, kidney failure, neuropathy, and blindness. However, traditional diagnostic pathways can be resource‑intensive and inaccessible in many settings.

This capstone builds two independent AI systems capable of predicting diabetes risk using routinely collected clinical variables such as:

  • Glucose
  • BMI
  • Insulin
  • Blood Pressure
  • Age
  • Pregnancy history
  • Diabetes pedigree function

The project follows a full CRISP‑DM pipeline, from data wrangling to deployment, with strong emphasis on:

  • Clinical interpretability
  • Imbalance handling
  • Ethical considerations
  • Robust evaluation
  • Real‑world deployment

📌 2. Key Features

🔬 Machine Learning System

  • Logistic Regression, Random Forest, and Gradient Boosting models
  • Hyperparameter tuning with cross‑validation
  • SMOTE, class weights, and threshold tuning
  • SHAP‑based interpretability
  • FastAPI endpoint + Streamlit UI
  • Dockerized and deployed on Render

🧠 Deep Learning System

  • Fully connected neural network with ≥3 hidden layers
  • Dropout + L2 regularization
  • Class‑weighted loss + oversampling
  • Learning curves and generalization analysis
  • FastAPI endpoint + Streamlit UI
  • Dockerized and deployed on Render

📌 3. Dataset

Source: Pima Indians Diabetes Dataset
Link: https://www.kaggle.com/datasets/uciml/pima-indians-diabetes-database/data

Target Variable:

  • Outcome (1 = diabetic, 0 = non‑diabetic)

Predictor Variables:

  • Pregnancies
  • Glucose
  • BloodPressure
  • SkinThickness
  • Insulin
  • BMI
  • DiabetesPedigreeFunction
  • Age

Important Note: Several physiological features contain zero values representing missingness. These are handled carefully during preprocessing.

├── 📁 artifacts       # ML/DL artifacts (models, scalers, etc.)
├── 📁 data            # Raw and processed datasets
├── 📁 dl_system       # Deep Learning system (API + Streamlit Client)
├── 📁 ml_system       # Machine Learning system (API + Streamlit Client)
├── 📁 models          # Trained model files
├── 📁 notebooks       # Jupyter notebooks for EDA, preprocessing, and training
├── 📁 plots           # Generated plots and visualizations
├── 📁 reports         # Reports and ethical analysis
├── 📝 FILETREE.md     # Full file structure
├── 📝 LICENSE.md      # License information
└── 📝 README.md       # Project documentation

Note: For a comprehensive view of the project structure, including all files and subdirectories, please refer to the FILETREE.md.


📌 5. Methodology (CRISP‑DM)

1. Data Wrangling

  • Replace physiologically impossible zeros with NaN
  • Median imputation for skewed variables
  • Outlier detection using IQR and clinical thresholds
  • Ensure no data leakage via pipelines

2. Exploratory Data Analysis

  • Class imbalance visualization
  • Feature distributions (stratified by Outcome)
  • Correlation heatmaps
  • Clinical insights from patterns

3. Preprocessing & Feature Engineering

  • Scaling with StandardScaler
  • Train/validation/test split (stratified)
  • Imbalance handling:
    • SMOTE
    • Random oversampling
    • Class‑weighted loss
    • Threshold tuning

4. ML System

  • Logistic Regression
  • Random Forest
  • Gradient Boosting / XGBoost
  • Hyperparameter tuning
  • SHAP interpretability

5. DL System

  • Dense neural network (≥3 layers)
  • Dropout + L2 regularization
  • Class‑weighted BCE loss
  • Early stopping
  • Learning curves

6. Deployment

  • FastAPI endpoints for ML and DL
  • Streamlit apps for interactive prediction
  • Dockerized services
  • Render deployment

📌 6. Evaluation Metrics

Primary metrics (clinical priority):

  • Recall (Sensitivity)
  • ROC‑AUC

Secondary metrics:

  • Precision
  • F1‑Score
  • PR‑AUC
  • Confusion Matrix

Clinical justification:

Missing a diabetic patient (false negative) can delay treatment and cause severe complications.
Therefore, Recall is prioritized over Accuracy.


📌 7. Deployment Links

🔗 ML System

🔗 DL System


📌 8. How to Run Locally (uv + pyproject.toml)

This project uses uv for fast and efficient dependency management. Each system component (ML/DL API & Client) maintains its own pyproject.toml for isolation.

1. Install uv

(If not already installed)

pip install uv

2. Clone the repository

git clone https://github.com/D0nG4667/Diabetes_Disease_Outcome_AI_System.git
cd Diabetes_Disease_Outcome_AI_System

3. Run the ML System

ML API:

cd ml_system/api
uv run uvicorn app:app --reload

ML Client: (Open a new terminal)

cd ml_system/client
uv run streamlit run Home.py

4. Run the DL System

DL API:

cd dl_system/api
uv run uvicorn app:app --reload

DL Client: (Open a new terminal)

cd dl_system/client
uv run streamlit run Home.py

5. Manage Dependencies

To add a package to a specific component:

cd <component_directory>
uv add <package_name>

📌 9. Ethical Considerations

  • Dataset is limited to Pima Indian women → limited demographic generalizability
  • Risk of algorithmic bias if deployed without external validation
  • Models should support—not replace—clinical judgment
  • Requires calibration and prospective evaluation before real‑world use

📌 10. References

Alghamdi, M., Al‑Muhtadi, J., & Al‑Ghamdi, A. (2017). A comparative study of machine learning algorithms for predicting diabetes. IJACSA, 8(6).

Han, L., Luo, S., Yu, J., Pan, L., Chen, S., & Yang, D. (2020). Rule extraction from SVMs for diabetes diagnosis. Healthcare, 8(3), 247.

Rahman, M. M., & Islam, M. M. (2020). Exploring machine learning approaches for diabetes prediction. Diabetes & Metabolic Syndrome, 14(5), 1021–1025.


📌 11. License

This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.

CC BY-NC 4.0

You are free to:

  • Share — copy and redistribute the material in any medium or format
  • Adapt — remix, transform, and build upon the material

Under the following terms:

  • Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made.
  • NonCommercial — You may not use the material for commercial purposes.

For more details, see the LICENSE.md file.

📩 Commercial Inquiries

For commercial licensing, custom implementations, or collaboration opportunities, please contact the author.



Made with ❤️ by Dr. Gabriel Okundaye
🌐 gabcares.xyz  |  🐙 GitHub

About

This project develops two production‑ready AI systems—one Machine Learning (ML) and one Deep Learning (DL)—to predict Type 2 Diabetes using structured clinical data from the Pima Indians Diabetes Dataset. The work emphasizes clinical validity, responsible AI practices, and real‑world deployment workflows.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages