autogluon.timeseries 1.4.1b20250820__py3-none-any.whl → 1.4.1b20250901__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.
Files changed (52) 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 +9 -9
  5. autogluon/timeseries/learner.py +14 -14
  6. autogluon/timeseries/metrics/__init__.py +5 -5
  7. autogluon/timeseries/metrics/abstract.py +11 -12
  8. autogluon/timeseries/models/__init__.py +2 -0
  9. autogluon/timeseries/models/abstract/abstract_timeseries_model.py +39 -41
  10. autogluon/timeseries/models/abstract/tunable.py +6 -6
  11. autogluon/timeseries/models/autogluon_tabular/mlforecast.py +30 -30
  12. autogluon/timeseries/models/autogluon_tabular/per_step.py +12 -12
  13. autogluon/timeseries/models/chronos/model.py +10 -10
  14. autogluon/timeseries/models/chronos/pipeline/base.py +8 -8
  15. autogluon/timeseries/models/chronos/pipeline/chronos.py +12 -12
  16. autogluon/timeseries/models/chronos/pipeline/chronos_bolt.py +12 -12
  17. autogluon/timeseries/models/chronos/pipeline/utils.py +12 -12
  18. autogluon/timeseries/models/ensemble/abstract.py +19 -19
  19. autogluon/timeseries/models/ensemble/basic.py +8 -8
  20. autogluon/timeseries/models/ensemble/greedy.py +13 -13
  21. autogluon/timeseries/models/gluonts/abstract.py +24 -24
  22. autogluon/timeseries/models/gluonts/dataset.py +2 -2
  23. autogluon/timeseries/models/gluonts/models.py +7 -7
  24. autogluon/timeseries/models/local/abstract_local_model.py +12 -12
  25. autogluon/timeseries/models/local/statsforecast.py +11 -11
  26. autogluon/timeseries/models/multi_window/multi_window_model.py +33 -22
  27. autogluon/timeseries/models/registry.py +3 -3
  28. autogluon/timeseries/predictor.py +37 -37
  29. autogluon/timeseries/regressor.py +13 -13
  30. autogluon/timeseries/splitter.py +6 -6
  31. autogluon/timeseries/trainer/__init__.py +3 -0
  32. autogluon/timeseries/trainer/model_set_builder.py +256 -0
  33. autogluon/timeseries/trainer/prediction_cache.py +149 -0
  34. autogluon/timeseries/{trainer.py → trainer/trainer.py} +72 -128
  35. autogluon/timeseries/transforms/covariate_scaler.py +3 -3
  36. autogluon/timeseries/transforms/target_scaler.py +7 -7
  37. autogluon/timeseries/utils/datetime/lags.py +2 -2
  38. autogluon/timeseries/utils/datetime/time_features.py +2 -2
  39. autogluon/timeseries/utils/features.py +32 -32
  40. autogluon/timeseries/version.py +1 -1
  41. {autogluon.timeseries-1.4.1b20250820.dist-info → autogluon.timeseries-1.4.1b20250901.dist-info}/METADATA +5 -5
  42. autogluon.timeseries-1.4.1b20250901.dist-info/RECORD +75 -0
  43. autogluon/timeseries/configs/presets_configs.py +0 -79
  44. autogluon/timeseries/models/presets.py +0 -280
  45. autogluon.timeseries-1.4.1b20250820.dist-info/RECORD +0 -72
  46. /autogluon.timeseries-1.4.1b20250820-py3.9-nspkg.pth → /autogluon.timeseries-1.4.1b20250901-py3.9-nspkg.pth +0 -0
  47. {autogluon.timeseries-1.4.1b20250820.dist-info → autogluon.timeseries-1.4.1b20250901.dist-info}/LICENSE +0 -0
  48. {autogluon.timeseries-1.4.1b20250820.dist-info → autogluon.timeseries-1.4.1b20250901.dist-info}/NOTICE +0 -0
  49. {autogluon.timeseries-1.4.1b20250820.dist-info → autogluon.timeseries-1.4.1b20250901.dist-info}/WHEEL +0 -0
  50. {autogluon.timeseries-1.4.1b20250820.dist-info → autogluon.timeseries-1.4.1b20250901.dist-info}/namespace_packages.txt +0 -0
  51. {autogluon.timeseries-1.4.1b20250820.dist-info → autogluon.timeseries-1.4.1b20250901.dist-info}/top_level.txt +0 -0
  52. {autogluon.timeseries-1.4.1b20250820.dist-info → autogluon.timeseries-1.4.1b20250901.dist-info}/zip-safe +0 -0
@@ -1,12 +1,10 @@
1
- from __future__ import annotations
2
-
3
1
  import copy
4
2
  import logging
5
3
  import os
6
4
  import re
7
5
  import time
8
6
  from abc import ABC, abstractmethod
9
- from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
7
+ from typing import Any, Optional, Sequence, Union
10
8
 
11
9
  import pandas as pd
12
10
  from typing_extensions import Self
@@ -38,27 +36,27 @@ class TimeSeriesModelBase(ModelBase, ABC):
38
36
 
39
37
  Parameters
40
38
  ----------
41
- path : str, default = None
39
+ path
42
40
  Directory location to store all outputs.
43
41
  If None, a new unique time-stamped directory is chosen.
