# tulika105/diabetes_prediction architecture

> Architecture diagram of the GitHub repository tulika105/diabetes_prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tulika105/diabetes_prediction
- Repository: https://github.com/tulika105/diabetes_prediction

## Overview

##### Main Components
- Data Source: Represent the CSV file (diabetes_prediction_dataset.csv) as the raw data input.
- Data Preprocessing: Show a component that cleans and preprocesses the data. This stage includes handling missing values, encoding categorical features, scaling numerical ones (via StandardScaler), and applying hybrid sampling (SMOTE and under-sampling) to balance the data.
- Modeling: Illustrate the training phase where multiple machine-learning models are considered (e.g., Logistic Regression, SVM, Decision Tree, and the XGBoost classifier). Emphasize that the XGBoost model provided the best performance.
- Model Persistence: Represent the saved model (XGB.pkl) which is the output of the model training/evaluation pipeline.
- Prediction Module: Include the diabetes_predict.py component that likely serves as the interface or function for making predictions using the persisted model.
- Interactive Deployment: Highlight the deployment via Streamlit (as referenced by the provided deployment URL). This component will be the user-facing interface that accepts patient inputs to predict diabetes status.
- Notebook Exploration: Optionally note the Jupyter Notebook (Diabetes Prediction (1).ipynb) as part of exploratory data analysis, model experimentation, and evaluation steps.

##### Detailed Relationships and Interactions
- Data flows from the raw dataset (CSV) into the preprocessing phase.
- Preprocessed data is fed into the modeling/training component where several algorithms are experimented with.
- Model evaluation is performed using standard metrics (accuracy, precision, recall, F1-score) with results documented in the notebook.
- The best model (XGBoost) is serialized (using Pickle to create XGB.pkl) for later use.
- The diabetes_predict.py script utilizes the saved model to perform inference.
- Finally, the Streamlit deployment layer brings the trained model to production, allowing end users to input data and receive predictions.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Data ingestion, preprocessing, modeling, and deployment are cleanly separated, which can be depicted as distinct components.
- Reusability: Model persistence allows the trained model to be reused across multiple sessions or deployments.
- Modularity: Even though the system is small, modularity is maintained between the training (in the notebook) and the production inference (diabetes_predict.py and the Streamlit app).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Data Source (diabetes_prediction_dataset.csv)"]:::data
    subgraph "Machine Learning Pipeline"
        B["Data Preprocessing (Cleaning,Encoding,Scaling,SMOTE,Under-sampling)"]:::data
        C["Modeling (LogisticRegression,SVM,DecisionTree,XGBoost)"]:::model
        D["Model Persistence (XGB.pkl)"]:::model
        E["Prediction Module (diabetes_predict.py)"]:::model
    end
    F["Interactive Deployment (Streamlit UI)"]:::deploy
    G["Notebook Exploration (Diabetes Prediction (1).ipynb)"]:::notebook

    A -->|"to_preprocess"| B
    B -->|"train_models"| C
    C -->|"serialize"| D
    D -->|"inference_with"| E
    E -->|"deploy_via_Streamlit"| F
    C ---|"evaluate_in"| G

    click A "https://github.com/tulika105/diabetes_prediction/blob/main/diabetes_prediction_dataset.csv"
    click B "https://github.com/tulika105/diabetes_prediction/blob/main/Diabetes Prediction (1).ipynb"
    click C "https://github.com/tulika105/diabetes_prediction/blob/main/Diabetes Prediction (1).ipynb"
    click G "https://github.com/tulika105/diabetes_prediction/blob/main/Diabetes Prediction (1).ipynb"
    click D "https://github.com/tulika105/diabetes_prediction/blob/main/XGB.pkl"
    click E "https://github.com/tulika105/diabetes_prediction/blob/main/diabetes_predict.py"
    click F "https://github.com/tulika105/diabetes_prediction/blob/main/diabetes_predict.py"

    classDef data fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef model fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef deploy fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef notebook fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
```
