Skip to content

Commit 16730e0

Browse files
committed
update
1 parent a9aa277 commit 16730e0

61 files changed

Lines changed: 4268 additions & 865 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 0 additions & 211 deletions
This file was deleted.

benchmark/README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# TFTS Benchmark System
2+
3+
A flexible benchmarking framework for evaluating TFTS models across multiple datasets with multiple metrics and multiple runs. Designed for reproducibility and paper-quality results.
4+
5+
## Usage
6+
7+
### Command-Line
8+
9+
```bash
10+
python -m benchmark.cli \
11+
--models rnn transformer dlinear \
12+
--datasets sine air_passengers \
13+
--metrics mae rmse mape \
14+
--runs 3 \
15+
--epochs 50 \
16+
--output-dir results/
17+
```
18+
19+
### Python API
20+
21+
```python
22+
from benchmark import BenchmarkConfig, BenchmarkRunner
23+
24+
config = BenchmarkConfig(
25+
models=["rnn", "transformer", "dlinear"],
26+
datasets=["sine", "air_passengers"],
27+
metrics=["mae", "rmse", "mape"],
28+
runs=3,
29+
epochs=50,
30+
output_dir="benchmark_results",
31+
)
32+
33+
runner = BenchmarkRunner(config)
34+
results = runner.run()
35+
36+
results.print_table() # console
37+
results.to_csv("results.csv") # CSV
38+
results.to_latex("results.tex") # LaTeX for papers
39+
```
40+
41+
## Adding a New Dataset
42+
43+
```python
44+
from benchmark import Dataset
45+
import pandas as pd
46+
47+
class MyDataset(Dataset):
48+
name = "my_dataset"
49+
description = "Description of my dataset"
50+
train_length = 24
51+
predict_sequence_length = 8
52+
53+
def prepare_data(self, **kwargs):
54+
# Load your data from any source (CSV, DB, API, etc.)
55+
x, y = ...
56+
return x, y
57+
58+
def get_train_valid_split(self, **kwargs):
59+
x, y = self.prepare_data(**kwargs)
60+
# split into train/valid
61+
return (x_train, y_train), (x_valid, y_valid)
62+
```
63+
64+
Then register it:
65+
66+
```python
67+
from benchmark import BenchmarkRunner, DatasetRegistry
68+
69+
registry = DatasetRegistry()
70+
registry.register("my_dataset", MyDataset)
71+
72+
config = BenchmarkConfig(datasets=["my_dataset"], ...)
73+
runner = BenchmarkRunner(config, dataset_registry=registry)
74+
results = runner.run()
75+
```
76+
77+
## Architecture
78+
79+
- **BenchmarkRunner**: Orchestrates running models on datasets, collecting results.
80+
- **Dataset**: Abstract base; each dataset subclass implements `prepare_data()` and returns standardized format.
81+
- **DatasetRegistry**: Maintains a registry of all available datasets.
82+
- **ModelRegistry**: Wraps existing tfts model mapping.
83+
- **BenchmarkMetrics**: Computes standard time-series metrics (MAE, MSE, RMSE, MAPE, etc.)
84+
- **BenchmarkResults**: Formats and exports results (CSV, JSON, LaTeX, console table).
85+
86+
## Metrics
87+
88+
Available metrics:
89+
- `mae`: Mean Absolute Error
90+
- `mse`: Mean Squared Error
91+
- `rmse`: Root Mean Squared Error
92+
- `mape`: Mean Absolute Percentage Error
93+
- `smape`: Symmetric MAPE
94+
- `r2`: R-squared
95+
96+
## Migrated Example Benchmarks
97+
98+
The previous `examples/benchmarks` tasks are available as registered datasets:
99+
100+
- `forecasting_sticker_sales`
101+
- `CMI_detect_sleep_states`
102+
103+
Both support `data_path` overrides through `per_dataset_config`. If the source
104+
CSV is not available, they generate deterministic placeholder data so the
105+
benchmark runner and CLI remain usable without Kaggle downloads.
106+
107+
## Output Files
108+
109+
After running, the following files are generated in `output_dir`:
110+
- `results.json`: Raw results for each run.
111+
- `results.csv`: Averaged results (mean/std per model-dataset).
112+
- `results.tex`: LaTeX table for papers.

benchmark/__init__.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""TFTS Benchmark System.
2+
3+
A flexible benchmarking framework for evaluating TFTS modelsacross multiple
4+
datasets with multiple metrics and multiple runs. Designed for reproducibility
5+
and paper-quality results.
6+
7+
Example::
8+
9+
from benchmark import BenchmarkRunner, BenchmarkConfig
10+
from benchmark.datasets import GrocerysalesDataset, RecruitRestaurantDataset
11+
12+
config = BenchmarkConfig(
13+
models=["rnn", "transformer", "dlinear"],
14+
datasets=["grocery_sales", "recruit_restaurant"],
15+
metrics=["mae", "rmse", "mape"],
16+
runs=5,
17+
output_dir="benchmark_results",
18+
)
19+
20+
runner = BenchmarkRunner(config)
21+
results = runner.run()
22+
results.to_latex("benchmark_results.tex")
23+
results.to_csv("benchmark_results.csv")
24+
"""
25+
26+
from benchmark.base import BenchmarkConfig, Dataset
27+
from benchmark.formatter import BenchmarkResults
28+
from benchmark.registry import DatasetRegistry, ModelRegistry
29+
from benchmark.runner import BenchmarkRunner
30+
31+
__all__ = [
32+
"BenchmarkRunner",
33+
"BenchmarkConfig",
34+
"BenchmarkResults",
35+
"Dataset",
36+
"DatasetRegistry",
37+
"ModelRegistry",
38+
]

0 commit comments

Comments
 (0)