44
- freq: str
42
+ freq
45
43
  Frequency string (cf. gluonts frequency strings) describing the frequency
46
44
  of the time series data. For example, "h" for hourly or "D" for daily data.
47
- prediction_length: int
45
+ prediction_length
48
46
  Length of the prediction horizon, i.e., the number of time steps the model
49
47
  is fit to forecast.
50
- name : str, default = None
48
+ name
51
49
  Name of the subdirectory inside path where model will be saved.
52
50
  The final model directory will be os.path.join(path, name)
53
51
  If None, defaults to the model's class name: self.__class__.__name__
54
- covariate_metadata: CovariateMetadata
52
+ covariate_metadata
55
53
  A mapping of different covariate types known to autogluon.timeseries to column names
56
54
  in the data set.
57
- eval_metric : Union[str, TimeSeriesScorer], default = "WQL"
55
+ eval_metric
58
56
  Metric by which predictions will be ultimately evaluated on future test data. This only impacts
59
57
  ``model.score()``, as eval_metric is not used during training. Available metrics can be found in
60
58
  ``autogluon.timeseries.metrics``.
61
- hyperparameters : dict, default = None
59
+ hyperparameters
62
60
  Hyperparameters that will be used by the model (can be search spaces instead of fixed values).
63
61
  If None, model defaults are used. This is identical to passing an empty dictionary.
64
62
  """
@@ -79,7 +77,7 @@ class TimeSeriesModelBase(ModelBase, ABC):
79
77
  self,
80
78
  path: Optional[str] = None,
81
79
  name: Optional[str] = None,
82
- hyperparameters: Optional[Dict[str, Any]] = None,
80
+ hyperparameters: Optional[dict[str, Any]] = None,
83
81
  freq: Optional[str] = None,
84
82
  prediction_length: int = 1,
85
83
  covariate_metadata: Optional[CovariateMetadata] = None,
@@ -119,7 +117,7 @@ class TimeSeriesModelBase(ModelBase, ABC):
119
117
  else:
120
118
  self.must_drop_median = False
121
119
 
122
- self._oof_predictions: Optional[List[TimeSeriesDataFrame]] = None
120
+ self._oof_predictions: Optional[list[TimeSeriesDataFrame]] = None
123
121
 
124
122
  # user provided hyperparameters and extra arguments that are used during model training
125
123
  self._hyperparameters, self._extra_ag_args = self._check_and_split_hyperparameters(hyperparameters)
@@ -147,22 +145,21 @@ class TimeSeriesModelBase(ModelBase, ABC):
147
145
 
148
146
  @classmethod
149
147
  def _check_and_split_hyperparameters(
150
- cls, hyperparameters: Optional[Dict[str, Any]] = None
151
- ) -> Tuple[Dict[str, Any], Dict[str, Any]]:
152
- """
153
- Given the user-specified hyperparameters, split into `hyperparameters` and `extra_ag_args`, intended
148
+ cls, hyperparameters: Optional[dict[str, Any]] = None
149
+ ) -> tuple[dict[str, Any], dict[str, Any]]:
150
+ """Given the user-specified hyperparameters, split into `hyperparameters` and `extra_ag_args`, intended
154
151
  to be used during model initialization.
155
152
 
156
153
  Parameters
157
154
  ----------
158
- hyperparameters : Optional[Dict[str, Any]], default = None
155
+ hyperparameters
159
156
  The model hyperparameters dictionary provided to the model constructor.
160
157
 
161
158
  Returns
162
159
  -------
163
- hyperparameters: Dict[str, Any]
160
+ hyperparameters
164
161
  Native model hyperparameters that are passed into the "inner model" AutoGluon wraps
165
- extra_ag_args: Dict[str, Any]
162
+ extra_ag_args
166
163
  Special auxiliary parameters that modify the model training process used by AutoGluon
167
164
  """
168
165
  hyperparameters = copy.deepcopy(hyperparameters) if hyperparameters is not None else dict()
@@ -214,7 +211,7 @@ class TimeSeriesModelBase(ModelBase, ABC):
214
211
  return model
215
212
 
216
213
  @classmethod
217
- def load_oof_predictions(cls, path: str, verbose: bool = True) -> List[TimeSeriesDataFrame]:
214
+ def load_oof_predictions(cls, path: str, verbose: bool = True) -> list[TimeSeriesDataFrame]:
218
215
  """Load the cached OOF predictions from disk."""
219
216
  return load_pkl.load(path=os.path.join(path, "utils", cls._oof_filename), verbose=verbose)
220
217
 
@@ -284,7 +281,7 @@ class TimeSeriesModelBase(ModelBase, ABC):
284
281
  return False
285
282
 
286
283
  @staticmethod
287
- def _get_system_resources() -> Dict[str, Any]:
284
+ def _get_system_resources() -> dict[str, Any]:
288
285
  resource_manager = get_resource_manager()
289
286
  system_num_cpus = resource_manager.get_cpu_count()
290
287
  system_num_gpus = resource_manager.get_gpu_count()
@@ -306,7 +303,8 @@ class TimeSeriesModelBase(ModelBase, ABC):
306
303
  def _more_tags(self) -> dict:
