# behrad-h/transportation-mode-detection architecture

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

- Interactive diagram: https://gitdiagram.com/behrad-h/transportation-mode-detection
- Repository: https://github.com/behrad-h/transportation-mode-detection

## Overview

##### Data Flow Representation

- Raw GPS data → TMD Datalog
- TMD Datalog → Feature Engineering
- Feature Engineering → Processed Datasets
- Processed Datasets → Model Training/Optimization
- Model Training → Trained Model
- Trained Model → Detection Engine
- Testing Data → Detection Engine
- Detection Engine → Predictions

##### Important Elements

- Distance
- Speed metrics (Speed, Avg Speed, Max Speed, Speed Percentiles)
- Acceleration metrics (Acceleration, Avg Acceleration, Std Deviation)

- Algorithm: Decision Tree
- Optimization Methods: Pre-pruning, Post-pruning
- Performance Metrics: Accuracy, F1 Score, Precision, Recall

- Walk
- Car
- Bus
- Bike
- Subway

##### Technical Details

- File formats (CSV, PKL)
- Key libraries used (Scikit-learn)
- Data transformation steps
- Model persistence mechanism

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Data_Processing_Layer
        InputData[Raw GPS Data]
        RawStorage[("Raw Data Storage")]:::storage
        FeatureEng[Feature Engineering]:::processing
        ProcessedStorage[("Processed Datasets")]:::storage
    end

    subgraph Model_Layer
        ModelTraining[Model Training]:::model
        ModelOpt[Model Optimization]:::model
        FeatureOpt[Feature Optimization]:::model
        TrainedModel[("Trained Model")]:::storage
    end

    subgraph Detection_Layer
        DetectionEngine[Detection Engine]:::processing
        TestData[Testing Dataset]:::data
        Predictions[Output Predictions]:::output
    end

    subgraph Feature_Details
        Features["Features Computed:
        - Distance
        - Speed Metrics
        - Acceleration Metrics"]:::info
    end

    subgraph Model_Details
        ModelInfo["Model Details:
        - Decision Tree Algorithm
        - Pre/Post-pruning
        - Performance Metrics"]:::info
    end

    subgraph Transport_Modes
        Modes["Transportation Modes:
        - Walk
        - Car
        - Bus
        - Bike
        - Subway"]:::info
    end

    InputData --> RawStorage
    RawStorage --> FeatureEng
    FeatureEng --> ProcessedStorage
    ProcessedStorage --> ModelTraining
    ProcessedStorage --> ModelOpt
    ProcessedStorage --> FeatureOpt
    ModelTraining --> TrainedModel
    ModelOpt --> TrainedModel
    FeatureOpt --> FeatureEng
    TrainedModel --> DetectionEngine
    TestData --> DetectionEngine
    DetectionEngine --> Predictions

    click RawStorage "https://github.com/Behrad-H/Transportation-Mode-Detection/tree/main/TMD Datalog/"
    click FeatureEng "https://github.com/Behrad-H/Transportation-Mode-Detection/blob/main/dataset_builder.py"
    click ProcessedStorage "https://github.com/Behrad-H/Transportation-Mode-Detection/tree/main/TMD_Datasets/"
    click ModelTraining "https://github.com/Behrad-H/Transportation-Mode-Detection/blob/main/model_training.ipynb"
    click ModelOpt "https://github.com/Behrad-H/Transportation-Mode-Detection/blob/main/model_optimization.ipynb"
    click FeatureOpt "https://github.com/Behrad-H/Transportation-Mode-Detection/blob/main/features_optimization.ipynb"
    click TrainedModel "https://github.com/Behrad-H/Transportation-Mode-Detection/blob/main/finalized_model.pkl"
    click DetectionEngine "https://github.com/Behrad-H/Transportation-Mode-Detection/blob/main/detections.py"
    click TestData "https://github.com/Behrad-H/Transportation-Mode-Detection/blob/main/TMD_Detection_Testing/TMD_testing_dataset.csv"
    click Predictions "https://github.com/Behrad-H/Transportation-Mode-Detection/blob/main/TMD_Detection_Testing/TMD_testing_predictions.txt"

    classDef storage fill:#3498db,stroke:#2980b9,stroke-width:2px
    classDef processing fill:#2ecc71,stroke:#27ae60,stroke-width:2px
    classDef model fill:#f1c40f,stroke:#f39c12,stroke-width:2px
    classDef output fill:#e74c3c,stroke:#c0392b,stroke-width:2px
    classDef data fill:#95a5a6,stroke:#7f8c8d,stroke-width:2px
    classDef info fill:#ecf0f1,stroke:#bdc3c7,stroke-width:2px
```
