# gtzjh/mymodels architecture

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

- Interactive diagram: https://gitdiagram.com/gtzjh/mymodels
- Repository: https://github.com/gtzjh/mymodels

## Overview

##### Main Components
- Data Input Layer: Represented by the CSV files found in the “data” directory. These datasets (housing, obesity, titanic) are sample inputs for different ML tasks.
- Pipeline Controller: The “mymodels/pipeline.py” file acts as the central orchestrator that ties together the workflow.
- Modular Components:
– Data Loader Module (mymodels/_data_loader.py): It is responsible for ingesting CSV data, handling the reading of files, and preprocessing (e.g., setting index columns).
– Encoder Module (mymodels/_encoder.py): This handles categorical encoding strategies (e.g., onehot, binary, target, etc.).
– Optimizer Module (mymodels/_optimizer.py): It leverages tools such as Optuna for hyperparameter tuning.
– Evaluator Module (mymodels/_evaluator.py): This module computes and outputs accuracy metrics, plots (ROC curves, scatter plots, etc.) for performance assessment.
– Explainer Module (mymodels/_explainer.py): Integrates SHAP for interpreting model predictions with summary and dependence plots.
– Models Module (mymodels/models.py): Encapsulates the various supported machine learning models (e.g., XGBoost, RandomForest, CatBoost, etc.).
- Runner Scripts: Files like “run_housing.py”, “run_obesity.py”, and “run_titanic.py” are entry points that set up the pipeline for different types of tasks (regression, multi-class classification, binary classification).

- Once data is loaded, it passes through pre-processing modules such as encoding (handled by the Encoder module).
- The refined dataset is then forwarded by the Pipeline to the Models module. The Optimizer module supports model selection and parameter tuning during this process.
- Once the model is trained, the Evaluator module assesses model performance and handles result outputting (including saving generated metrics and plots).
- In parallel or subsequently, the Explainer module uses SHAP to add interpretability to the model outputs.
- Finally, the overall orchestration is managed by the Pipeline controller, which ensures each module is invoked in the proper order.

##### Architectural Patterns and Integration
- The project is organized in a modular fashion where each component addresses a distinct part of the machine learning workflow. This separation of concerns is analogous to a layered or pipeline design.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Runner Scripts"
        R1["run_housing.py"]
        R2["run_obesity.py"]
        R3["run_titanic.py"]
    end

    subgraph "Data Sources"
        DS["CSV Files (housing, obesity, titanic)"]
    end

    PC["Pipeline Controller"]

    subgraph "Pipeline Modules"
        DL["Data Loader Module"]
        EN["Encoder Module"]
        OP["Optimizer Module\n(Optuna)"]
        MO["Models Module\n(ML Libraries)"]
        EV["Evaluator Module"]
        EX["Explainer Module\n(SHAP)"]
    end

    R1 -->|"triggers"| PC
    R2 -->|"triggers"| PC
    R3 -->|"triggers"| PC

    DS -->|"ingest_CSV"| DL
    PC -->|"orchestrates"| DL
    DL -->|"preprocess"| EN
    EN -->|"encode"| OP
    OP -->|"tune_model"| MO
    MO -->|"evaluate"| EV
    EV -->|"explain"| EX

    click DS "https://github.com/gtzjh/mymodels/tree/main/data/"
    click PC "https://github.com/gtzjh/mymodels/blob/main/mymodels/pipeline.py"
    click DL "https://github.com/gtzjh/mymodels/blob/main/mymodels/_data_loader.py"
    click EN "https://github.com/gtzjh/mymodels/blob/main/mymodels/_encoder.py"
    click OP "https://github.com/gtzjh/mymodels/blob/main/mymodels/_optimizer.py"
    click MO "https://github.com/gtzjh/mymodels/blob/main/mymodels/models.py"
    click EV "https://github.com/gtzjh/mymodels/blob/main/mymodels/_evaluator.py"
    click EX "https://github.com/gtzjh/mymodels/blob/main/mymodels/_explainer.py"
    click R1 "https://github.com/gtzjh/mymodels/blob/main/run_housing.py"
    click R2 "https://github.com/gtzjh/mymodels/blob/main/run_obesity.py"
    click R3 "https://github.com/gtzjh/mymodels/blob/main/run_titanic.py"

    classDef runner fill:#fef3bd,stroke:#e0c080,stroke-width:2px;
    classDef source fill:#e0f7fa,stroke:#00796b,stroke-width:2px;
    classDef control fill:#d1c4e9,stroke:#673ab7,stroke-width:2px;
    classDef module fill:#fce4ec,stroke:#e91e63,stroke-width:2px;

    class R1,R2,R3 runner;
    class DS source;
    class PC control;
    class DL,EN,OP,MO,EV,EX module;
```