307
304
  """Encode model properties using tags, similar to sklearn & autogluon.tabular.
308
305
 
309
- For more details, see `autogluon.core.models.abstract.AbstractModel._get_tags()` and https://scikit-learn.org/stable/_sources/developers/develop.rst.txt.
306
+ For more details, see `autogluon.core.models.abstract.AbstractModel._get_tags()` and
307
+ https://scikit-learn.org/stable/_sources/developers/develop.rst.txt.
310
308
 
311
309
  List of currently supported tags:
312
310
  - allow_nan: Can the model handle data with missing values represented by np.nan?
@@ -388,7 +386,7 @@ class AbstractTimeSeriesModel(TimeSeriesModelBase, TimeSeriesTunable, metaclass=
388
386
  self,
389
387
  path: Optional[str] = None,
390
388
  name: Optional[str] = None,
391
- hyperparameters: Optional[Dict[str, Any]] = None,
389
+ hyperparameters: Optional[dict[str, Any]] = None,
392
390
  freq: Optional[str] = None,
393
391
  prediction_length: int = 1,
394
392
  covariate_metadata: Optional[CovariateMetadata] = None,
@@ -428,7 +426,7 @@ class AbstractTimeSeriesModel(TimeSeriesModelBase, TimeSeriesTunable, metaclass=
428
426
  )
429
427
 
430
428
  @property
431
- def allowed_hyperparameters(self) -> List[str]:
429
+ def allowed_hyperparameters(self) -> list[str]:
432
430
  """List of hyperparameters allowed by the model."""
433
431
  return ["target_scaler", "covariate_regressor", "covariate_scaler"]
434
432
 
@@ -445,32 +443,32 @@ class AbstractTimeSeriesModel(TimeSeriesModelBase, TimeSeriesTunable, metaclass=
445
443
  Models should not override the `fit` method, but instead override the `_fit` method which
446
444
  has the same arguments.
447
445
 
448
- Other Parameters
449
- ----------------
450
- train_data : TimeSeriesDataFrame
446
+ Parameters
447
+ ----------
448
+ train_data
451
449
  The training data provided in the library's `autogluon.timeseries.dataset.TimeSeriesDataFrame`
452
450
  format.
453
- val_data : TimeSeriesDataFrame, optional
451
+ val_data
454
452
  The validation data set in the same format as training data.
455
- time_limit : float, default = None
453
+ time_limit
456
454
  Time limit in seconds to adhere to when fitting model.
457
455
  Ideally, model should early stop during fit to avoid going over the time limit if specified.
458
- num_cpus : int, default = 'auto'
456
+ num_cpus
459
457
  How many CPUs to use during fit.
460
458
  This is counted in virtual cores, not in physical cores.
461
459
  If 'auto', model decides.
462
- num_gpus : int, default = 'auto'
460
+ num_gpus
463
461
  How many GPUs to use during fit.
464
462
  If 'auto', model decides.
465
- verbosity : int, default = 2
463
+ verbosity
466
464
  Verbosity levels range from 0 to 4 and control how much information is printed.
467
465
  Higher levels correspond to more detailed print statements (you can set verbosity = 0 to suppress warnings).
468
- **kwargs :
466
+ **kwargs
469
467
  Any additional fit arguments a model supports.
470
468
 
471
469
  Returns
472
470
  -------
473
- model: AbstractTimeSeriesModel
471
+ model
474
472
  The fitted model object
475
473
  """
476
474
  start_time = time.monotonic()
@@ -553,7 +551,7 @@ class AbstractTimeSeriesModel(TimeSeriesModelBase, TimeSeriesTunable, metaclass=
553
551
  "as hyperparameters when initializing or use `hyperparameter_tune` instead."
554
552
  )
555
553
 
556
- def _log_unused_hyperparameters(self, extra_allowed_hyperparameters: list[str] | None = None) -> None:
554
+ def _log_unused_hyperparameters(self, extra_allowed_hyperparameters: Optional[list[str]] = None) -> None:
557
555
  """Log a warning if unused hyperparameters were provided to the model."""
558
556
  allowed_hyperparameters = self.allowed_hyperparameters
559
557
  if extra_allowed_hyperparameters is not None:
