timecopilot.gift_eval
GIFTEval
GIFTEval(
dataset_name: str,
term: str,
output_path: Path | str | None = None,
storage_path: Path | str | None = None,
)
Evaluation utility for GIFTEval.
This class loads a time series dataset, sets up evaluation metrics, and provides methods to evaluate GluonTS predictors on the dataset, saving results to CSV if desired.
Initialize a GIFTEval instance for a specific dataset and evaluation term.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_name
|
str
|
Name of the dataset to evaluate on. |
required |
term
|
str
|
Evaluation term (e.g., 'medium', 'long'). |
required |
output_path
|
str | Path | None
|
Directory to save results CSV, or None to skip saving. |
None
|
storage_path
|
Path | str | None
|
Path where the dataset is stored. |
None
|
Example
import pandas as pd
from timecopilot.gift_eval.eval import GIFTEval
from timecopilot.gift_eval.gluonts_predictor import GluonTSPredictor
from timecopilot.models.stats import SeasonalNaive
storage_path = "./gift_eval_data"
GIFTEval.download_data(storage_path)
predictor = GluonTSPredictor(
# you can use any forecaster from TimeCopilot
# and create your own forecaster by subclassing
# [Forecaster][timecopilot.models.utils.forecaster.Forecaster]
forecaster=SeasonalNaive(),
batch_size=512,
)
gift_eval = GIFTEval(
dataset_name="m4_weekly",
term="short",
output_path="./seasonal_naive",
storage_path=storage_path,
)
gift_eval.evaluate_predictor(
predictor,
batch_size=512,
)
eval_df = pd.read_csv("./seasonal_naive/all_results.csv")
Raises:
Type | Description |
---|---|
ValueError
|
If the dataset is not compatible with the specified term. |
Source code in timecopilot/gift_eval/eval.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
download_data
staticmethod
download_data(storage_path: Path | str | None = None)
Download the GIFTEval dataset from Hugging Face.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
storage_path
|
Path | str | None
|
Path to store the dataset. |
None
|
Source code in timecopilot/gift_eval/eval.py
57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
evaluate_predictor
evaluate_predictor(
predictor: RepresentablePredictor | GluonTSPredictor,
batch_size: int | None = None,
overwrite_results: bool = False,
)
Evaluate a GluonTS predictor on the loaded dataset and save results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
predictor
|
RepresentablePredictor | GluonTSPredictor
|
The predictor to evaluate. |
required |
batch_size
|
int | None
|
Batch size for evaluation. If None, uses predictor's default. |
None
|
overwrite_results
|
bool
|
Whether to overwrite the existing results CSV file. |
False
|
Source code in timecopilot/gift_eval/eval.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
GluonTSPredictor
GluonTSPredictor(
forecaster: Forecaster,
h: int | None = None,
freq: str | None = None,
level: list[int | float] | None = None,
quantiles: list[float] | None = None,
max_length: int | None = None,
imputation_method: MissingValueImputation | None = None,
batch_size: int | None = 1024,
)
Bases: RepresentablePredictor
Adapter to use a TimeCopilot Forecaster as a GluonTS Predictor.
This class wraps a TimeCopilot Forecaster and exposes the GluonTS Predictor interface, allowing it to be used with GluonTS evaluation and processing utilities.
Initialize a GluonTSPredictor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
forecaster
|
Forecaster
|
The TimeCopilot forecaster to wrap. You can use any forecaster from TimeCopilot, and create your own forecaster by subclassing Forecaster. |
required |
h
|
int | None
|
Forecast horizon. If None (default), the horizon is inferred from the dataset. |
None
|
freq
|
str | None
|
Frequency string (e.g., 'D', 'H'). If None (default), the frequency is inferred from the dataset. |
None
|
level
|
list[int | float] | None
|
Not supported; use quantiles instead. |
None
|
quantiles
|
list[float] | None
|
Quantiles to forecast. If None (default), the default quantiles [0.1, 0.2, ..., 0.9] are used. |
None
|
max_length
|
int | None
|
Maximum length of input series. |
None
|
imputation_method
|
MissingValueImputation | None
|
Imputation method for missing values. If None (default), the last value is used with LastValueImputation(). |
None
|
batch_size
|
int | None
|
Batch size for prediction. |
1024
|
Raises:
Type | Description |
---|---|
NotImplementedError
|
If level is provided (use quantiles instead). |
Source code in timecopilot/gift_eval/gluonts_predictor.py
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 63 64 65 66 67 68 69 70 71 |
|
predict
predict(dataset: Dataset, **kwargs: Any) -> list[Forecast]
Predict forecasts for a GluonTS Dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset
|
Dataset
|
GluonTS Dataset to forecast. |
required |
**kwargs
|
Any
|
Additional keyword arguments (unused). |
{}
|
Returns:
Type | Description |
---|---|
list[Forecast]
|
list[Forecast]: List of GluonTS Forecast objects for the dataset. |
Source code in timecopilot/gift_eval/gluonts_predictor.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|