# shafimohammad09/predicting-stroke-risk-using-machine-learning architecture

> Architecture diagram of the GitHub repository shafimohammad09/predicting-stroke-risk-using-machine-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shafimohammad09/predicting-stroke-risk-using-machine-learning
- Repository: https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning

## Overview

##### Project type and purpose
- This is a machine-learning pipeline with a lightweight Python web front end for stroke-risk prediction. The README and directory names show that the core is data ingestion, preprocessing, model training/evaluation, visualization, and finally a “front” folder serving predictions via a web API.

##### File structure
- Top-level “dataset” folder holds raw CSV.
- “main” folder contains orchestration scripts (main.py), custom helper functions, and visual reporting code.
- “milestoneX” folders break the pipeline into phases:
- milestone1.py – initial data exploration
- milestone2 – encoding & extra visualizations
- milestone3 – comparison of multiple models
- milestone4 – final pipeline adjustments
- “front” folder is a web application (front.py + webap.py) for serving the trained model.
- No external database; all data is file-based.

##### Key insights from README
- Preprocessing steps (handling missing BMI values, encoding categorical features)
- Modeling steps (Linear, Lasso, Ridge, Logistic regression)
- Visualization and evaluation metrics
- Future work (SMOTE, advanced algorithms, integration)

##### Main components
a. Data Layer
- dataset/data.csv (raw data source)
b. Preprocessing Layer
- Scripts in main/custom_function.py, milestone2/dataenco.py
- Tasks: missing-value handling, encoding
c. Feature Engineering & Pipeline Orchestration
- milestone scripts + main/main.py invoke each stage
d. Model Training & Evaluation
- milestone3/multimodelcomp.py + main/visual_main.py
- Implements regression and classification models, computes metrics
e. Visualization & Reporting
- main/visual_main.py, milestone2/visual_extra.py, presentation.pptx
- Generates distribution plots, precision-recall curves
f. Serving Layer (API & Front-end)
- front/webap.py – Flask (or FastAPI) service wrapping trained model
- front/front.py – front-end UI or CLI that calls web API

##### Relationships and interactions
- Front-end → API → Model Inference

##### Architectural patterns and design principles
- Linear pipeline (batch processing) for ML work
- Modular milestones for incremental development
- Separation of concerns: data, processing, modeling, visualization, serving

##### Technologies & libraries to call out
- Python (Pandas, NumPy, scikit-learn, Matplotlib/Seaborn)
- Flask or FastAPI for webap.py
- CSV file for data storage (no RDBMS)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Layer"
        Data[(dataset/data.csv)]:::data
    end

    subgraph "Preprocessing & Encoding"
        Custom["Custom Functions"]:::process
        Encode["Data Encoder Module"]:::process
    end

    subgraph "Feature Engineering & Orchestration"
        Explore["Initial Exploration"]:::process
        Orchestrator["Main Orchestrator"]:::process
        FinalAdj["Final Pipeline Adjustments"]:::process
    end

    subgraph "Model Training & Evaluation"
        MultiModel["Multi-Model Comparison"]:::model
        VisualMetrics["Metrics Visualization"]:::model
    end

    subgraph "Visualization & Reporting"
        ExtraVisuals["Extra Visuals"]:::viz
        Presentation["Presentation Output"]:::viz
    end

    subgraph "Serving Layer"
        API["Web API Service"]:::serv
        Frontend["Front-End Interface"]:::serv
    end

    Data -->|"raw_data.csv"| Custom
    Custom -->|"cleaned_data.csv"| Encode
    Encode -->|"encoded_data.csv"| Explore
    Explore -->|"X_features"| Orchestrator
    Orchestrator -->|"X_pipeline"| FinalAdj
    FinalAdj -->|"final_features"| MultiModel
    MultiModel -->|"trained_models"| VisualMetrics
    MultiModel -->|"model.pkl"| API
    VisualMetrics -->|"plots"| ExtraVisuals
    ExtraVisuals -->|"report_visuals"| Presentation
    API -->|"predict_request"| Frontend

    click Data "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/dataset/data.csv"
    click Custom "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/main/custom_function.py"
    click Encode "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/milestone2/dataenco.py"
    click Explore "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/milestone1.py"
    click Orchestrator "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/main/main.py"
    click FinalAdj "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/milestone4/milestone4.py"
    click MultiModel "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/milestone3/multimodelcomp.py"
    click VisualMetrics "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/main/visual_main.py"
    click ExtraVisuals "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/milestone2/visual_extra.py"
    click Presentation "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/main/presentation.pptx"
    click API "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/front/webap.py"
    click Frontend "https://github.com/shafimohammad09/predicting-stroke-risk-using-machine-learning/blob/main/front/front.py"

    classDef data fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef process fill:#90EE90,stroke:#333,stroke-width:1px
    classDef model fill:#FFA500,stroke:#333,stroke-width:1px
    classDef viz fill:#FFFF00,stroke:#333,stroke-width:1px
    classDef serv fill:#DDA0DD,stroke:#333,stroke-width:1px
```