@@ -581,15 +579,15 @@ class AbstractTimeSeriesModel(TimeSeriesModelBase, TimeSeriesTunable, metaclass=
581
579
 
582
580
  Parameters
583
581
  ----------
584
- data: Union[TimeSeriesDataFrame, Dict[str, Optional[TimeSeriesDataFrame]]]
582
+ data
585
583
  The dataset where each time series is the "context" for predictions. For ensemble models that depend on
586
584
  the predictions of other models, this method may accept a dictionary of previous models' predictions.
587
- known_covariates : Optional[TimeSeriesDataFrame]
585
+ known_covariates
588
586
  A TimeSeriesDataFrame containing the values of the known covariates during the forecast horizon.
589
587
 
590
588
  Returns
591
589
  -------
592
- predictions: TimeSeriesDataFrame
590
+ predictions
593
591
  pandas dataframes with a timestamp index, where each input item from the input
594
592
  data is given as a separate forecast item in the dictionary, keyed by the `item_id`s
595
593
  of input items.
@@ -705,12 +703,12 @@ class AbstractTimeSeriesModel(TimeSeriesModelBase, TimeSeriesTunable, metaclass=
705
703
 
706
704
  Parameters
707
705
  ----------
708
- data: TimeSeriesDataFrame
706
+ data
709
707
  Dataset used for scoring.
710
708
 
711
709
  Returns
712
710
  -------
713
- score: float
711
+ score
714
712
  The computed forecast evaluation score on the last `self.prediction_length`
715
713
  time steps of each time series.
716
714
  """
@@ -745,6 +743,6 @@ class AbstractTimeSeriesModel(TimeSeriesModelBase, TimeSeriesTunable, metaclass=
745
743
  known_covariates: Optional[TimeSeriesDataFrame] = None,
746
744
  is_train: bool = False,
747
745
  **kwargs,
748
- ) -> Tuple[TimeSeriesDataFrame, Optional[TimeSeriesDataFrame]]:
746
+ ) -> tuple[TimeSeriesDataFrame, Optional[TimeSeriesDataFrame]]:
749
747
  """Method that implements model-specific preprocessing logic."""
750
748
  return data, known_covariates
@@ -5,7 +5,7 @@ import os
5
5
  import time
6
6
  from abc import ABC, abstractmethod
7
7
  from contextlib import nullcontext
8
- from typing import Any, Dict, Optional, Tuple, Union
8
+ from typing import Any, Optional, Union
9
9
 
10
10
  from typing_extensions import Self
11
11
 
@@ -43,7 +43,7 @@ class TimeSeriesTunable(Tunable, ABC):
43
43
  refit_every_n_windows: Optional[int] = 1,
44
44
  hyperparameter_tune_kwargs: Union[str, dict] = "auto",
45
45
  time_limit: Optional[float] = None,
46
- ) -> Tuple[Dict[str, Any], Any]:
46
+ ) -> tuple[dict[str, Any], Any]:
47
47
  hpo_executor = self._get_default_hpo_executor()
48
48
  hpo_executor.initialize(
49
49
  hyperparameter_tune_kwargs, default_num_trials=default_num_trials, time_limit=time_limit
@@ -144,14 +144,14 @@ class TimeSeriesTunable(Tunable, ABC):
144
144
  """
145
145
  return None
146
146
 
147
- def get_minimum_resources(self, is_gpu_available: bool = False) -> Dict[str, Union[int, float]]:
147
+ def get_minimum_resources(self, is_gpu_available: bool = False) -> dict[str, Union[int, float]]:
148
148
  return {
149
149
  "num_cpus": 1,
150
150
  }
151
151
 
152
152
  def _save_with_data(
153
153
  self, train_data: TimeSeriesDataFrame, val_data: Optional[TimeSeriesDataFrame]
154
- ) -> Tuple[str, str]:
154
+ ) -> tuple[str, str]:
155
155
  self.path = os.path.abspath(self.path)
156
156
  self.path_root = self.path.rsplit(self.name, 1)[0]
157
157
 
@@ -173,7 +173,7 @@ class TimeSeriesTunable(Tunable, ABC):
173
173
  pass
174
174
 
175
175
  @abstractmethod
176
- def _get_search_space(self) -> Dict[str, Any]:
176
+ def _get_search_space(self) -> dict[str, Any]:
177
177
  pass
178
178
 
179
179
  @abstractmethod
@@ -185,5 +185,5 @@ class TimeSeriesTunable(Tunable, ABC):
185
185
 
186
186
  @staticmethod
187
187
  @abstractmethod
188
- def _get_system_resources() -> Dict[str, Any]:
188
+ def _get_system_resources() -> dict[str, Any]:
189
189
  pass
@@ -3,7 +3,7 @@ import logging
3
3
  import math
4
4
  import time
5
5
  import warnings
6
- from typing import Any, Callable, Collection, Dict, List, Optional, Tuple, Type, Union
6
+ from typing import Any, Callable, Collection, Optional, Type, Union
7
7
 
8
8
  import numpy as np
9
9
  import pandas as pd
@@ -68,7 +68,7 @@ class AbstractMLForecastModel(AbstractTimeSeriesModel):
68
68
  path: Optional[str] = None,
69
69
  name: Optional[str] = None,
70
70
  eval_metric: Optional[Union[str, TimeSeriesScorer]] = None,
71
- hyperparameters: Optional[Dict[str, Any]] = None,
71
+ hyperparameters: Optional[dict[str, Any]] = None,
72
72
  **kwargs,
73
73
  ):
