Back to models
Forecaster

ChronosForecaster

Interface to the Chronos and Chronos-Bolt Zero-Shot Forecaster by Amazon Research.

Chronos and Chronos-Bolt are pretrained time-series foundation models developed by Amazon for time-series forecasting. This method has been proposed in [2] and official code is given at [1].

Note: vanilla Chronos is not exogenous capable despite being so advertised in [2]. The “exogenous capable” version is actually a composite forecaster rather than an exogenous capable foundation model.

To obtain this “exogenous capable” version of Chronos as advertised in [2], combine ChronosForecaster with an exogenous capable forecaster via ResidualBoostingForecaster. The original reference uses tabularized linear regression, i.e., YtoX(LinearRegression()), with YtoX from sktime and LinearRegression from sklearn.

Quickstart

python
from sktime.forecasting.chronos import ChronosForecaster

estimator = ChronosForecaster(model_path: str, config: dict=None, seed: int | None=None, use_source_package: bool=False, ignore_deps: bool=False)

Parameters(5)

model_pathstr
Path to the Chronos huggingface model.
configdict, optional, default={}

A dictionary specifying the configuration settings for the model. The available configuration options include hyperparameters that control the prediction behavior, sampling, and hardware preferences. In case of the Chronos model, the dictionary can include the following keys:

  • “num_samples”int, optional

    The number of samples to generate during prediction. Median of these samples is taken to get prediction for each timestamp.

seed: int, optional, default=None
Random seed for transformers.
use_source_package: bool, optional, default=False

If True, the model will be loaded directly from the source package chronos. This is useful if you want to bypass the local version of the package or when working in an environment where the latest updates from the source package are needed. If False, the model will be loaded from the local version of package maintained in sktime. To install the source package, follow the instructions here [1].

ignore_deps: bool, optional, default=False
If True, dependency checks will be ignored, and the user is expected to handle the installation of required packages manually. If False, the class will enforce the default dependencies required for Chronos.

Examples

>>> # Example using 'amazon/chronos-t5-tiny' model
>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.chronos import ChronosForecaster
>>> from sktime.split import temporal_train_test_split
>>> from sktime.forecasting.base import ForecastingHorizon
>>> y = load_airline ()
>>> y_train, y_test = temporal_train_test_split (y)
>>> fh = ForecastingHorizon (y_test. index, is_relative = False)
>>> forecaster = ChronosForecaster ("amazon/chronos-t5-tiny")
>>> forecaster. fit (y_train)
>>> y_pred = forecaster. predict (fh)
>>> # Example using 'amazon/chronos-bolt-tiny' model
>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.chronos import ChronosForecaster
>>> from sktime.split import temporal_train_test_split
>>> from sktime.forecasting.base import ForecastingHorizon
>>> y = load_airline ()
>>> y_train, y_test = temporal_train_test_split (y)
>>> fh = ForecastingHorizon (y_test. index, is_relative = False)
>>> forecaster = ChronosForecaster ("amazon/chronos-bolt-tiny")
>>> forecaster. fit (y_train)
>>> y_pred = forecaster. predict (fh)

References

[2] (1,2,3)

Abdul Fatir Ansari, Lorenzo Stella, Caner Turkmen, and others (2024).

Chronos: Learning the Language of Time Series