# sayandeep02/state-of-charge-soc-estimation-using-machine-learning architecture

> Architecture diagram of the GitHub repository sayandeep02/state-of-charge-soc-estimation-using-machine-learning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sayandeep02/state-of-charge-soc-estimation-using-machine-learning
- Repository: https://github.com/sayandeep02/state-of-charge-soc-estimation-using-machine-learning

## Overview

##### Main Components
- Data Sources and Ingestion:
- The “data” folder includes CSV files divided into training, validation, and testing sets.
- The dataset is prepared through the “dataset.py” module.
- Data Preprocessing and Utilities:
- The code in “custom.py”, “libraries.py”, and “utils.py” handles preprocessing, feature normalization/standardization, and other utility functions.
- Model Definitions and Storage:
- The “models” directory contains pre-trained models saved as .sav (for scikit-learn based models) and .keras (for the neural network).
- The machine learning pipelines, including training configuration and model evaluations, are mainly referenced from the “soc_estimation.ipynb” notebook.
- Visualization and Analysis:
- Experimentation/Execution:
- The main flow of experiments and SOC estimation is demonstrated in the notebook (“soc_estimation.ipynb”) and supported by associated scripts.

##### Relationships and Interactions
- Data Flow:
- Raw CSV data from the “data” directory is ingested, preprocessed (e.g., normalization, handling of outliers and missing values) and then fed into various model training modules.
- Model Training Flow:
- Preprocessed data passes to each modeling component (Linear Regression, Decision Tree, KNN, MLP-FNN).
- Each model might use its own defined parameters and algorithms, possibly referencing external libraries such as scikit-learn and TensorFlow (for the neural network).
- Model Evaluation and Metrics:
- There’s a clear flow from training to evaluation. After model training, predictions are compared to actual values, and metrics (MSE, MAE, etc.) are computed (as seen in the multiple graphs and images).
- Visualization:
- The outputs (e.g., observed vs predicted plots and SHAP visualization) reflect the system’s evaluation stage.
- Persistence:
- Trained models are saved in the “models” folder for future inference or analysis.

##### Incorporate Important Architectural Patterns and Technologies
- Data Layer: Includes data ingestion and preprocessing (modules like “dataset.py” and “utils.py”) on top of raw CSVs.
- Processing Layer: Implements various supervised learning algorithms using standard ML libraries (scikit-learn for regression and decision trees; TensorFlow/Keras for the neural network).
- Visualization & Analysis Layer: Uses plotting libraries (Plotly, Matplotlib, Seaborn) to display distributions, performance metrics, and model explainability (SHAP).
- Modularity: The project splits functions into logically separated modules (for data handling, modeling, and utility functions), ensuring ease of maintenance and experimentation.
- External Dependencies: Leverages popular Python libraries such as NumPy, Pandas, TensorFlow, scikit-learn, and visualization libraries.

##### Elements
- “Preprocessing & Feature Engineering” (supported by “custom.py”, “utils.py”, “dataset.py”)
- “Machine Learning Models” with sub-components:
- “Linear Regression Model”
- “Decision Tree Regression”
- “K-Nearest Neighbors Regression”
- “MLP-FNN (Neural Network)” – include activation functions and optimizer details as noted in the README.
- “Model Evaluation & Metrics” (including performance graphs and metrics)
- “Explainable AI (SHAP Analysis)”
- From raw data to preprocessing, then to modeling, and finally to evaluation and visualization.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Data Layer
    subgraph "Data Layer"
        DI["Data Ingestion\n(Raw CSV Files)"]:::data
        DS["Dataset Preparation\n(dataset.py)"]:::data
    end
    DI --> DS

    %% Preprocessing & Utilities Layer
    subgraph "Preprocessing & Utilities"
        C["Preprocessing Module\n(custom.py)"]:::preprocessing
        L["Libraries\n(libraries.py)"]:::preprocessing
        U["Utilities\n(utils.py)"]:::preprocessing
    end
    DS --> C
    DS --> L
    DS --> U

    %% Aggregated Preprocessed Data Node
    PP["Preprocessed Data"]:::preprocessing
    C --> PP
    L --> PP
    U --> PP

    %% Experimentation/Execution Pipeline
    EP["Experimentation/Execution Pipeline\n(soc_estimation.ipynb)"]:::experiment
    PP --> EP

    %% Machine Learning Models Subsystem
    subgraph "Machine Learning Models"
        LR["Linear Regression Model"]:::model
        DTR["Decision Tree Regression"]:::model
        KNN["K-Nearest Neighbors Regression"]:::model
        MLP["MLP-FNN (Neural Network)\n(1 input:5, Hidden:256,256,128)"]:::model
    end
    EP --> LR
    EP --> DTR
    EP --> KNN
    EP --> MLP

    %% Model Definitions & Storage
    MS["Model Definitions & Storage\n(models directory)"]:::model
    LR --> MS
    DTR --> MS
    KNN --> MS
    MLP --> MS

    %% Model Evaluation & Metrics
    ME["Model Evaluation & Metrics"]:::evaluation
    MS --> ME

    %% Explainable AI Component
    EA["Explainable AI\n(SHAP Analysis)"]:::evaluation
    ME --> EA

    %% Visualization & Analysis Layer
    VIS["Visualization & Analysis"]:::visualization
    EA --> VIS

    %% Click Events
    click DI "https://github.com/sayandeep02/state-of-charge-soc-estimation-using-machine-learning/tree/master/LGHG2@n10C_to_25degC/data"
    click DS "https://github.com/sayandeep02/state-of-charge-soc-estimation-using-machine-learning/blob/master/LGHG2@n10C_to_25degC/dataset.py"
    click C "https://github.com/sayandeep02/state-of-charge-soc-estimation-using-machine-learning/blob/master/LGHG2@n10C_to_25degC/custom.py"
    click L "https://github.com/sayandeep02/state-of-charge-soc-estimation-using-machine-learning/blob/master/LGHG2@n10C_to_25degC/libraries.py"
    click U "https://github.com/sayandeep02/state-of-charge-soc-estimation-using-machine-learning/blob/master/LGHG2@n10C_to_25degC/utils.py"
    click EP "https://github.com/sayandeep02/state-of-charge-soc-estimation-using-machine-learning/blob/master/LGHG2@n10C_to_25degC/soc_estimation.ipynb"
    click MS "https://github.com/sayandeep02/state-of-charge-soc-estimation-using-machine-learning/tree/master/LGHG2@n10C_to_25degC/models"
    click VIS "https://github.com/sayandeep02/state-of-charge-soc-estimation-using-machine-learning/tree/master/LGHG2@n10C_to_25degC/images"

    %% Classes for styling
    classDef data fill:#AED581,stroke:#555,stroke-width:2px;
    classDef preprocessing fill:#81D4FA,stroke:#555,stroke-width:2px;
    classDef experiment fill:#FFCC80,stroke:#555,stroke-width:2px;
    classDef model fill:#FFF59D,stroke:#555,stroke-width:2px;
    classDef evaluation fill:#F48FB1,stroke:#555,stroke-width:2px;
    classDef visualization fill:#CE93D8,stroke:#555,stroke-width:2px;
```