74
74
  super().__init__(
@@ -86,12 +86,12 @@ class AbstractMLForecastModel(AbstractTimeSeriesModel):
86
86
  self._sum_of_differences: int = 0 # number of time steps removed from each series by differencing
87
87
  self._max_ts_length: Optional[int] = None
88
88
  self._target_lags: np.ndarray
89
- self._date_features: List[Callable]
89
+ self._date_features: list[Callable]
90
90
  self._mlf: MLForecast
91
91
  self._scaler: Optional[BaseTargetTransform] = None
92
92
  self._residuals_std_per_item: pd.Series
93
93
  self._train_target_median: Optional[float] = None
94
- self._non_boolean_real_covariates: List[str] = []
94
+ self._non_boolean_real_covariates: list[str] = []
95
95
 
96
96
  def _initialize_transforms_and_regressor(self):
97
97
  super()._initialize_transforms_and_regressor()
@@ -99,7 +99,7 @@ class AbstractMLForecastModel(AbstractTimeSeriesModel):
99
99
  self.target_scaler = None
100
100
 
101
101
  @property
102
- def allowed_hyperparameters(self) -> List[str]:
102
+ def allowed_hyperparameters(self) -> list[str]:
103
103
  return super().allowed_hyperparameters + [
104
104
  "lags",
105
105
  "date_features",
@@ -117,7 +117,7 @@ class AbstractMLForecastModel(AbstractTimeSeriesModel):
117
117
  known_covariates: Optional[TimeSeriesDataFrame] = None,
118
118
  is_train: bool = False,
119
119
  **kwargs,
120
- ) -> Tuple[TimeSeriesDataFrame, Optional[TimeSeriesDataFrame]]:
120
+ ) -> tuple[TimeSeriesDataFrame, Optional[TimeSeriesDataFrame]]:
121
121
  if is_train:
122
122
  # All-NaN series are removed; partially-NaN series in train_data are handled inside _generate_train_val_dfs
123
123
  all_nan_items = data.item_ids[data[self.target].isna().groupby(ITEMID, sort=False).all()]
@@ -130,7 +130,7 @@ class AbstractMLForecastModel(AbstractTimeSeriesModel):
130
130
  data[self.target] = data[self.target].fillna(value=self._train_target_median)
131
131
  return data, known_covariates
132
132
 
133
- def _process_deprecated_hyperparameters(self, model_params: Dict[str, Any]) -> Dict[str, Any]:
133
+ def _process_deprecated_hyperparameters(self, model_params: dict[str, Any]) -> dict[str, Any]:
134
134
  if "tabular_hyperparameters" in model_params:
135
135
  logger.warning(
136
136
  f"Hyperparameter 'tabular_hyperparameters' for {self.name} is deprecated and will be removed in v1.5. "
@@ -155,7 +155,7 @@ class AbstractMLForecastModel(AbstractTimeSeriesModel):
155
155
  )
156
156
  return model_params
157
157
 
158
- def _get_default_hyperparameters(self) -> Dict[str, Any]:
158
+ def _get_default_hyperparameters(self) -> dict[str, Any]:
159
159
  return {
160
160
  "max_num_items": 20_000,
161
161
  "max_num_samples": 1_000_000,
@@ -163,12 +163,12 @@ class AbstractMLForecastModel(AbstractTimeSeriesModel):
163
163
  "model_hyperparameters": {},
164
164
  }
165
165
 
166
- def _create_tabular_model(self, model_name: str, model_hyperparameters: Dict[str, Any]) -> TabularModel:
166
+ def _create_tabular_model(self, model_name: str, model_hyperparameters: dict[str, Any]) -> TabularModel:
167
167
  raise NotImplementedError
168
168
 
169
169
  def _get_mlforecast_init_args(
170
- self, train_data: TimeSeriesDataFrame, model_params: Dict[str, Any]
171
- ) -> Dict[str, Any]:
170
+ self, train_data: TimeSeriesDataFrame, model_params: dict[str, Any]
171
+ ) -> dict[str, Any]:
172
172
  from mlforecast.target_transforms import Differences
173
173
 
174
174
  from .transforms import MLForecastScaler
@@ -236,7 +236,7 @@ class AbstractMLForecastModel(AbstractTimeSeriesModel):
236
236
 
237
237
  def _generate_train_val_dfs(
238
238
  self, data: TimeSeriesDataFrame, max_num_items: Optional[int] = None, max_num_samples: Optional[int] = None
239
- ) -> Tuple[pd.DataFrame, pd.DataFrame]:
239
+ ) -> tuple[pd.DataFrame, pd.DataFrame]:
240
240
  # Exclude items that are too short for chosen differences - otherwise exception will be raised
241
241
  if self._sum_of_differences > 0:
242
242
  ts_lengths = data.num_timesteps_per_item()
@@ -400,16 +400,16 @@ class AbstractMLForecastModel(AbstractTimeSeriesModel):
400
400
  self,
401
401
  data: TimeSeriesDataFrame,
402
402
  known_covariates: Optional[TimeSeriesDataFrame] = None,
403
- ) -> Tuple[TimeSeriesDataFrame, Optional[TimeSeriesDataFrame], Optional[TimeSeriesDataFrame]]:
403
+ ) -> tuple[TimeSeriesDataFrame, Optional[TimeSeriesDataFrame], Optional[TimeSeriesDataFrame]]:
404
404
  """Remove series that are too short for chosen differencing from data and generate naive forecast for them.
405
405
 
406
406
  Returns
407
407
  -------
408
- data_long : TimeSeriesDataFrame
408
+ data_long
409
409
  Data containing only time series that are long enough for the model to predict.
410
- known_covariates_long : TimeSeriesDataFrame or None
410
+ known_covariates_long
411
411
  Future known covariates containing only time series that are long enough for the model to predict.
412
- forecast_for_short_series : TimeSeriesDataFrame or None
412
+ forecast_for_short_series
413
413
  Seasonal naive forecast for short series, if there are any in the dataset.
414
414
  """
415
415
  ts_lengths = data.num_timesteps_per_item()
