|
| 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. |
0 commit comments