T0Forecaster
Interface to the T0 zero-shot forecaster by The Forecasting Company.
T0 is a pretrained time series foundation model for zero-shot forecasting, released by The Forecasting Company [1], [2]. The model is loaded from a pretrained checkpoint and applied without task-specific training: the context is stored in fit and forecasts are produced zero-shot in predict.
T0 natively supports known-future covariates (exogenous data), passed to the underlying model via its future_covariates argument. These covariates must span the context window and the forecast horizon, so exogenous data must be provided both in fit (past values) and predict (future values).
Capabilities and behaviour:
Multivariate - a multi-column
yis forecast column-by-column, each as an independent series (capability:multivariate=True).Probabilistic - T0 returns quantiles natively, so
predict_quantiles,predict_intervaland (by default)predict_varare available (capability:pred_int=True);predictreturns the median (0.5 quantile).Exogenous - known-future covariates are conditioned on, but must cover every step
1..max(fh), so a non-contiguousfhrequires contiguousX(capability:non_contiguous_X=False).Missing values -
NaNentries in the context are treated as missing (capability:missing_values=True).In-sample - not supported;
fhmust be strictly in the future (capability:insample=False).
Quickstart
from sktime.forecasting.t0 import T0Forecaster
estimator = T0Forecaster(model_path: str | None='theforecastingcompany/t0-alpha', device: str | None=None, context_length: int | None=None, random_state=None, license_accepted: bool=False, ignore_deps: bool=False)Parameters(6)
- model_pathstr or None, default=”theforecastingcompany/t0-alpha”
Path to the T0 HuggingFace model checkpoint. The default checkpoint is a gated model on the HuggingFace Hub, so downloading it requires accepting the vendor’s terms on the model page and authenticating with a HuggingFace token. If
None, a small randomly-initialized T0 model is built locally (from thetfc-t0model code) instead of downloading any checkpoint - this produces untrained (meaningless) forecasts and is intended only for testing or offline use.- devicestr or None, default=None
- Device for inference, e.g., “cpu”, “cuda”, or “mps”. If None, uses “cuda” when a CUDA device is available, otherwise “cpu”.
- context_lengthint or None, default=None
- Maximum context length for inference. If None, the full context is used.
- random_stateint, RandomState instance or None, optional, default=None
Random seed for reproducibility, sklearn-compatible. If
None, no seeding is applied and the ambient random state is used. If set, inference runs in a forked RNG seeded fromrandom_state, leaving the global RNG untouched. T0’s inference is deterministic, so this does not change the forecast; it is accepted for interface consistency.- license_acceptedbool, optional, default=False
Whether the user has read and accepted the license terms of the
tfc-t0package and the T0 models, licensed by The Forecasting Company. Must be set toTrueto useT0Forecaster; otherwisefitraises. To view the license, callT0Forecaster.print_license(); the model card and gated-access terms are at https://huggingface.co/theforecastingcompany/t0-alpha.- ignore_depsbool, optional, default=False
- If True, dependency checks are skipped.
Examples
Univariate point forecast (zero-shot):
>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.t0 import T0Forecaster
>>> from sktime.split import temporal_train_test_split
>>> y = load_airline ()
>>> y_train, y_test = temporal_train_test_split (y, test_size = 12)
>>> forecaster = T0Forecaster (license_accepted = True)
>>> forecaster. fit (y_train)
>>> y_pred = forecaster. predict (fh = [1, 2, 3 ]) Probabilistic forecast (T0 returns quantiles natively):
>>> y_quantiles = forecaster. predict_quantiles (
... fh = [1, 2, 3 ], alpha = [0.1, 0.5, 0.9 ]
... )
>>> y_interval = forecaster. predict_interval (
... fh = [1, 2, 3 ], coverage = 0.9
... ) Forecast with known-future exogenous data (X in both fit and predict):
>>> from sktime.datasets import load_longley
>>> y, X = load_longley ()
>>> y_tr, y_te, X_tr, X_te = temporal_train_test_split (y, X, test_size = 3)
>>> forecaster = T0Forecaster (license_accepted = True)
>>> forecaster. fit (y_tr, X = X_tr)
>>> y_pred = forecaster. predict (fh = [1, 2, 3 ], X = X_te) Multivariate forecast on a real dataset (each column forecast independently):
>>> from sktime.datasets import load_longley
>>> _, y_multi = load_longley () # 5-column economic indicators frame
>>> y_multi_train = y_multi. iloc [: - 3 ]
>>> forecaster = T0Forecaster (license_accepted = True)
>>> forecaster. fit (y_multi_train)
>>> y_pred = forecaster. predict (fh = [1, 2, 3 ])