Class Signature
Chronos_2_Model class implements Chronos 2.0, the next generation of Amazon’s Chronos with enhanced capabilities for handling longer sequences and improved forecasting performance.
Initialization Parameters
Model configuration dictionary using Chronos2CoreConfig parameters. Used when initializing a new model without pre-trained weights.
Hugging Face model repository ID. If provided, loads the pre-trained Chronos 2.0 model. If not provided, initializes a new model using the config.
Properties
Maximum number of output patches the model can generate, derived from
model.chronos_config.max_output_patches.Size of each output patch, derived from
model.chronos_config.output_patch_size.Methods
finetune()
Dataset for finetuning. Call
get_data_loader() to get the dataloader.Number of training epochs. Can be passed in kwargs.
Optional keyword arguments (default lr=1e-4, default epochs=5).
The model is finetuned in-place.
evaluate()
Dataset for evaluation. Use
get_data_loader() to obtain the dataloader.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):metrics: Dictionary of metrics (as above)trues: Ground truth values, shape (batch_size, n_channels, horizon_len)preds: Mean predictions, shape (batch_size, n_channels, horizon_len)histories: Input context sequences, shape (batch_size, n_channels, context_len)
Usage Example
Notes
- Chronos 2.0 uses a patch-based architecture for better long sequence handling
- The model automatically calculates the number of output patches based on the forecast horizon and patch size
- Improved over original Chronos with better scalability and performance
- Supports both fine-tuning and zero-shot forecasting
- The horizon length for fine-tuning must be smaller than
max_patches * patch_size