# haktanpolatt/federated-learning-on-weather-station-data architecture

> Architecture diagram of the GitHub repository haktanpolatt/federated-learning-on-weather-station-data, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/haktanpolatt/federated-learning-on-weather-station-data
- Repository: https://github.com/haktanpolatt/federated-learning-on-weather-station-data

## Overview

##### Project type and purpose
- This is a research-oriented machine-learning project that implements and evaluates federated learning algorithms on weather-station datasets.
- The goal is to compare classical tree-based models (Decision Tree, Random Forest, XGBoost) under two federated scenarios, using Python scripts and a Jupyter notebook.

##### File structure
- Top-level folders:
- Data/ – raw CSV data for local “clients” (weather stations)
- Papers/ – reference material (does not participate in runtime)
- Top-level files:
- Scenario-*.py – orchestrate client-side training and server-side aggregation for each model and scenario
- RandomForest.ipynb – exploratory analysis and visualization of federated runs
- README.md, CHANGELOG.md, .gitattributes, .vscode (IDE config)

##### Components
a. Main components
- Data Sources (weather station CSVs)
- Client-side Training Modules (scripts for DecisionTree, RandomForest, XGBoost)
- Federated Orchestrator / Server (aggregation logic in each Scenario-*.py)
- Central Model Store (holds the global model parameters)
- Evaluation & Visualization (RandomForest.ipynb, logs)
- Configuration / Scripts Repo (the Git repo itself)
b. Relationships & interactions
1. The Federated Orchestrator reads a list of Data Sources.
2. Each Client-side Training Module loads its assigned CSV, trains a local model, and serializes model parameters.
3. The Orchestrator collects parameters from all clients and performs aggregation (e.g., averaging).
4. The new global model is redistributed to clients for the next round.
5. After convergence, the global model is evaluated; results are visualized in the Jupyter Notebook.
c. Architectural patterns / design principles
- Federated Learning pattern: decoupling data storage (clients) from a central parameter server.
- Modular script organization: one script per model and scenario.
- Separation of concerns: data folder vs. code vs. research artifacts (papers).
d. Relevant technologies & libraries
- Python 3.x runtime
- scikit-learn (DecisionTree, RandomForest)
- XGBoost
- pandas / numpy for data handling
- Jupyter for interactive analysis

##### Detail without overthinking
- Scenario script as a distinct client-model pair if granular detail is desired.
- Data/ folder feeding into clients, and the Notebook pulling from the Central Model Store.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Sources"
        Data["Data/"]:::data
    end

    subgraph "Client Training Modules"
        DT1["Scenario-1-DecisionTree.py"]:::client
        DT2["Scenario-2-DecisionTree.py"]:::client
        RF1["Scenario-1-RandomForest.py"]:::client
        RF2["Scenario-2-RandomForest.py"]:::client
        XGB1["Scenario-1-XGBoost.py"]:::client
        XGB2["Scenario-2-XGBoost.py"]:::client
    end

    FO["Federated Orchestrator"]:::server
    CMS["Central Model Store"]:::db
    NB["RandomForest.ipynb"]:::doc

    subgraph "Research Artifacts"
        PAPERS["Papers/"]:::external
    end

    subgraph "Project Configuration"
        README["README.md"]:::external
        VSCODE[".vscode/"]:::external
        CHANGELOG["CHANGELOG.md"]:::external
        GATTR[".gitattributes"]:::external
    end

    Data -->|load data| DT1
    Data -->|load data| DT2
    Data -->|load data| RF1
    Data -->|load data| RF2
    Data -->|load data| XGB1
    Data -->|load data| XGB2

    DT1 -->|send updates| FO
    DT2 -->|send updates| FO
    RF1 -->|send updates| FO
    RF2 -->|send updates| FO
    XGB1 -->|send updates| FO
    XGB2 -->|send updates| FO

    FO -->|"aggregate"| CMS
    CMS -->|"broadcast model"| DT1
    CMS -->|"broadcast model"| DT2
    CMS -->|"broadcast model"| RF1
    CMS -->|"broadcast model"| RF2
    CMS -->|"broadcast model"| XGB1
    CMS -->|"broadcast model"| XGB2

    CMS -->|"evaluate"| NB

    classDef data fill:#D6E9F8,stroke:#4A90E2,stroke-width:1px;
    classDef client fill:#E8F4FD,stroke:#2C7FB8,stroke-width:1px,stroke-dasharray: 2 2;
    classDef server fill:#DFF0D8,stroke:#3C763D,stroke-width:1px;
    classDef db fill:#F5F5F5,stroke:#AAA,stroke-width:1px;
    classDef doc fill:#FCF8E3,stroke:#8A6D3B,stroke-width:1px;
    classDef external fill:#F2F2F2,stroke:#666,stroke-width:1px,stroke-dasharray: 4 2;

    click Data "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/tree/main/Data/"
    click DT1 "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/blob/main/Scenario-1-DecisionTree.py"
    click DT2 "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/blob/main/Scenario-2-DecisionTree.py"
    click RF1 "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/blob/main/Scenario-1-RandomForest.py"
    click RF2 "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/blob/main/Scenario-2-RandomForest.py"
    click XGB1 "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/blob/main/Scenario-1-XGBoost.py"
    click XGB2 "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/blob/main/Scenario-2-XGBoost.py"
    click NB "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/blob/main/RandomForest.ipynb"
    click PAPERS "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/tree/main/Papers/"
    click README "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/blob/main/README.md"
    click VSCODE "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/tree/main/.vscode/"
    click CHANGELOG "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/blob/main/CHANGELOG.md"
    click GATTR "https://github.com/haktanpolatt/federated-learning-on-weather-station-data/blob/main/.gitattributes"
```
