Back to models
Forecaster

MOIRAIForecaster

MOIRAI Forecasters.

Quickstart

python
from sktime.forecasting.moirai import MOIRAIForecaster

estimator = MOIRAIForecaster(checkpoint_path: str, context_length=200, patch_size=32, num_samples=100, num_feat_dynamic_real=None, num_past_feat_dynamic_real=None, map_location=None, target_dim=2, broadcasting=False, deterministic=False, batch_size=32, use_source_package=False)

Parameters(9)

checkpoint_pathstr, default=None

Path to the checkpoint of the model. Supported weights are available at [1].

context_lengthint, default=200
Length of the context window, time points the model will take as input for inference.
patch_sizeint, default=32
Time steps to perform patching with.
num_samplesint, default=100
Number of samples to draw.
map_locationstr, default=None
Hardware to use for the model.
target_dimint, default=2
Dimension of the target.
deterministicbool, default=False
Whether to use a deterministic model.
batch_sizeint, default=32
Number of samples in each batch of inference.
broadcastingbool, default=False

if True, multiindex data input will be broadcasted to single series. For each single series, one copy of this forecaster will try to fit and predict on it. The broadcasting is happening inside automatically, from the outerside api perspective, the input and output are the same, only one multiindex output from predict use_source_package: bool, default=False If True, the model and configuration will be loaded directly from the source package uni2ts.models.moirai. 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 and configuration will be loaded from the local version of package maintained in sktime. To install the source package, follow the instructions here [2].

Examples

>>> from sktime.forecasting.moirai import MOIRAIForecaster
>>> import pandas as pd
>>> import numpy as np
>>> morai_forecaster = MOIRAIForecaster (
... checkpoint_path = f "sktime/moirai-1.0-R-small"
... )
>>> y = np. random. normal (0, 1, (30, 2))
>>> X = y * 2 + np. random. normal (0, 1, (30, 1))
>>> index = pd. date_range ("2020-01-01", periods = 30, freq = "D")
>>> y = pd. DataFrame (y, index = index)
>>> X = pd. DataFrame (X, columns = ["x1", "x2" ], index = index)
>>> morai_forecaster. fit (y, X = X) MOIRAIForecaster(checkpoint_path='sktime/moirai-1.0-R-small')
>>> X_test = pd. DataFrame (
... np. random. normal (0, 1, (10, 2)),
... columns = ["x1", "x2" ],
... index = pd. date_range ("2020-01-31", periods = 10, freq = "D"),
... )
>>> forecast = morai_forecaster. predict (fh = range (1, 11), X = X_test)

References

  1. [1 ] https://huggingface.co/collections/sktime/moirai-variations-66ba3bc9f1dfeeafaed3b974 [2 ] https://pypi.org/project/uni2ts/1.1.0/