ChronosForecaster
Interface to the Chronos and Chronos-Bolt Zero-Shot Forecaster by Amazon Research.
Quickstart
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
Chronosmodel, 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.
- “num_samples”int, optional
- 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
- [1 ] (1, 2) https://github.com/amazon-science/chronos-forecasting [2 ] (1, 2, 3) Abdul Fatir Ansari, Lorenzo Stella, Caner Turkmen, and others (2024). Chronos: Learning the Language of Time Series