# boya-zhang-ai/freqcycle architecture

> Architecture diagram of the GitHub repository boya-zhang-ai/freqcycle, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/boya-zhang-ai/freqcycle
- Repository: https://github.com/boya-zhang-ai/freqcycle

## Overview

FreqCycle is a time-series forecasting project: users configure a dataset and model, then launch training, testing, or prediction through the command-line runner. The experiment layer selects a forecasting model, obtains batches from the data provider, and handles optimization and evaluation. The principal FreqCycle model combines learned recurrent-cycle patterns with segmented frequency learning; the repository also offers multi-cycle and frequency-linear alternatives. The README documents the cycle-index and segmentation roles. Some utility and alternative-model internals were not sampled, so their detailed links are omitted.

Main entry points: [`exp/exp_main.py`](https://github.com/boya-zhang-ai/freqcycle/blob/main/exp/exp_main.py) (Experiment controller), [`models/FreqCycle.py`](https://github.com/boya-zhang-ai/freqcycle/blob/main/models/FreqCycle.py) (FreqCycle), [`models/MFreqCycle.py`](https://github.com/boya-zhang-ai/freqcycle/blob/main/models/MFreqCycle.py) (Multi-cycle FreqCycle), [`run.py`](https://github.com/boya-zhang-ai/freqcycle/blob/main/run.py) (Runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Execution"]
  node_runner["Runner<br/>[run.py]"]
  node_experiment["Experiment controller<br/>[exp_main.py]"]
  node_base["Device setup<br/>[exp_basic.py]"]
end

subgraph group_data["Data preparation"]
  node_factory["Data provider<br/>[data_factory.py]"]
  node_datasets["Time-series datasets<br/>[data_loader.py]"]
  node_timefeatures["Time features<br/>[timefeatures.py]"]
end

subgraph group_models["Forecasting models"]
  node_freqcycle["FreqCycle<br/>[FreqCycle.py]"]
  node_cyclepatterns["Recurrent cycle patterns<br/>[FreqCycle.py]"]
  node_segmented["Segmented frequency learning<br/>[FreqCycle.py]"]
  node_mfreqcycle["Multi-cycle FreqCycle<br/>[MFreqCycle.py]"]
  node_mcyclepatterns["Multi-cycle patterns<br/>[MFreqCycle.py]"]
  node_msegmented["Multi-cycle segmentation<br/>[MFreqCycle.py]"]
  node_dfreq["DFreqLinear<br/>[DFreqLinear.py]"]
  node_ldfreq["LDFreqLinear<br/>[LDFreqLinear.py]"]
  node_embed["Embedding layers<br/>[Embed.py]"]
  node_revin["RevIN layer<br/>[RevIN.py]"]
end

subgraph group_support["Experiment support"]
  node_metrics["Forecast metrics<br/>[metrics.py]"]
  node_tools["Training utilities<br/>[tools.py]"]
end

node_user(("CLI user"))

node_user -->|"configures and launches"| node_runner
node_runner -->|"starts training or prediction"| node_experiment
node_experiment -->|"inherits device setup"| node_base
node_experiment -->|"requests data loaders"| node_factory
node_factory -->|"constructs datasets"| node_datasets
node_datasets -->|"encodes timestamps"| node_timefeatures
node_experiment -->|"dispatches model"| node_freqcycle
node_experiment -->|"dispatches model"| node_mfreqcycle
node_experiment -->|"dispatches model"| node_dfreq
node_experiment -->|"dispatches model"| node_ldfreq
node_freqcycle -->|"removes and restores cycles"| node_cyclepatterns
node_freqcycle -->|"forecasts residuals"| node_segmented
node_mfreqcycle -->|"builds cycle components"| node_mcyclepatterns
node_mfreqcycle -->|"uses segmentation"| node_msegmented
node_experiment -->|"evaluates forecasts"| node_metrics
node_experiment -.->|"uses training helpers"| node_tools

click node_runner "https://github.com/boya-zhang-ai/freqcycle/blob/main/run.py"
click node_experiment "https://github.com/boya-zhang-ai/freqcycle/blob/main/exp/exp_main.py"
click node_base "https://github.com/boya-zhang-ai/freqcycle/blob/main/exp/exp_basic.py"
click node_factory "https://github.com/boya-zhang-ai/freqcycle/blob/main/data_provider/data_factory.py"
click node_datasets "https://github.com/boya-zhang-ai/freqcycle/blob/main/data_provider/data_loader.py"
click node_timefeatures "https://github.com/boya-zhang-ai/freqcycle/blob/main/utils/timefeatures.py"
click node_freqcycle "https://github.com/boya-zhang-ai/freqcycle/blob/main/models/FreqCycle.py"
click node_cyclepatterns "https://github.com/boya-zhang-ai/freqcycle/blob/main/models/FreqCycle.py"
click node_segmented "https://github.com/boya-zhang-ai/freqcycle/blob/main/models/FreqCycle.py"
click node_mfreqcycle "https://github.com/boya-zhang-ai/freqcycle/blob/main/models/MFreqCycle.py"
click node_mcyclepatterns "https://github.com/boya-zhang-ai/freqcycle/blob/main/models/MFreqCycle.py"
click node_msegmented "https://github.com/boya-zhang-ai/freqcycle/blob/main/models/MFreqCycle.py"
click node_dfreq "https://github.com/boya-zhang-ai/freqcycle/blob/main/models/DFreqLinear.py"
click node_ldfreq "https://github.com/boya-zhang-ai/freqcycle/blob/main/models/LDFreqLinear.py"
click node_embed "https://github.com/boya-zhang-ai/freqcycle/blob/main/layers/Embed.py"
click node_revin "https://github.com/boya-zhang-ai/freqcycle/blob/main/layers/RevIN.py"
click node_metrics "https://github.com/boya-zhang-ai/freqcycle/blob/main/utils/metrics.py"
click node_tools "https://github.com/boya-zhang-ai/freqcycle/blob/main/utils/tools.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_runner,node_experiment,node_base,node_user toneBlue
class node_factory,node_datasets,node_timefeatures toneAmber
class node_freqcycle,node_cyclepatterns,node_segmented,node_mfreqcycle,node_mcyclepatterns,node_msegmented,node_dfreq,node_ldfreq,node_embed,node_revin toneMint
class node_metrics,node_tools toneRose
```

## Components

### Execution

- [Runner](https://github.com/boya-zhang-ai/freqcycle/blob/main/run.py): `run.py`
- [Experiment controller](https://github.com/boya-zhang-ai/freqcycle/blob/main/exp/exp_main.py): `exp/exp_main.py`
- [Device setup](https://github.com/boya-zhang-ai/freqcycle/blob/main/exp/exp_basic.py): `exp/exp_basic.py`

### Data preparation

- [Data provider](https://github.com/boya-zhang-ai/freqcycle/blob/main/data_provider/data_factory.py): `data_provider/data_factory.py`
- [Time-series datasets](https://github.com/boya-zhang-ai/freqcycle/blob/main/data_provider/data_loader.py): `data_provider/data_loader.py`
- [Time features](https://github.com/boya-zhang-ai/freqcycle/blob/main/utils/timefeatures.py): `utils/timefeatures.py`

### Forecasting models

- [FreqCycle](https://github.com/boya-zhang-ai/freqcycle/blob/main/models/FreqCycle.py): `models/FreqCycle.py`
- [Recurrent cycle patterns](https://github.com/boya-zhang-ai/freqcycle/blob/main/models/FreqCycle.py): `models/FreqCycle.py`
- [Segmented frequency learning](https://github.com/boya-zhang-ai/freqcycle/blob/main/models/FreqCycle.py): `models/FreqCycle.py`
- [Multi-cycle FreqCycle](https://github.com/boya-zhang-ai/freqcycle/blob/main/models/MFreqCycle.py): `models/MFreqCycle.py`
- [Multi-cycle patterns](https://github.com/boya-zhang-ai/freqcycle/blob/main/models/MFreqCycle.py): `models/MFreqCycle.py`
- [Multi-cycle segmentation](https://github.com/boya-zhang-ai/freqcycle/blob/main/models/MFreqCycle.py): `models/MFreqCycle.py`
- [DFreqLinear](https://github.com/boya-zhang-ai/freqcycle/blob/main/models/DFreqLinear.py): `models/DFreqLinear.py`
- [LDFreqLinear](https://github.com/boya-zhang-ai/freqcycle/blob/main/models/LDFreqLinear.py): `models/LDFreqLinear.py`
- [Embedding layers](https://github.com/boya-zhang-ai/freqcycle/blob/main/layers/Embed.py): `layers/Embed.py`
- [RevIN layer](https://github.com/boya-zhang-ai/freqcycle/blob/main/layers/RevIN.py): `layers/RevIN.py`

### Experiment support

- [Forecast metrics](https://github.com/boya-zhang-ai/freqcycle/blob/main/utils/metrics.py): `utils/metrics.py`
- [Training utilities](https://github.com/boya-zhang-ai/freqcycle/blob/main/utils/tools.py): `utils/tools.py`

### Other components

- **CLI user**

## Connections

- CLI user → Runner: configures and launches (evidence: `run.py`)
- Runner → Experiment controller: starts training or prediction (evidence: `run.py`)
- Experiment controller → Device setup: inherits device setup (evidence: `exp/exp_main.py`)
- Experiment controller → Data provider: requests data loaders (evidence: `exp/exp_main.py`)
- Data provider → Time-series datasets: constructs datasets (evidence: `data_provider/data_factory.py`)
- Time-series datasets → Time features: encodes timestamps (evidence: `data_provider/data_loader.py`)
- Experiment controller → FreqCycle: dispatches model (evidence: `exp/exp_main.py`)
- Experiment controller → Multi-cycle FreqCycle: dispatches model (evidence: `exp/exp_main.py`)
- Experiment controller → DFreqLinear: dispatches model (evidence: `exp/exp_main.py`)
- Experiment controller → LDFreqLinear: dispatches model (evidence: `exp/exp_main.py`)
- FreqCycle → Recurrent cycle patterns: removes and restores cycles (evidence: `models/FreqCycle.py`)
- FreqCycle → Segmented frequency learning: forecasts residuals (evidence: `models/FreqCycle.py`)
- Multi-cycle FreqCycle → Multi-cycle patterns: builds cycle components (evidence: `models/MFreqCycle.py`)
- Multi-cycle FreqCycle → Multi-cycle segmentation: uses segmentation (evidence: `models/MFreqCycle.py`)
- Experiment controller → Forecast metrics: evaluates forecasts (evidence: `exp/exp_main.py`)
- Experiment controller → Training utilities: uses training helpers (evidence: `exp/exp_main.py`)
