Class Signature
ChronosModel class implements Amazon’s Chronos, a language model-based approach to probabilistic time series forecasting that uses tokenization to convert time series into discrete tokens.
Initialization Parameters
Model configuration dictionary. Used when initializing a new model without pre-trained weights.
Hugging Face model repository ID. If provided, loads the pre-trained Chronos model. If not provided, initializes a new model using the config.
Methods
finetune()
Dataset for finetuning. Call
get_data_loader() to get the dataloader.Optional keyword arguments (currently uses default hyperparameters: lr=1e-4, epochs=5).
The model is finetuned in-place.
evaluate()
Dataset for evaluation. Use
get_data_loader() to obtain the dataloader.Forecast horizon length.
Quantile levels used to compute quantile forecasts and scoring metrics (e.g., [0.1, 0.5, 0.9]).
If True, return only a dict of metrics. If False, return metrics plus arrays.
When
metric_only=True:Dictionary containing:mse: Mean Squared Errormae: Mean Absolute Errormase: Mean Absolute Scaled Errormape: Mean Absolute Percentage Errorrmse: Root Mean Squared Errornrmse: Normalized RMSEsmape: Symmetric Mean Absolute Percentage Errormsis: Mean Scaled Interval Scorend: Normalized Deviationmwsq: Mean Weighted Scaled Quantile Losscrps: Continuous Ranked Probability Score
metric_only=False:Tuple of (metrics, trues, preds, histories, quantile_forecasts):metrics: Dictionary of metrics (as above)trues: Ground truth values, shape (num_samples, horizon_len, num_ts)preds: Mean predictions, shape (num_samples, horizon_len, num_ts)histories: Input context sequences, shape (num_samples, context_len, num_ts)quantile_forecasts: Quantile forecasts, shape (num_quantiles, num_samples, horizon_len, num_ts)
plot()
Dataset for plotting. Use
get_data_loader() to obtain the dataloader.Forecast horizon length.
List of quantile levels to request from the model (e.g., [0.1, 0.5, 0.9]).
Additional keyword arguments forwarded to the visualization helper.
This method does not return a value. It displays visualizations.
Usage Example
Notes
- Chronos uses a T5-based architecture to treat forecasting as a sequence-to-sequence problem
- The model tokenizes time series values into discrete bins before processing
- Quantile predictions are generated through the model’s probabilistic outputs
- Three model sizes are available: small, base, and large
- The model supports variable-length context and prediction horizons