File size: 1,339 Bytes
c4b87d2 0a58567 c4b87d2 0a58567 c4b87d2 0a58567 c4b87d2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
"""Core data structures and helpers shared across GIFT-Eval modules."""
from dataclasses import dataclass
from src.gift_eval.constants import ALL_DATASETS
@dataclass
class DatasetMetadata:
"""Structured description of a dataset/term combination."""
full_name: str
key: str
freq: str
term: str
season_length: int
target_dim: int
to_univariate: bool
prediction_length: int
windows: int
@dataclass
class EvaluationItem:
"""Container for evaluation results and optional figures."""
dataset_metadata: DatasetMetadata
metrics: dict
figures: list[tuple[object, str]]
DatasetSelection = list[str] | tuple[str, ...] | str
def expand_datasets_arg(datasets: DatasetSelection) -> list[str]:
"""Normalize dataset selection strings to explicit lists."""
if isinstance(datasets, str):
dataset_list = [datasets]
else:
dataset_list = list(datasets)
if not dataset_list:
return []
if dataset_list[0] == "all":
return list(ALL_DATASETS)
for dataset in dataset_list:
if dataset not in ALL_DATASETS:
raise ValueError(f"Invalid dataset: {dataset}. Use one of {ALL_DATASETS}")
return dataset_list
__all__ = [
"DatasetMetadata",
"EvaluationItem",
"DatasetSelection",
"expand_datasets_arg",
]
|