# fh-prevail/ur2cute_torch architecture

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

- Interactive diagram: https://gitdiagram.com/fh-prevail/ur2cute_torch
- Repository: https://github.com/fh-prevail/ur2cute_torch

## Overview

UR2CUTE is a PyTorch library for intermittent-demand forecasting. A user fits its scikit-learn-style estimator on a time series, then predicts a multi-step horizon: shared temporal features feed separate occurrence and magnitude models, whose outputs are combined using a threshold. The README also documents rolling-origin backtesting, forecast components, and model persistence. Most runtime responsibilities are implemented in the single `UR2CUTE/model.py` module; relationships below follow README descriptions where source excerpts do not show the complete method flow.

Main entry points: [`UR2CUTE/model.py`](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py) (UR2CUTE estimator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api_eval["Estimator and evaluation"]
  node_estimator["UR2CUTE estimator<br/>[model.py]"]
  node_backtest["Rolling backtest<br/>[model.py]"]
  node_metrics["Demand metrics<br/>[model.py]"]
end

subgraph group_prep["Input preparation"]
  node_validation["Input validation<br/>[model.py]"]
  node_features["Feature engineering<br/>[model.py]"]
  node_windows["Windowing and split<br/>[model.py]"]
  node_scaling["Scaling transforms<br/>[model.py]"]
end

subgraph group_models["Dual CNN models"]
  node_classifier["Occurrence CNN<br/>[model.py]"]
  node_regressor["Magnitude CNN<br/>[model.py]"]
end

subgraph group_outputs["Forecast and persistence"]
  node_threshold["Threshold selection<br/>[model.py]"]
  node_forecast["Forecast output<br/>[model.py]"]
  node_persistence["Model persistence<br/>[model.py]"]
end

node_user(("Analyst"))
node_model_file["Serialized model"]

node_user -->|"fits or predicts"| node_estimator
node_estimator -->|"validates inputs"| node_validation
node_estimator -->|"builds channels"| node_features
node_features -->|"forms windows"| node_windows
node_windows -->|"scales partitions"| node_scaling
node_estimator -->|"trains and predicts"| node_classifier
node_estimator -->|"trains and predicts"| node_regressor
node_classifier -->|"supplies occurrence probability"| node_threshold
node_regressor -->|"supplies quantity"| node_forecast
node_threshold -->|"gates quantity"| node_forecast
node_estimator -->|"runs rolling origins"| node_backtest
node_backtest -->|"summarizes errors"| node_metrics
node_estimator -->|"saves or loads"| node_persistence
node_persistence -->|"serializes parameters"| node_model_file
node_forecast -->|"returns forecasts"| node_user

click node_estimator "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_validation "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_features "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_windows "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_scaling "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_classifier "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_regressor "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_threshold "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_forecast "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_backtest "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_metrics "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py"
click node_persistence "https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.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_estimator,node_backtest,node_metrics toneBlue
class node_validation,node_features,node_windows,node_scaling toneAmber
class node_classifier,node_regressor toneMint
class node_threshold,node_forecast,node_persistence toneRose
class node_user,node_model_file toneIndigo
```

## Components

### Estimator and evaluation

- [UR2CUTE estimator](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`
- [Rolling backtest](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`
- [Demand metrics](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`

### Input preparation

- [Input validation](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`
- [Feature engineering](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`
- [Windowing and split](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`
- [Scaling transforms](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`

### Dual CNN models

- [Occurrence CNN](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`
- [Magnitude CNN](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`

### Forecast and persistence

- [Threshold selection](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`
- [Forecast output](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`
- [Model persistence](https://github.com/fh-prevail/ur2cute_torch/blob/main/UR2CUTE/model.py): `UR2CUTE/model.py`

### Other components

- **Analyst**
- **Serialized model**

## Connections

- Analyst → UR2CUTE estimator: fits or predicts (evidence: `README.md`)
- UR2CUTE estimator → Input validation: validates inputs (evidence: `README.md`)
- UR2CUTE estimator → Feature engineering: builds channels (evidence: `README.md`)
- Feature engineering → Windowing and split: forms windows (evidence: `README.md`)
- Windowing and split → Scaling transforms: scales partitions (evidence: `README.md`)
- UR2CUTE estimator → Occurrence CNN: trains and predicts (evidence: `README.md`)
- UR2CUTE estimator → Magnitude CNN: trains and predicts (evidence: `README.md`)
- Occurrence CNN → Threshold selection: supplies occurrence probability (evidence: `README.md`)
- Magnitude CNN → Forecast output: supplies quantity (evidence: `README.md`)
- Threshold selection → Forecast output: gates quantity (evidence: `README.md`)
- UR2CUTE estimator → Rolling backtest: runs rolling origins (evidence: `README.md`)
- Rolling backtest → Demand metrics: summarizes errors (evidence: `README.md`)
- UR2CUTE estimator → Model persistence: saves or loads (evidence: `README.md`)
- Model persistence → Serialized model: serializes parameters (evidence: `README.md`)
- Forecast output → Analyst: returns forecasts (evidence: `README.md`)
