Esc
Ask AIAnswers may be inaccurate; check the linked pages.Esc
Ask anything about these docs, like how to get started or what a function does.

Multivariate

chronax.gluonts_predictor.Multivariate

A dataclass used for configuring multivariate batching parameters.

__init__(self, batch_size=16)

Parameter Type Default Description
batch_size int 16 (undocumented)

TotoSampleForecastGenerator

chronax.gluonts_predictor.TotoSampleForecastGenerator · inherits SampleForecastGenerator

Wrapper class for generating GluonTS forecasts from Toto models.

This class differs from the behavior of standard GluonTS generators in one major way:

Most GluonTS models are encoder-style models with a fixed prediction length, whereas Toto is a decoder-only model that can generate forecasts of arbitrary length using autoregressive sampling. This wrapper handles the iterative sampling process to generate forecasts of the required length, which can be set to any value when the generator is called.

In addition, this class can also provide both point predictions (when num_samples is None) or samples from the predictive distribution (when num_samples is not None). Note that when num_samples is not None, the memory usage is significantly higher, so the batch_size and num_variates should be set accordingly.

__call__(self, inference_data_loader, prediction_net, prediction_length, num_samples, input_names, output_transform, mode=Multivariate(batch_size=4), samples_per_batch=10, use_kv_cache=False) -> Iterator[SampleForecast]

Parameter Type Default Description
inference_data_loader DataLoader - (undocumented)
prediction_net Toto - (undocumented)
prediction_length int - (undocumented)
num_samples Optional[int] - (undocumented)
input_names List[str] - (undocumented)
output_transform Optional[OutputTransform] - (undocumented)
mode Multivariate Multivariate(batch_size=4) (undocumented)
samples_per_batch int 10 (undocumented)
use_kv_cache bool False (undocumented)

TotoSampleForecast

chronax.gluonts_predictor.TotoSampleForecast · inherits SampleForecast

Wrapper around GluonTS's SampleForecast class that adds a deterministic mean forecast to the samples. By default, SampleForecast calculates the mean forecast by taking the mean of the samples, but since Toto predicts parametrically, we can calculate the mean forecast more efficiently by directly computing the mean from the model's output. This is useful for evaluation metrics that require a point prediction.

__init__(self, samples, mean, start_date, item_id=None, info=None)

Parameter Type Default Description
samples np.ndarray - (undocumented)
mean np.ndarray - (undocumented)
start_date pd.Period - (undocumented)
item_id Optional[str] None (undocumented)
info Optional[dict] None (undocumented)

TotoPredictor

chronax.gluonts_predictor.TotoPredictor · inherits PyTorchPredictor

Predictor class for Toto models in GluonTS. This class is a thin wrapper that adapts Toto to the GluonTS interface for evaluation and forecasting. Most of the actual work is done by the TotoSampleForecastGenerator class.

__init__(self, input_names, prediction_net, prediction_length, input_transform, forecast_generator, output_transform=None, lead_time=0, device='auto', mode=Multivariate(batch_size=16), samples_per_batch=10)

Parameter Type Default Description
input_names List[str] - (undocumented)
prediction_net torch.nn.Module - (undocumented)
prediction_length int - (undocumented)
input_transform Transformation - (undocumented)
forecast_generator TotoSampleForecastGenerator - (undocumented)
output_transform Optional[OutputTransform] None (undocumented)
lead_time int 0 (undocumented)
device str \| torch.device "auto" (undocumented)
mode Multivariate Multivariate(batch_size=16) (undocumented)
samples_per_batch int 10 (undocumented)

create_for_eval(cls, model, prediction_length, context_length, mode=Multivariate(batch_size=1), samples_per_batch=10) -> "TotoPredictor"

Parameter Type Default Description
model Toto - (undocumented)
prediction_length int - (undocumented)
context_length int - (undocumented)
mode Multivariate Multivariate(batch_size=1) (undocumented)
samples_per_batch int 10 (undocumented)

custom_stack_fn(self, data, device=None) -> Dict[str, Union[torch.Tensor, List[Any]]]

Custom stack function for the InferenceDataLoader. Attempts to use GluonTS's batchify for stacking. Falls back to manual logic with consistent padding.

Parameter Type Default Description
data List[Dict[str, Any]] - (undocumented)
device torch.types.Device None Ensure we have a device to use

predict(self, dataset, num_samples=None, use_kv_cache=False, eval=True) -> Iterator[Forecast]

Parameter Type Default Description
dataset Dataset - (undocumented)
num_samples Optional[int] None (undocumented)
use_kv_cache bool False (undocumented)
eval bool True (undocumented)