@@ -468,7 +468,7 @@ class AbstractMLForecastModel(AbstractTimeSeriesModel):
468
468
  predictions[str(q)] = predictions["mean"] + norm.ppf(q) * std_per_timestep.to_numpy()
469
469
  return predictions
470
470
 
471
- def _more_tags(self) -> Dict[str, Any]:
471
+ def _more_tags(self) -> dict[str, Any]:
472
472
  return {"allow_nan": True, "can_refit_full": True}
473
473
 
474
474
 
@@ -493,13 +493,13 @@ class DirectTabularModel(AbstractMLForecastModel):
493
493
 
494
494
  Other Parameters
495
495
  ----------------
496
- lags : List[int], default = None
496
+ lags : list[int], default = None
497
497
  Lags of the target that will be used as features for predictions. If None, will be determined automatically
498
498
  based on the frequency of the data.
499
- date_features : List[Union[str, Callable]], default = None
499
+ date_features : list[Union[str, Callable]], default = None
500
500
  Features computed from the dates. Can be pandas date attributes or functions that will take the dates as input.
501
501
  If None, will be determined automatically based on the frequency of the data.
502
- differences : List[int], default = []
502
+ differences : list[int], default = []
503
503
  Differences to take of the target before computing the features. These are restored at the forecasting step.
504
504
  Defaults to no differencing.
505
505
  target_scaler : {"standard", "mean_abs", "min_max", "robust", None}, default = "mean_abs"
@@ -508,7 +508,7 @@ class DirectTabularModel(AbstractMLForecastModel):
508
508
  Name of the tabular regression model. See ``autogluon.tabular.registry.ag_model_registry`` or
509
509
  `the documentation <https://auto.gluon.ai/stable/api/autogluon.tabular.models.html>`_ for the list of available
510
510
  tabular models.
511
- model_hyperparameters : Dict[str, Any], optional
511
+ model_hyperparameters : dict[str, Any], optional
512
512
  Hyperparameters passed to the tabular regression model.
513
513
  max_num_items : int or None, default = 20_000
514
514
  If not None, the model will randomly select this many time series for training and validation.
@@ -523,7 +523,7 @@ class DirectTabularModel(AbstractMLForecastModel):
523
523
  def is_quantile_model(self) -> bool:
524
524
  return self.eval_metric.needs_quantile
525
525
 
526
- def get_hyperparameters(self) -> Dict[str, Any]:
526
+ def get_hyperparameters(self) -> dict[str, Any]:
527
527
  model_params = super().get_hyperparameters()
528
528
  # We don't set 'target_scaler' if user already provided 'scaler' to avoid overriding the user-provided value
529
529
  if "scaler" not in model_params:
@@ -634,7 +634,7 @@ class DirectTabularModel(AbstractMLForecastModel):
634
634
  column_order = ["mean"] + [col for col in predictions_df.columns if col != "mean"]
635
635
  return predictions_df[column_order]
636
636
 
637
- def _create_tabular_model(self, model_name: str, model_hyperparameters: Dict[str, Any]) -> TabularModel:
637
+ def _create_tabular_model(self, model_name: str, model_hyperparameters: dict[str, Any]) -> TabularModel:
638
638
  model_class = ag_model_registry.key_to_cls(model_name)
639
639
  if self.is_quantile_model:
640
640
  problem_type = ag.constants.QUANTILE
@@ -673,25 +673,25 @@ class RecursiveTabularModel(AbstractMLForecastModel):
673
673
 
674
674
  Other Parameters
675
675
  ----------------
676
- lags : List[int], default = None
676
+ lags : list[int], default = None
677
677
  Lags of the target that will be used as features for predictions. If None, will be determined automatically
678
678
  based on the frequency of the data.
679
- date_features : List[Union[str, Callable]], default = None
679
+ date_features : list[Union[str, Callable]], default = None
680
680
  Features computed from the dates. Can be pandas date attributes or functions that will take the dates as input.
681
681
  If None, will be determined automatically based on the frequency of the data.
682
- differences : List[int], default = None
682
+ differences : list[int], default = None
683
683
  Differences to take of the target before computing the features. These are restored at the forecasting step.
684
684
  If None, will be set to ``[seasonal_period]``, where seasonal_period is determined based on the data frequency.
685
685
  target_scaler : {"standard", "mean_abs", "min_max", "robust", None}, default = "standard"
686
686
  Scaling applied to each time series. Scaling is applied after differencing.
687
- lag_transforms : Dict[int, List[Callable]], default = None
687
+ lag_transforms : dict[int, list[Callable]], default = None
688
688
  Dictionary mapping lag periods to transformation functions applied to lagged target values (e.g., rolling mean).
689
689
  See `MLForecast documentation <https://nixtlaverse.nixtla.io/mlforecast/lag_transforms.html>`_ for more details.
690
690
  model_name : str, default = "GBM"
691
691
  Name of the tabular regression model. See ``autogluon.tabular.registry.ag_model_registry`` or
692
692
  `the documentation <https://auto.gluon.ai/stable/api/autogluon.tabular.models.html>`_ for the list of available
693
693
  tabular models.
694
- model_hyperparameters : Dict[str, Any], optional
694
+ model_hyperparameters : dict[str, Any], optional
695
695
  Hyperparameters passed to the tabular regression model.
696
696
  max_num_items : int or None, default = 20_000
