# osamanayfeh/diabetes-prediction-xgboost-ann architecture

> Architecture diagram of the GitHub repository osamanayfeh/diabetes-prediction-xgboost-ann, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/osamanayfeh/diabetes-prediction-xgboost-ann
- Repository: https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann

## Overview

This repository is a diabetes-risk ML application comparing XGBoost with a PyTorch feedforward network. Its main workflow downloads patient data, creates leak-free train/validation/test splits, trains both models, and evaluates them on the held-out test set. A separate prediction command accepts one patient’s measurements and returns both models’ risk assessments. Training and evaluation modules are shown directly; capabilities described only in the README are represented with documented links where their implementation is not shown.

Main entry points: [`src/evaluate.py`](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/evaluate.py) (Compare models), [`src/train_ann.py`](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/train_ann.py) (Train ANN), [`src/data_preprocessing.py`](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/data_preprocessing.py) (Split and preprocess), [`src/train_xgboost.py`](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/train_xgboost.py) (Train XGBoost)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Data preparation"]
  node_preprocess["Split and preprocess"]
end

subgraph group_training["Model training"]
  node_train["Train XGBoost<br/>[train_xgboost.py]"]
  node_anntrain["Train ANN<br/>[train_ann.py]"]
  node_annmodel["ANN architecture<br/>[train_ann.py]"]
end

subgraph group_inference["Prediction and evaluation"]
  node_predict["Patient prediction<br/>[predict.py]"]
  node_evaluate["Compare models<br/>[evaluate.py]"]
end

subgraph group_artifacts["Data and artifacts"]
  node_rawdata[("Raw and split data")]
  node_modelstore[("Models and preprocessors")]
  node_results["Evaluation results"]
  node_plots["Diagnostic plots"]
end

subgraph group_common["Shared utilities"]
  node_utils["Paths and logging<br/>[utils.py]"]
end

node_user(("Analyst or clinician"))
node_dataset(("Pima dataset source"))

node_user -->|"starts workflow"| node_preprocess
node_dataset -->|"provides data"| node_preprocess
node_preprocess -->|"writes splits"| node_rawdata
node_preprocess -->|"writes scaler and medians"| node_modelstore
node_user -->|"starts training"| node_train
node_rawdata -->|"reads train and validation"| node_train
node_train -->|"saves model"| node_modelstore
node_train -->|"saves feature plot"| node_plots
node_user -->|"starts training"| node_anntrain
node_rawdata -->|"reads training splits"| node_anntrain
node_anntrain -->|"instantiates"| node_annmodel
node_anntrain -->|"saves checkpoint"| node_modelstore
node_anntrain -->|"saves loss curve"| node_plots
node_user -->|"starts evaluation"| node_evaluate
node_rawdata -->|"reads test split"| node_evaluate
node_modelstore -->|"loads trained models"| node_evaluate
node_evaluate -->|"constructs ANN"| node_annmodel
node_evaluate -->|"writes metrics"| node_results
node_evaluate -->|"writes ROC and confusion plots"| node_plots
node_user -->|"provides patient measurements"| node_predict
node_modelstore -->|"loads models and preprocessing"| node_predict
node_predict -->|"instantiates ANN"| node_annmodel
node_preprocess -->|"uses paths and seeding"| node_utils
node_train -->|"uses paths and seeding"| node_utils
node_anntrain -->|"uses paths and seeding"| node_utils
node_evaluate -->|"uses paths and logging"| node_utils
node_predict -->|"uses paths and logging"| node_utils

