autogluon.timeseries 1.0.1b20240304__py3-none-any.whl → 1.4.1b20251210__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of autogluon.timeseries might be problematic. Click here for more details.
- autogluon/timeseries/configs/__init__.py +3 -2
- autogluon/timeseries/configs/hyperparameter_presets.py +62 -0
- autogluon/timeseries/configs/predictor_presets.py +84 -0
- autogluon/timeseries/dataset/ts_dataframe.py +339 -186
- autogluon/timeseries/learner.py +192 -60
- autogluon/timeseries/metrics/__init__.py +55 -11
- autogluon/timeseries/metrics/abstract.py +96 -25
- autogluon/timeseries/metrics/point.py +186 -39
- autogluon/timeseries/metrics/quantile.py +47 -20
- autogluon/timeseries/metrics/utils.py +6 -6
- autogluon/timeseries/models/__init__.py +13 -7
- autogluon/timeseries/models/abstract/__init__.py +2 -2
- autogluon/timeseries/models/abstract/abstract_timeseries_model.py +533 -273
- autogluon/timeseries/models/abstract/model_trial.py +10 -10
- autogluon/timeseries/models/abstract/tunable.py +189 -0
- autogluon/timeseries/models/autogluon_tabular/__init__.py +2 -0
- autogluon/timeseries/models/autogluon_tabular/mlforecast.py +369 -215
- autogluon/timeseries/models/autogluon_tabular/per_step.py +513 -0
- autogluon/timeseries/models/autogluon_tabular/transforms.py +67 -0
- autogluon/timeseries/models/autogluon_tabular/utils.py +3 -51
- autogluon/timeseries/models/chronos/__init__.py +4 -0
- autogluon/timeseries/models/chronos/chronos2.py +361 -0
- autogluon/timeseries/models/chronos/model.py +738 -0
- autogluon/timeseries/models/chronos/utils.py +369 -0
- autogluon/timeseries/models/ensemble/__init__.py +35 -2
- autogluon/timeseries/models/ensemble/{abstract_timeseries_ensemble.py → abstract.py} +50 -26
- autogluon/timeseries/models/ensemble/array_based/__init__.py +3 -0
- autogluon/timeseries/models/ensemble/array_based/abstract.py +236 -0
- autogluon/timeseries/models/ensemble/array_based/models.py +73 -0
- autogluon/timeseries/models/ensemble/array_based/regressor/__init__.py +12 -0
- autogluon/timeseries/models/ensemble/array_based/regressor/abstract.py +88 -0
- autogluon/timeseries/models/ensemble/array_based/regressor/linear_stacker.py +167 -0
- autogluon/timeseries/models/ensemble/array_based/regressor/per_quantile_tabular.py +94 -0
- autogluon/timeseries/models/ensemble/array_based/regressor/tabular.py +107 -0
- autogluon/timeseries/models/ensemble/ensemble_selection.py +167 -0
- autogluon/timeseries/models/ensemble/per_item_greedy.py +162 -0
- autogluon/timeseries/models/ensemble/weighted/__init__.py +8 -0
- autogluon/timeseries/models/ensemble/weighted/abstract.py +40 -0
- autogluon/timeseries/models/ensemble/weighted/basic.py +78 -0
- autogluon/timeseries/models/ensemble/weighted/greedy.py +57 -0
- autogluon/timeseries/models/gluonts/__init__.py +3 -1
- autogluon/timeseries/models/gluonts/abstract.py +583 -0
- autogluon/timeseries/models/gluonts/dataset.py +109 -0
- autogluon/timeseries/models/gluonts/{torch/models.py → models.py} +185 -44
- autogluon/timeseries/models/local/__init__.py +1 -10
- autogluon/timeseries/models/local/abstract_local_model.py +150 -97
- autogluon/timeseries/models/local/naive.py +31 -23
- autogluon/timeseries/models/local/npts.py +6 -2
- autogluon/timeseries/models/local/statsforecast.py +99 -112
- autogluon/timeseries/models/multi_window/multi_window_model.py +99 -40
- autogluon/timeseries/models/registry.py +64 -0
- autogluon/timeseries/models/toto/__init__.py +3 -0
- autogluon/timeseries/models/toto/_internal/__init__.py +9 -0
- autogluon/timeseries/models/toto/_internal/backbone/__init__.py +3 -0
- autogluon/timeseries/models/toto/_internal/backbone/attention.py +196 -0
- autogluon/timeseries/models/toto/_internal/backbone/backbone.py +262 -0
- autogluon/timeseries/models/toto/_internal/backbone/distribution.py +70 -0
- autogluon/timeseries/models/toto/_internal/backbone/kvcache.py +136 -0
- autogluon/timeseries/models/toto/_internal/backbone/rope.py +89 -0
- autogluon/timeseries/models/toto/_internal/backbone/rotary_embedding_torch.py +342 -0
- autogluon/timeseries/models/toto/_internal/backbone/scaler.py +305 -0
- autogluon/timeseries/models/toto/_internal/backbone/transformer.py +333 -0
- autogluon/timeseries/models/toto/_internal/dataset.py +165 -0
- autogluon/timeseries/models/toto/_internal/forecaster.py +423 -0
- autogluon/timeseries/models/toto/dataloader.py +108 -0
- autogluon/timeseries/models/toto/hf_pretrained_model.py +118 -0
- autogluon/timeseries/models/toto/model.py +236 -0
- autogluon/timeseries/predictor.py +826 -305
- autogluon/timeseries/regressor.py +253 -0
- autogluon/timeseries/splitter.py +10 -31
- autogluon/timeseries/trainer/__init__.py +2 -3
- autogluon/timeseries/trainer/ensemble_composer.py +439 -0
- autogluon/timeseries/trainer/model_set_builder.py +256 -0
- autogluon/timeseries/trainer/prediction_cache.py +149 -0
- autogluon/timeseries/trainer/trainer.py +1298 -0
- autogluon/timeseries/trainer/utils.py +17 -0
- autogluon/timeseries/transforms/__init__.py +2 -0
- autogluon/timeseries/transforms/covariate_scaler.py +164 -0
- autogluon/timeseries/transforms/target_scaler.py +149 -0
- autogluon/timeseries/utils/constants.py +10 -0
- autogluon/timeseries/utils/datetime/base.py +38 -20
- autogluon/timeseries/utils/datetime/lags.py +18 -16
- autogluon/timeseries/utils/datetime/seasonality.py +14 -14
- autogluon/timeseries/utils/datetime/time_features.py +17 -14
- autogluon/timeseries/utils/features.py +317 -53
- autogluon/timeseries/utils/forecast.py +31 -17
- autogluon/timeseries/utils/timer.py +173 -0
- autogluon/timeseries/utils/warning_filters.py +44 -6
- autogluon/timeseries/version.py +2 -1
- autogluon.timeseries-1.4.1b20251210-py3.11-nspkg.pth +1 -0
- {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info}/METADATA +71 -47
- autogluon_timeseries-1.4.1b20251210.dist-info/RECORD +103 -0
- {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info}/WHEEL +1 -1
- autogluon/timeseries/configs/presets_configs.py +0 -11
- autogluon/timeseries/evaluator.py +0 -6
- autogluon/timeseries/models/ensemble/greedy_ensemble.py +0 -170
- autogluon/timeseries/models/gluonts/abstract_gluonts.py +0 -550
- autogluon/timeseries/models/gluonts/torch/__init__.py +0 -0
- autogluon/timeseries/models/presets.py +0 -325
- autogluon/timeseries/trainer/abstract_trainer.py +0 -1144
- autogluon/timeseries/trainer/auto_trainer.py +0 -74
- autogluon.timeseries-1.0.1b20240304-py3.8-nspkg.pth +0 -1
- autogluon.timeseries-1.0.1b20240304.dist-info/RECORD +0 -58
- {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info/licenses}/LICENSE +0 -0
- {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info/licenses}/NOTICE +0 -0
- {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info}/namespace_packages.txt +0 -0
- {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info}/top_level.txt +0 -0
- {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info}/zip-safe +0 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from abc import ABC, abstractmethod
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from autogluon.common.utils.utils import hash_pandas_df
|
|
7
|
+
from autogluon.core.utils.loaders import load_pkl
|
|
8
|
+
from autogluon.core.utils.savers import save_pkl
|
|
9
|
+
from autogluon.timeseries import TimeSeriesDataFrame
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PredictionCache(ABC):
|
|
15
|
+
"""A prediction cache is an abstract key-value store for time series predictions. The storage is keyed by
|
|
16
|
+
(data, known_covariates) pairs and stores (model_pred_dict, pred_time_dict) pair values. In this stored pair,
|
|
17
|
+
(model_pred_dict, pred_time_dict), both dictionaries are keyed by model names.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, root_path: str):
|
|
21
|
+
self.root_path = Path(root_path)
|
|
22
|
+
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def get(
|
|
25
|
+
self, data: TimeSeriesDataFrame, known_covariates: TimeSeriesDataFrame | None
|
|
26
|
+
) -> tuple[dict[str, TimeSeriesDataFrame | None], dict[str, float]]:
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
@abstractmethod
|
|
30
|
+
def put(
|
|
31
|
+
self,
|
|
32
|
+
data: TimeSeriesDataFrame,
|
|
33
|
+
known_covariates: TimeSeriesDataFrame | None,
|
|
34
|
+
model_pred_dict: dict[str, TimeSeriesDataFrame | None],
|
|
35
|
+
pred_time_dict: dict[str, float],
|
|
36
|
+
) -> None:
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
@abstractmethod
|
|
40
|
+
def clear(self) -> None:
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def get_prediction_cache(use_cache: bool, root_path: str) -> PredictionCache:
|
|
45
|
+
if use_cache:
|
|
46
|
+
return FileBasedPredictionCache(root_path=root_path)
|
|
47
|
+
else:
|
|
48
|
+
return NoOpPredictionCache(root_path=root_path)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def compute_dataset_hash(data: TimeSeriesDataFrame, known_covariates: TimeSeriesDataFrame | None = None) -> str:
|
|
52
|
+
"""Compute a unique string that identifies the time series dataset."""
|
|
53
|
+
combined_hash = hash_pandas_df(data) + hash_pandas_df(known_covariates) + hash_pandas_df(data.static_features)
|
|
54
|
+
return combined_hash
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class NoOpPredictionCache(PredictionCache):
|
|
58
|
+
"""A dummy (no-op) prediction cache."""
|
|
59
|
+
|
|
60
|
+
def get(
|
|
61
|
+
self, data: TimeSeriesDataFrame, known_covariates: TimeSeriesDataFrame | None
|
|
62
|
+
) -> tuple[dict[str, TimeSeriesDataFrame | None], dict[str, float]]:
|
|
63
|
+
return {}, {}
|
|
64
|
+
|
|
65
|
+
def put(
|
|
66
|
+
self,
|
|
67
|
+
data: TimeSeriesDataFrame,
|
|
68
|
+
known_covariates: TimeSeriesDataFrame | None,
|
|
69
|
+
model_pred_dict: dict[str, TimeSeriesDataFrame | None],
|
|
70
|
+
pred_time_dict: dict[str, float],
|
|
71
|
+
) -> None:
|
|
72
|
+
pass
|
|
73
|
+
|
|
74
|
+
def clear(self) -> None:
|
|
75
|
+
pass
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class FileBasedPredictionCache(PredictionCache):
|
|
79
|
+
"""A file-backed cache of model predictions."""
|
|
80
|
+
|
|
81
|
+
_cached_predictions_filename = "cached_predictions.pkl"
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def path(self) -> Path:
|
|
85
|
+
return Path(self.root_path) / self._cached_predictions_filename
|
|
86
|
+
|
|
87
|
+
def get(
|
|
88
|
+
self, data: TimeSeriesDataFrame, known_covariates: TimeSeriesDataFrame | None
|
|
89
|
+
) -> tuple[dict[str, TimeSeriesDataFrame | None], dict[str, float]]:
|
|
90
|
+
dataset_hash = compute_dataset_hash(data, known_covariates)
|
|
91
|
+
return self._get_cached_pred_dicts(dataset_hash)
|
|
92
|
+
|
|
93
|
+
def put(
|
|
94
|
+
self,
|
|
95
|
+
data: TimeSeriesDataFrame,
|
|
96
|
+
known_covariates: TimeSeriesDataFrame | None,
|
|
97
|
+
model_pred_dict: dict[str, TimeSeriesDataFrame | None],
|
|
98
|
+
pred_time_dict: dict[str, float],
|
|
99
|
+
) -> None:
|
|
100
|
+
dataset_hash = compute_dataset_hash(data, known_covariates)
|
|
101
|
+
self._save_cached_pred_dicts(dataset_hash, model_pred_dict, pred_time_dict)
|
|
102
|
+
|
|
103
|
+
def clear(self) -> None:
|
|
104
|
+
if self.path.exists():
|
|
105
|
+
logger.debug(f"Removing existing cached predictions file {self.path}")
|
|
106
|
+
self.path.unlink()
|
|
107
|
+
|
|
108
|
+
def _load_cached_predictions(self) -> dict[str, dict[str, dict[str, Any]]]:
|
|
109
|
+
if self.path.exists():
|
|
110
|
+
try:
|
|
111
|
+
cached_predictions = load_pkl.load(str(self.path))
|
|
112
|
+
except Exception:
|
|
113
|
+
cached_predictions = {}
|
|
114
|
+
else:
|
|
115
|
+
cached_predictions = {}
|
|
116
|
+
return cached_predictions
|
|
117
|
+
|
|
118
|
+
def _get_cached_pred_dicts(
|
|
119
|
+
self, dataset_hash: str
|
|
120
|
+
) -> tuple[dict[str, TimeSeriesDataFrame | None], dict[str, float]]:
|
|
121
|
+
"""Load cached predictions for given dataset_hash from disk, if possible.
|
|
122
|
+
|
|
123
|
+
If loading fails for any reason, empty dicts are returned.
|
|
124
|
+
"""
|
|
125
|
+
cached_predictions = self._load_cached_predictions()
|
|
126
|
+
if dataset_hash in cached_predictions:
|
|
127
|
+
try:
|
|
128
|
+
model_pred_dict = cached_predictions[dataset_hash]["model_pred_dict"]
|
|
129
|
+
pred_time_dict = cached_predictions[dataset_hash]["pred_time_dict"]
|
|
130
|
+
assert model_pred_dict.keys() == pred_time_dict.keys()
|
|
131
|
+
return model_pred_dict, pred_time_dict
|
|
132
|
+
except Exception:
|
|
133
|
+
logger.warning("Cached predictions are corrupted. Predictions will be made from scratch.")
|
|
134
|
+
return {}, {}
|
|
135
|
+
|
|
136
|
+
def _save_cached_pred_dicts(
|
|
137
|
+
self,
|
|
138
|
+
dataset_hash: str,
|
|
139
|
+
model_pred_dict: dict[str, TimeSeriesDataFrame | None],
|
|
140
|
+
pred_time_dict: dict[str, float],
|
|
141
|
+
) -> None:
|
|
142
|
+
cached_predictions = self._load_cached_predictions()
|
|
143
|
+
# Do not save results for models that failed
|
|
144
|
+
cached_predictions[dataset_hash] = {
|
|
145
|
+
"model_pred_dict": {k: v for k, v in model_pred_dict.items() if v is not None},
|
|
146
|
+
"pred_time_dict": {k: v for k, v in pred_time_dict.items() if v is not None},
|
|
147
|
+
}
|
|
148
|
+
save_pkl.save(str(self.path), object=cached_predictions)
|
|
149
|
+
logger.debug(f"Cached predictions saved to {self.path}")
|