# terbinm/ai_class_mid_v2 architecture

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

- Interactive diagram: https://gitdiagram.com/terbinm/ai_class_mid_v2
- Repository: https://github.com/terbinm/ai_class_mid_v2

## Overview

##### Main Components
- Data Management:
- Input Data: "data/raw" for the original CSV data and "data/processed" (implied by the README, though only raw exists in the file tree) for preprocessed data.
- Data Generation/Processing: Modules in src/data (make_dataset.py and preprocess.py) are responsible for generating and cleaning the dataset.
- Feature Engineering:
- Located in src/features (build_features.py), responsible for constructing the features used in model training.
- Model Layer:
- Training and Evaluation: Located in src/models (linear_models.py, feature_selection.py, model_evaluation.py). This component deals with building, selecting, and evaluating different models.
- Models Repository: The README refers to a “models/” directory which is intended to store trained models (organized by quality parameter such as roughness, tension_strength, elongation).
- Visualization:
- Orchestration/Integration:
- The entry point "main.py" ties all these modules together to execute the ML pipeline.
- Support Components:
- Notebooks: For exploration and comparative analysis (“notebooks” folder).
- Setup and Dependencies: "setup.py" and "requirements.txt" ensure the environment is prepared properly.
- Additional Utilities: Files like "download_data.py" and "test.py" help with data acquisition and testing respectively.

##### Relationships and Interactions
- Data flows from the raw source (data/raw) into the processing modules (make_dataset.py and preprocess.py) to produce “cleaned” and split datasets.
- Preprocessed data then transitions into the feature engineering component (build_features.py), where important predictors are extracted and computed.
- Engineered features are fed into the model layer where different models (linear models, using feature selection strategies) are trained and evaluated (model_evaluation.py), with trained models being saved in the appropriate "models" sub-directory.
- The notebooks are used as an interactive layer for exploratory data analysis and to compare model performance visually.
- The main.py acts as the orchestrator that sequentially invokes data processing, feature building, modeling, and visualization routines.

##### Architectural Patterns
- Pipeline/Sequential Flow: The design represents a clear sequential machine learning pipeline from data input → preprocessing → feature engineering → model training/evaluation → visualization.
- Modularization: Each functional responsibility is encapsulated in its own module under src/ (data, features, models, visualization), enhancing maintainability and reusability.
- Separation of Concerns: The structure cleanly separates data management, modeling, and presentation logic.

##### Relevant Technologies and Frameworks
- Python ecosystem (evident from “requirements.txt” and file naming conventions).
- Likely libraries for data manipulation (pandas, numpy), machine learning (scikit-learn possibly for linear models and evaluation), and visualization (matplotlib, seaborn), although the specific libraries will be in the dependencies.
- Jupyter Notebooks for interactive exploration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Pipeline Orchestration
    Orchestrator["Pipeline Orchestration: main.py"]:::orchestration

    %% Data Management Subgraph
    subgraph "Data Management"
        A["Data Input: Raw Data CSV"]:::data
        B["Data Processing: make_dataset.py"]:::data
        C["Data Processing: preprocess.py"]:::data
        A -->|"process"| B
        B -->|"clean"| C
    end

    %% Feature Engineering Subgraph
    subgraph "Feature Engineering"
        D["Feature Engineering: build_features.py"]:::features
    end

    %% Model Layer Subgraph
    subgraph "Model Layer"
        E["Model Training: linear_models.py"]:::models
        F["Model Training: feature_selection.py"]:::models
        G["Model Evaluation: model_evaluation.py"]:::models
        H["Trained Models Repository"]:::models
        D -->|"trains"| E
        D -->|"trains"| F
        E -->|"evaluates"| G
        F -->|"evaluates"| G
        E -->|"saves"| H
        F -->|"saves"| H
    end

    %% Visualization Subgraph
    subgraph "Visualization & Results"
        I["Visualization: visualize.py"]:::visualization
        J["Results Directory"]:::data
        G -->|"feeds"| I
        G -->|"stores"| J
    end

    %% Support Utilities Subgraph
    subgraph "Support Utilities"
        K["Data Acquisition: download_data.py"]:::support
        L["Testing: test.py"]:::support
        M["Environment Setup: setup.py"]:::support
        O["Environment Setup: requirements.txt"]:::support
        N["Exploratory Analysis: notebooks"]:::support
    end

    %% Connecting Pipeline Flow
    Orchestrator -->|"initiates"| A
    C -->|"prepares"| D

    %% Styles
    classDef data stroke:#1f77b4,fill:#aec7e8,stroke-width:2px;
    classDef features stroke:#ff7f0e,fill:#ffbb78,stroke-width:2px;
    classDef models stroke:#2ca02c,fill:#98df8a,stroke-width:2px;
    classDef visualization stroke:#d62728,fill:#ff9896,stroke-width:2px;
    classDef orchestration stroke:#9467bd,fill:#c5b0d5,stroke-width:2px;
    classDef support stroke:#8c564b,fill:#c49c94,stroke-width:2px;

    %% Click Events
    click A "https://github.com/terbinm/ai_class_mid_v2/blob/master/data/raw/3d_printing_data.csv"
    click B "https://github.com/terbinm/ai_class_mid_v2/blob/master/src/data/make_dataset.py"
    click C "https://github.com/terbinm/ai_class_mid_v2/blob/master/src/data/preprocess.py"
    click D "https://github.com/terbinm/ai_class_mid_v2/blob/master/src/features/build_features.py"
    click E "https://github.com/terbinm/ai_class_mid_v2/blob/master/src/models/linear_models.py"
    click F "https://github.com/terbinm/ai_class_mid_v2/blob/master/src/models/feature_selection.py"
    click G "https://github.com/terbinm/ai_class_mid_v2/blob/master/src/models/model_evaluation.py"
    click I "https://github.com/terbinm/ai_class_mid_v2/blob/master/src/visualization/visualize.py"
    click Orchestrator "https://github.com/terbinm/ai_class_mid_v2/blob/master/main.py"
    click H "https://github.com/terbinm/ai_class_mid_v2/tree/master/models/"
    click K "https://github.com/terbinm/ai_class_mid_v2/blob/master/download_data.py"
    click L "https://github.com/terbinm/ai_class_mid_v2/blob/master/test.py"
    click M "https://github.com/terbinm/ai_class_mid_v2/blob/master/setup.py"
    click O "https://github.com/terbinm/ai_class_mid_v2/blob/master/requirements.txt"
    click N "https://github.com/terbinm/ai_class_mid_v2/tree/master/notebooks"
```