click node_preprocess "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/data_preprocessing.py"
click node_train "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/train_xgboost.py"
click node_anntrain "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/train_ann.py"
click node_annmodel "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/train_ann.py"
click node_predict "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/predict.py"
click node_evaluate "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/evaluate.py"
click node_rawdata "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/tree/main/data"
click node_modelstore "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/tree/main/models"
click node_results "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/tree/main/results"
click node_plots "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/tree/main/images"
click node_utils "https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/utils.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_preprocess toneBlue
class node_train,node_anntrain,node_annmodel toneAmber
class node_predict,node_evaluate toneMint
class node_rawdata,node_modelstore,node_results,node_plots toneRose
class node_utils,node_user,node_dataset toneIndigo
```

## Components

### Data preparation

- [Split and preprocess](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/data_preprocessing.py): `src/data_preprocessing.py`

### Model training

- [Train XGBoost](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/train_xgboost.py): `src/train_xgboost.py`
- [Train ANN](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/train_ann.py): `src/train_ann.py`
- [ANN architecture](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/train_ann.py): `src/train_ann.py`

### Prediction and evaluation

- [Patient prediction](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/predict.py): `src/predict.py`
- [Compare models](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/evaluate.py): `src/evaluate.py`

### Data and artifacts

- [Raw and split data](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/tree/main/data): `data`
- [Models and preprocessors](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/tree/main/models): `models`
- [Evaluation results](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/tree/main/results): `results`
- [Diagnostic plots](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/tree/main/images): `images`

### Shared utilities

- [Paths and logging](https://github.com/osamanayfeh/diabetes-prediction-xgboost-ann/blob/main/src/utils.py): `src/utils.py`

### Other components

- **Analyst or clinician**
- **Pima dataset source**

## Connections

- Analyst or clinician → Split and preprocess: starts workflow (evidence: `README.md`)
- Pima dataset source → Split and preprocess: provides data (evidence: `src/data_preprocessing.py`)
- Split and preprocess → Raw and split data: writes splits (evidence: `src/data_preprocessing.py`)
- Split and preprocess → Models and preprocessors: writes scaler and medians (evidence: `src/data_preprocessing.py`)
- Analyst or clinician → Train XGBoost: starts training (evidence: `README.md`)
- Raw and split data → Train XGBoost: reads train and validation (evidence: `src/train_xgboost.py`)
- Train XGBoost → Models and preprocessors: saves model (evidence: `src/train_xgboost.py`)
- Train XGBoost → Diagnostic plots: saves feature plot (evidence: `src/train_xgboost.py`)
- Analyst or clinician → Train ANN: starts training (evidence: `README.md`)
- Raw and split data → Train ANN: reads training splits (evidence: `src/train_ann.py`)
- Train ANN → ANN architecture: instantiates (evidence: `src/train_ann.py`)
- Train ANN → Models and preprocessors: saves checkpoint (evidence: `src/train_ann.py`)
- Train ANN → Diagnostic plots: saves loss curve (evidence: `src/train_ann.py`)
- Analyst or clinician → Compare models: starts evaluation (evidence: `README.md`)
- Raw and split data → Compare models: reads test split (evidence: `src/evaluate.py`)
- Models and preprocessors → Compare models: loads trained models (evidence: `src/evaluate.py`)
- Compare models → ANN architecture: constructs ANN (evidence: `src/evaluate.py`)
- Compare models → Evaluation results: writes metrics (evidence: `src/evaluate.py`)
- Compare models → Diagnostic plots: writes ROC and confusion plots (evidence: `src/evaluate.py`)
- Analyst or clinician → Patient prediction: provides patient measurements (evidence: `src/predict.py`)
- Models and preprocessors → Patient prediction: loads models and preprocessing (evidence: `src/predict.py`)
- Patient prediction → ANN architecture: instantiates ANN (evidence: `src/predict.py`)
- Split and preprocess → Paths and logging: uses paths and seeding (evidence: `src/data_preprocessing.py`)
- Train XGBoost → Paths and logging: uses paths and seeding (evidence: `src/train_xgboost.py`)
- Train ANN → Paths and logging: uses paths and seeding (evidence: `src/train_ann.py`)
- Compare models → Paths and logging: uses paths and logging (evidence: `src/evaluate.py`)
- Patient prediction → Paths and logging: uses paths and logging (evidence: `src/predict.py`)