697
697
  If not None, the model will randomly select this many time series for training and validation.
@@ -702,7 +702,7 @@ class RecursiveTabularModel(AbstractMLForecastModel):
702
702
 
703
703
  ag_priority = 90
704
704
 
705
- def get_hyperparameters(self) -> Dict[str, Any]:
705
+ def get_hyperparameters(self) -> dict[str, Any]:
706
706
  model_params = super().get_hyperparameters()
707
707
  # We don't set 'target_scaler' if user already provided 'scaler' to avoid overriding the user-provided value
708
708
  if "scaler" not in model_params:
@@ -756,7 +756,7 @@ class RecursiveTabularModel(AbstractMLForecastModel):
756
756
  predictions = pd.concat([predictions, forecast_for_short_series]) # type: ignore
757
757
  return predictions.reindex(original_item_id_order, level=ITEMID)
758
758
 
759
- def _create_tabular_model(self, model_name: str, model_hyperparameters: Dict[str, Any]) -> TabularModel:
759
+ def _create_tabular_model(self, model_name: str, model_hyperparameters: dict[str, Any]) -> TabularModel:
760
760
  model_class = ag_model_registry.key_to_cls(model_name)
761
761
  return TabularModel(
762
762
  model_class=model_class,
@@ -2,7 +2,7 @@ import logging
2
2
  import math
3
3
  import os
4
4
  import time
5
- from typing import Any, Callable, Dict, List, Literal, Optional, Type
5
+ from typing import Any, Callable, Literal, Optional, Type
6
6
 
7
7
  import numpy as np
8
8
  import pandas as pd
@@ -49,15 +49,15 @@ class PerStepTabularModel(AbstractTimeSeriesModel):
49
49
 
50
50
  Other Parameters
51
51
  ----------------
52
- trailing_lags : List[int], default = None
52
+ trailing_lags : list[int], default = None
53
53
  Trailing window lags of the target that will be used as features for predictions.
54
54
  Trailing lags are shifted per forecast step: model for step ``h`` uses ``[lag+h for lag in trailing_lags]``.
55
55
  If None, defaults to ``[1, 2, ..., 12]``.
56
- seasonal_lags: List[int], default = None
56
+ seasonal_lags : list[int], default = None
57
57
  Seasonal lags of the target used as features. Unlike trailing lags, seasonal lags are not shifted
58
58
  but filtered by availability: model for step ``h`` uses ``[lag for lag in seasonal_lags if lag > h]``.
59
59
  If None, determined automatically based on data frequency.
60
- date_features : List[Union[str, Callable]], default = None
60
+ date_features : list[Union[str, Callable]], default = None
61
61
  Features computed from the dates. Can be pandas date attributes or functions that will take the dates as input.
62
62
  If None, will be determined automatically based on the frequency of the data.
63
63
  target_scaler : {"standard", "mean_abs", "min_max", "robust", None}, default = "mean_abs"
@@ -66,7 +66,7 @@ class PerStepTabularModel(AbstractTimeSeriesModel):
66
66
  Name of the tabular regression model. See ``autogluon.tabular.registry.ag_model_registry`` or
67
67
  `the documentation <https://auto.gluon.ai/stable/api/autogluon.tabular.models.html>`_ for the list of available
68
68
  tabular models.
69
- model_hyperparameters : Dict[str, Any], optional
69
+ model_hyperparameters : dict[str, Any], optional
70
70
  Hyperparameters passed to the tabular regression model.
71
71
  validation_fraction : float or None, default = 0.1
72
72
  Fraction of the training data to use for validation. If None or 0.0, no validation set is created.
@@ -94,11 +94,11 @@ class PerStepTabularModel(AbstractTimeSeriesModel):
94
94
  self._date_features: list[Callable]
95
95
  self._model_cls: Type[AbstractTabularModel]
96
96
  self._n_jobs: int
97
- self._non_boolean_real_covariates: List[str] = []
97
+ self._non_boolean_real_covariates: list[str] = []
98
98
  self._max_ts_length: Optional[int] = None
99
99
 
100
100
  @property
101
- def allowed_hyperparameters(self) -> List[str]:
101
+ def allowed_hyperparameters(self) -> list[str]:
102
102
  # TODO: Differencing is currently not supported because it greatly complicates the preprocessing logic
103
103
  return super().allowed_hyperparameters + [
104
104
  "trailing_lags",
@@ -285,10 +285,10 @@ class PerStepTabularModel(AbstractTimeSeriesModel):
285
285
 
286
286
  @staticmethod
287
287
  def _get_lags_for_step(
288
- trailing_lags: List[int],
289
- seasonal_lags: List[int],
288
+ trailing_lags: list[int],
289
+ seasonal_lags: list[int],
290
290
  step: int,
291
- ) -> List[int]:
291
+ ) -> list[int]:
292
292
  """Get the list of lags that can be used by the model for the given step."""
293
293
  shifted_trailing_lags = [lag + step for lag in trailing_lags]
294
294
  # Only keep lags that are available for model predicting `step` values ahead at prediction time
@@ -417,7 +417,7 @@ class PerStepTabularModel(AbstractTimeSeriesModel):
417
417
 
418
418
  Returns
419
419
  -------
420
- predictions :
420
+ predictions
421
421
  Predictions of the model for the given step. Shape: (num_items, len(quantile_levels)).
422
422
  """
423
423
  from mlforecast import MLForecast
@@ -498,5 +498,5 @@ class PerStepTabularModel(AbstractTimeSeriesModel):
498
498
  predictions["mean"] = predictions["0.5"]
499
499
  return TimeSeriesDataFrame(predictions)
500
500
 
501
- def _more_tags(self) -> Dict[str, Any]:
501
+ def _more_tags(self) -> dict[str, Any]:
502
502
  return {"allow_nan": True, "can_refit_full": True}
@@ -3,7 +3,7 @@ import os
3
3
  import shutil
4
4
  import warnings
5
5
  from pathlib import Path
6
- from typing import Any, Dict, Optional, Union
6
+ from typing import Any, Optional, Union
7
7
 
8
8
  import numpy as np
9
9
  import pandas as pd
@@ -110,7 +110,7 @@ class ChronosModel(AbstractTimeSeriesModel):
110
110
 
111
111
  Other Parameters
112
112
  ----------------
113
- model_path: str, default = "autogluon/chronos-bolt-small"
113
+ model_path : str, default = "autogluon/chronos-bolt-small"
114
114
  Model path used for the model, i.e., a HuggingFace transformers ``name_or_path``. Can be a
115
115
  compatible model name on HuggingFace Hub or a local path to a model directory. Original
116
116
  Chronos models (i.e., ``autogluon/chronos-t5-{model_size}``) can be specified with aliases
@@ -144,7 +144,7 @@ class ChronosModel(AbstractTimeSeriesModel):
144
144
  for more information.
145
145
  fine_tune : bool, default = False
146
146
  If True, the pretrained model will be fine-tuned
147
- fine_tune_lr: float, default = 1e-5
147
+ fine_tune_lr : float, default = 1e-5
148
148
  The learning rate used for fine-tuning. This default is suitable for Chronos-Bolt models; for the original
149
149
  Chronos models, we recommend using a higher learning rate such as ``1e-4``
150
150
  fine_tune_steps : int, default = 1000
@@ -162,7 +162,7 @@ class ChronosModel(AbstractTimeSeriesModel):
162
162
  during fine-tuning. If None, the entire validation dataset will be used.
163
163
  fine_tune_trainer_kwargs : dict, optional
164
164
  Extra keyword arguments passed to ``transformers.TrainingArguments``
165
- keep_transformers_logs: bool, default = False
165
+ keep_transformers_logs : bool, default = False
166
166
  If True, the logs generated by transformers will NOT be removed after fine-tuning
167
167
  """
168
168
 
@@ -181,7 +181,7 @@ class ChronosModel(AbstractTimeSeriesModel):
181
181
  path: Optional[str] = None,
182
182
  name: Optional[str] = None,
183
183
  eval_metric: Optional[str] = None,
184
- hyperparameters: Optional[Dict[str, Any]] = None,
184
+ hyperparameters: Optional[dict[str, Any]] = None,
185
185
  **kwargs, # noqa
186
186
  ):
