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.

Files changed (108) hide show
  1. autogluon/timeseries/configs/__init__.py +3 -2
  2. autogluon/timeseries/configs/hyperparameter_presets.py +62 -0
  3. autogluon/timeseries/configs/predictor_presets.py +84 -0
  4. autogluon/timeseries/dataset/ts_dataframe.py +339 -186
  5. autogluon/timeseries/learner.py +192 -60
  6. autogluon/timeseries/metrics/__init__.py +55 -11
  7. autogluon/timeseries/metrics/abstract.py +96 -25
  8. autogluon/timeseries/metrics/point.py +186 -39
  9. autogluon/timeseries/metrics/quantile.py +47 -20
  10. autogluon/timeseries/metrics/utils.py +6 -6
  11. autogluon/timeseries/models/__init__.py +13 -7
  12. autogluon/timeseries/models/abstract/__init__.py +2 -2
  13. autogluon/timeseries/models/abstract/abstract_timeseries_model.py +533 -273
  14. autogluon/timeseries/models/abstract/model_trial.py +10 -10
  15. autogluon/timeseries/models/abstract/tunable.py +189 -0
  16. autogluon/timeseries/models/autogluon_tabular/__init__.py +2 -0
  17. autogluon/timeseries/models/autogluon_tabular/mlforecast.py +369 -215
  18. autogluon/timeseries/models/autogluon_tabular/per_step.py +513 -0
  19. autogluon/timeseries/models/autogluon_tabular/transforms.py +67 -0
  20. autogluon/timeseries/models/autogluon_tabular/utils.py +3 -51
  21. autogluon/timeseries/models/chronos/__init__.py +4 -0
  22. autogluon/timeseries/models/chronos/chronos2.py +361 -0
  23. autogluon/timeseries/models/chronos/model.py +738 -0
  24. autogluon/timeseries/models/chronos/utils.py +369 -0
  25. autogluon/timeseries/models/ensemble/__init__.py +35 -2
  26. autogluon/timeseries/models/ensemble/{abstract_timeseries_ensemble.py → abstract.py} +50 -26
  27. autogluon/timeseries/models/ensemble/array_based/__init__.py +3 -0
  28. autogluon/timeseries/models/ensemble/array_based/abstract.py +236 -0
  29. autogluon/timeseries/models/ensemble/array_based/models.py +73 -0
  30. autogluon/timeseries/models/ensemble/array_based/regressor/__init__.py +12 -0
  31. autogluon/timeseries/models/ensemble/array_based/regressor/abstract.py +88 -0
  32. autogluon/timeseries/models/ensemble/array_based/regressor/linear_stacker.py +167 -0
  33. autogluon/timeseries/models/ensemble/array_based/regressor/per_quantile_tabular.py +94 -0
  34. autogluon/timeseries/models/ensemble/array_based/regressor/tabular.py +107 -0
  35. autogluon/timeseries/models/ensemble/ensemble_selection.py +167 -0
  36. autogluon/timeseries/models/ensemble/per_item_greedy.py +162 -0
  37. autogluon/timeseries/models/ensemble/weighted/__init__.py +8 -0
  38. autogluon/timeseries/models/ensemble/weighted/abstract.py +40 -0
  39. autogluon/timeseries/models/ensemble/weighted/basic.py +78 -0
  40. autogluon/timeseries/models/ensemble/weighted/greedy.py +57 -0
  41. autogluon/timeseries/models/gluonts/__init__.py +3 -1
  42. autogluon/timeseries/models/gluonts/abstract.py +583 -0
  43. autogluon/timeseries/models/gluonts/dataset.py +109 -0
  44. autogluon/timeseries/models/gluonts/{torch/models.py → models.py} +185 -44
  45. autogluon/timeseries/models/local/__init__.py +1 -10
  46. autogluon/timeseries/models/local/abstract_local_model.py +150 -97
  47. autogluon/timeseries/models/local/naive.py +31 -23
  48. autogluon/timeseries/models/local/npts.py +6 -2
  49. autogluon/timeseries/models/local/statsforecast.py +99 -112
  50. autogluon/timeseries/models/multi_window/multi_window_model.py +99 -40
  51. autogluon/timeseries/models/registry.py +64 -0
  52. autogluon/timeseries/models/toto/__init__.py +3 -0
  53. autogluon/timeseries/models/toto/_internal/__init__.py +9 -0
  54. autogluon/timeseries/models/toto/_internal/backbone/__init__.py +3 -0
  55. autogluon/timeseries/models/toto/_internal/backbone/attention.py +196 -0
  56. autogluon/timeseries/models/toto/_internal/backbone/backbone.py +262 -0
  57. autogluon/timeseries/models/toto/_internal/backbone/distribution.py +70 -0
  58. autogluon/timeseries/models/toto/_internal/backbone/kvcache.py +136 -0
  59. autogluon/timeseries/models/toto/_internal/backbone/rope.py +89 -0
  60. autogluon/timeseries/models/toto/_internal/backbone/rotary_embedding_torch.py +342 -0
  61. autogluon/timeseries/models/toto/_internal/backbone/scaler.py +305 -0
  62. autogluon/timeseries/models/toto/_internal/backbone/transformer.py +333 -0
  63. autogluon/timeseries/models/toto/_internal/dataset.py +165 -0
  64. autogluon/timeseries/models/toto/_internal/forecaster.py +423 -0
  65. autogluon/timeseries/models/toto/dataloader.py +108 -0
  66. autogluon/timeseries/models/toto/hf_pretrained_model.py +118 -0
  67. autogluon/timeseries/models/toto/model.py +236 -0
  68. autogluon/timeseries/predictor.py +826 -305
  69. autogluon/timeseries/regressor.py +253 -0
  70. autogluon/timeseries/splitter.py +10 -31
  71. autogluon/timeseries/trainer/__init__.py +2 -3
  72. autogluon/timeseries/trainer/ensemble_composer.py +439 -0
  73. autogluon/timeseries/trainer/model_set_builder.py +256 -0
  74. autogluon/timeseries/trainer/prediction_cache.py +149 -0
  75. autogluon/timeseries/trainer/trainer.py +1298 -0
  76. autogluon/timeseries/trainer/utils.py +17 -0
  77. autogluon/timeseries/transforms/__init__.py +2 -0
  78. autogluon/timeseries/transforms/covariate_scaler.py +164 -0
  79. autogluon/timeseries/transforms/target_scaler.py +149 -0
  80. autogluon/timeseries/utils/constants.py +10 -0
  81. autogluon/timeseries/utils/datetime/base.py +38 -20
  82. autogluon/timeseries/utils/datetime/lags.py +18 -16
  83. autogluon/timeseries/utils/datetime/seasonality.py +14 -14
  84. autogluon/timeseries/utils/datetime/time_features.py +17 -14
  85. autogluon/timeseries/utils/features.py +317 -53
  86. autogluon/timeseries/utils/forecast.py +31 -17
  87. autogluon/timeseries/utils/timer.py +173 -0
  88. autogluon/timeseries/utils/warning_filters.py +44 -6
  89. autogluon/timeseries/version.py +2 -1
  90. autogluon.timeseries-1.4.1b20251210-py3.11-nspkg.pth +1 -0
  91. {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info}/METADATA +71 -47
  92. autogluon_timeseries-1.4.1b20251210.dist-info/RECORD +103 -0
  93. {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info}/WHEEL +1 -1
  94. autogluon/timeseries/configs/presets_configs.py +0 -11
  95. autogluon/timeseries/evaluator.py +0 -6
  96. autogluon/timeseries/models/ensemble/greedy_ensemble.py +0 -170
  97. autogluon/timeseries/models/gluonts/abstract_gluonts.py +0 -550
  98. autogluon/timeseries/models/gluonts/torch/__init__.py +0 -0
  99. autogluon/timeseries/models/presets.py +0 -325
  100. autogluon/timeseries/trainer/abstract_trainer.py +0 -1144
  101. autogluon/timeseries/trainer/auto_trainer.py +0 -74
  102. autogluon.timeseries-1.0.1b20240304-py3.8-nspkg.pth +0 -1
  103. autogluon.timeseries-1.0.1b20240304.dist-info/RECORD +0 -58
  104. {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info/licenses}/LICENSE +0 -0
  105. {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info/licenses}/NOTICE +0 -0
  106. {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info}/namespace_packages.txt +0 -0
  107. {autogluon.timeseries-1.0.1b20240304.dist-info → autogluon_timeseries-1.4.1b20251210.dist-info}/top_level.txt +0 -0
  108. {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}")