# enimo/dnn_mtl_predict architecture

> Architecture diagram of the GitHub repository enimo/dnn_mtl_predict, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/enimo/dnn_mtl_predict
- Repository: https://github.com/enimo/dnn_mtl_predict

## Overview

##### Main Components

a) Data Layer:
- Input Data Source (CSV files)
- Data Preprocessing Components
- StandardScaler (represented by scaler.pkl)
- Encoder (represented by encoder.pkl)

b) Model Layer:
- Multi-Task Learning Neural Network
- Shared Layers
- Task-Specific Layers for:
- Travel Mode Prediction
- Travel Purpose Prediction
- Number of Stops Prediction
- Model Weights Storage (traffic_model.pth)

c) Application Layer:
- Training Pipeline
- Inference Pipeline
- API/Interface Layer

##### Component Relationships

- Data Flow: Raw Data → Preprocessing → Model → Predictions
- Training Flow: Training Data → Preprocessors → Model Training → Model Artifacts
- Inference Flow: Input Features → Preprocessed Features → Model Inference → Predictions

##### Specific Design Elements

- Rectangles: Data storage components (CSV, PKL, PTH files)
- Hexagons: Processing components (Scalers, Encoders)
- Rounded rectangles: Neural network components
- Diamonds: Decision points/splits

- Blue: Data components
- Green: Processing/transformation components
- Orange: Model components
- Purple: Output/prediction components

##### Detailed Component Specifications

- Input layer (6 features)
- Shared hidden layers
- Three separate output branches for:
- Travel mode prediction
- Travel purpose prediction
- Number of stops prediction

##### Key Processes to Highlight

a) Training Process:
- Data loading from CSV
- Feature standardization
- Model training
- Model saving

b) Inference Process:
- Feature input
- Preprocessing
- Model prediction
- Output generation

##### Technical Details

Annotations for:
- Python/PyTorch framework
- Key libraries (torch, sklearn)
- File formats (CSV, PKL, PTH)
- Input/output specifications

##### Additional Elements

Include:
- Version information
- Input/output specifications
- Environment requirements

Remember to emphasize:
- The multi-task nature of the model
- The shared vs. task-specific components
- The preprocessing pipeline
- The distinction between training and inference flows

This will provide a clear understanding of how the system processes data, trains the model, and generates predictions for the three different tasks.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Data_Layer
        InputData["Input Data Source"]:::data
        StandardScaler["StandardScaler"]:::processor
        Encoder["Encoder"]:::processor
        PreprocessedData["Preprocessed Data"]:::data
    end

    subgraph Model_Layer
        SharedLayers["Shared Neural Layers"]:::model
        
        subgraph TaskSpecific["Task-Specific Layers"]
            TravelMode["Travel Mode Branch"]:::model
            TravelPurpose["Travel Purpose Branch"]:::model
            StopsPred["Stops Prediction Branch"]:::model
        end
        
        ModelWeights["Model Weights"]:::storage
        BestModelWeights["Best Model Weights"]:::storage
    end

    subgraph Application_Layer
        TrainingPipeline["Training Pipeline"]:::process
        InferencePipeline["Inference Pipeline"]:::process
        EnvConfig["Environment Config"]:::config
        StartupScript["Startup Script"]:::script
    end

    %% Data Flow
    InputData --> StandardScaler
    InputData --> Encoder
    StandardScaler --> PreprocessedData
    Encoder --> PreprocessedData
    PreprocessedData --> SharedLayers
    
    SharedLayers --> TravelMode
    SharedLayers --> TravelPurpose
    SharedLayers --> StopsPred
    
    TravelMode --> ModelWeights
    TravelPurpose --> ModelWeights
    StopsPred --> ModelWeights
    
    ModelWeights --> BestModelWeights
    
    PreprocessedData --> TrainingPipeline
    TrainingPipeline --> ModelWeights
    ModelWeights --> InferencePipeline

    %% Click Events
    click InputData "https://github.com/enimo/dnn_mtl_predict/blob/main/traffic_train_data.csv"
    click StandardScaler "https://github.com/enimo/dnn_mtl_predict/blob/main/scaler.pkl"
    click Encoder "https://github.com/enimo/dnn_mtl_predict/blob/main/encoder.pkl"
    click ModelWeights "https://github.com/enimo/dnn_mtl_predict/blob/main/traffic_model.pth"
    click BestModelWeights "https://github.com/enimo/dnn_mtl_predict/blob/main/best_traffic_model.pth"
    click TrainingPipeline "https://github.com/enimo/dnn_mtl_predict/blob/main/train.py"
    click InferencePipeline "https://github.com/enimo/dnn_mtl_predict/blob/main/test.py"
    click EnvConfig "https://github.com/enimo/dnn_mtl_predict/blob/main/requirements.txt"
    click StartupScript "https://github.com/enimo/dnn_mtl_predict/blob/main/start.sh"

    %% Styling
    classDef data fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef processor fill:#98FB98,stroke:#333,stroke-width:2px
    classDef model fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef storage fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef process fill:#F0E68C,stroke:#333,stroke-width:2px
    classDef config fill:#E6E6FA,stroke:#333,stroke-width:2px
    classDef script fill:#FFB6C1,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Data Components]:::data
        L2[Processors]:::processor
        L3[Model Components]:::model
        L4[Storage]:::storage
        L5[Processes]:::process
        L6[Configuration]:::config
        L7[Scripts]:::script
    end
```