187
187
  hyperparameters = hyperparameters if hyperparameters is not None else {}
@@ -242,7 +242,7 @@ class ChronosModel(AbstractTimeSeriesModel):
242
242
  return self._model_pipeline
243
243
 
244
244
  @property
245
- def ag_default_config(self) -> Dict[str, Any]:
245
+ def ag_default_config(self) -> dict[str, Any]:
246
246
  """The default configuration of the model used by AutoGluon if the model is one of those
247
247
  defined in MODEL_CONFIGS. For now, these are ``autogluon/chronos-t5-*`` family of models.
248
248
  """
@@ -272,8 +272,8 @@ class ChronosModel(AbstractTimeSeriesModel):
272
272
  """
273
273
  return self.ag_default_config.get("default_torch_dtype", "auto")
274
274
 
275
- def get_minimum_resources(self, is_gpu_available: bool = False) -> Dict[str, Union[int, float]]:
276
- minimum_resources: Dict[str, Union[int, float]] = {"num_cpus": 1}
275
+ def get_minimum_resources(self, is_gpu_available: bool = False) -> dict[str, Union[int, float]]:
276
+ minimum_resources: dict[str, Union[int, float]] = {"num_cpus": 1}
277
277
  # if GPU is available, we train with 1 GPU per trial
278
278
  if is_gpu_available:
279
279
  minimum_resources["num_gpus"] = self.min_num_gpus
@@ -323,7 +323,7 @@ class ChronosModel(AbstractTimeSeriesModel):
323
323
 
324
324
  return init_args.copy()
325
325
 
326
- def _get_default_hyperparameters(self) -> Dict:
326
+ def _get_default_hyperparameters(self) -> dict:
327
327
  return {
328
328
  "batch_size": self.default_batch_size,
329
329
  "num_samples": self.default_num_samples,
@@ -688,7 +688,7 @@ class ChronosModel(AbstractTimeSeriesModel):
688
688
 
689
689
  return TimeSeriesDataFrame(df)
690
690
 
691
- def _more_tags(self) -> Dict:
691
+ def _more_tags(self) -> dict:
692
692
  do_fine_tune = self.get_hyperparameters()["fine_tune"]
693
693
  return {
694
694
  "allow_nan": True,