# gist-ailab/transfer-learning-pv-forecasting architecture

> Architecture diagram of the GitHub repository gist-ailab/transfer-learning-pv-forecasting, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gist-ailab/transfer-learning-pv-forecasting
- Repository: https://github.com/gist-ailab/transfer-learning-pv-forecasting

## Overview

This repository implements photovoltaic power forecasting across sites, with a documented source-to-target transfer-learning workflow: refine large-scale source PV data, train a forecasting model, then adapt it to local sites and evaluate predictions. The main runtime entry point is `run_longExp.py`; the experiment runner coordinates dataset loading, model training/testing, and metrics. The README also documents preprocessing and multiple regional datasets. Some subsystems are represented by their exact enclosing directories because their source was not sampled; edges reflect documented workflow or visible imports/calls, not assumed internal wiring.

Main entry points: [`exp/exp_main.py`](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/exp/exp_main.py) (Train and test), [`data_preprocessing`](https://github.com/gist-ailab/transfer-learning-pv-forecasting/tree/main/data_preprocessing) (Format and clean), [`data_provider/data_loader.py`](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/data_provider/data_loader.py) (Regional datasets), [`run_longExp.py`](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/run_longExp.py) (Experiment entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_preprocess["Format and clean"]
  node_regional["Regional datasets<br/>[data_loader.py]"]
  node_factory["Dataset selection<br/>[data_factory.py]"]
end

subgraph group_training["Forecasting and transfer"]
  node_entry["Experiment entry<br/>[run_longExp.py]"]
  node_experiment["Train and test<br/>[exp_main.py]"]
  node_base["Experiment setup<br/>[exp_basic.py]"]
  node_patchmodel["PatchTST model<br/>[PatchTST.py]"]
  node_patchlayers["Patch encoder layers"]
  node_othermodels["Alternative models"]
  node_helpers["Forecast utilities<br/>[tools.py]"]
end

subgraph group_evaluation["Evaluation and results"]
  node_metrics["Forecast metrics<br/>[metrics.py]"]
  node_forecast["Site forecasts"]
  node_result["Evaluation results"]
end

node_engineer(("Researcher"))
node_rawdata[("Regional PV data")]

node_engineer -->|"starts run"| node_entry
node_rawdata -->|"supplies data"| node_preprocess
node_preprocess -->|"refines data"| node_regional
node_regional -->|"provides samples"| node_factory
node_entry -->|"runs experiments"| node_experiment
node_experiment -->|"requests batches"| node_factory
node_experiment -->|"initializes"| node_base
node_experiment -->|"trains or adapts"| node_patchmodel
node_experiment -->|"selects model"| node_othermodels
node_patchmodel -->|"uses encoder"| node_patchlayers
node_experiment -->|"uses utilities"| node_helpers
node_experiment -->|"evaluates predictions"| node_metrics
node_experiment -->|"produces predictions"| node_forecast
node_metrics -->|"reports scores"| node_result

click node_preprocess "https://github.com/gist-ailab/transfer-learning-pv-forecasting/tree/main/data_preprocessing"
click node_regional "https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/data_provider/data_loader.py"
click node_factory "https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/data_provider/data_factory.py"
click node_entry "https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/run_longExp.py"
click node_experiment "https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/exp/exp_main.py"
click node_base "https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/exp/exp_basic.py"
click node_patchmodel "https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/models/PatchTST.py"
click node_patchlayers "https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/layers/PatchTST_backbone.py"
click node_othermodels "https://github.com/gist-ailab/transfer-learning-pv-forecasting/tree/main/models"
click node_helpers "https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/utils/tools.py"
click node_metrics "https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/utils/metrics.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_preprocess,node_regional,node_factory toneBlue
class node_entry,node_experiment,node_base,node_patchmodel,node_patchlayers,node_othermodels,node_helpers,node_rawdata toneAmber
class node_metrics,node_forecast,node_result toneMint
class node_engineer toneIndigo
```

## Components

### Data preparation

- [Format and clean](https://github.com/gist-ailab/transfer-learning-pv-forecasting/tree/main/data_preprocessing): `data_preprocessing`
- [Regional datasets](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/data_provider/data_loader.py): `data_provider/data_loader.py`
- [Dataset selection](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/data_provider/data_factory.py): `data_provider/data_factory.py`

### Forecasting and transfer

- [Experiment entry](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/run_longExp.py): `run_longExp.py`
- [Train and test](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/exp/exp_main.py): `exp/exp_main.py`
- [Experiment setup](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/exp/exp_basic.py): `exp/exp_basic.py`
- [PatchTST model](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/models/PatchTST.py): `models/PatchTST.py`
- [Patch encoder layers](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/layers/PatchTST_backbone.py): `layers/PatchTST_backbone.py`
- [Alternative models](https://github.com/gist-ailab/transfer-learning-pv-forecasting/tree/main/models): `models`
- [Forecast utilities](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/utils/tools.py): `utils/tools.py`

### Evaluation and results

- [Forecast metrics](https://github.com/gist-ailab/transfer-learning-pv-forecasting/blob/main/utils/metrics.py): `utils/metrics.py`
- **Site forecasts**
- **Evaluation results**

### Other components

- **Researcher**
- **Regional PV data**

## Connections

- Researcher → Experiment entry: starts run
- Regional PV data → Format and clean: supplies data
- Format and clean → Regional datasets: refines data
- Regional datasets → Dataset selection: provides samples
- Experiment entry → Train and test: runs experiments
- Train and test → Dataset selection: requests batches
- Train and test → Experiment setup: initializes
- Train and test → PatchTST model: trains or adapts
- Train and test → Alternative models: selects model
- PatchTST model → Patch encoder layers: uses encoder
- Train and test → Forecast utilities: uses utilities
- Train and test → Forecast metrics: evaluates predictions
- Train and test → Site forecasts: produces predictions
- Forecast metrics → Evaluation results: reports scores
