ARIMAWrapper
Python template · sinapsis_darts_forecasting.templates.time_series_model
Overview
Base Template for Darts Time Series forecasting models.
ARIMA — inherited documentation
The base class for transferable future covariates "local" forecasting models, handling single uni- or multivariate target and optional future covariates time series. Additionally, at prediction time, it can be applied to new data unrelated to the original series used for fitting the model.
Transferable Future Covariates Local Forecasting Models (TFC-LFM) are models that can be trained on a single uni- or multivariate target and optional future covariates series. Additionally, at prediction time, it can be applied to new data unrelated to the original series used for fitting the model. Currently in Darts, all models in this category wrap to statsmodel models such as VARIMA. TFC-LFMs usually train on the entire target and future covariates series supplied when calling :func:`fit()` at once. They can also predict in one go with :func:`predict()` for any number of predictions `n` after the end of the training series. When using future covariates, the values for the future `n` prediction steps must be given in the covariate series.
All implementations must implement the :func:`_fit()` and :func:`_predict()` methods.ARIMA ARIMA-type models extensible with exogenous variables (future covariates) and seasonal components.
Parameters ---------- p : int | Sequence[int] Order (number of time lags) of the autoregressive model (AR). If a sequence of integers, specifies the exact lags to include. d : int The order of differentiation; i.e., the number of times the data have had past values subtracted (I). q : int | Sequence[int] The size of the moving average window (MA). If a sequence of integers, specifies the exact lags to include in the window. seasonal_order: Tuple[int | Sequence[int], int, int | Sequence[int], int] The (P,D,Q,s) order of the seasonal component for the AR parameters (P), differences (D), MA parameters (Q) and periodicity (s). D and s are always integers, while P and Q may either be integers or sequence of positive integers specifying exactly which lag orders are included. trend: Literal['n', 'c', 't', 'ct'] | list[int], optional Parameter controlling the deterministic trend. Either a string or list of integers. If a string, can be 'n' for no trend, 'c' for a constant term, 't' for a linear trend in time, and 'ct' for a constant term and linear trend. If a list of integers, defines a polynomial according to `numpy.poly1d` [1]_. E.g., `[1,1,0,1]` would translate to :math:`a + bt + ct^3`. Trend term of lower order than `d + D` cannot be as they would be eliminated due to the differencing operation. Default is 'c' for models without integration, and 'n' for models with integration. add_encoders A large number of future covariates can be automatically generated with `add_encoders`. This can be done by adding multiple pre-defined index encoders and/or custom user-made functions that will be used as index encoders. Additionally, a transformer such as Darts' :class:`Scaler` can be added to transform the generated covariates. This happens all under one hood and only needs to be specified at model creation. Read :meth:`SequentialEncoder <darts.dataprocessing.encoders.SequentialEncoder>` to find out more about ``add_encoders``. Default: ``None``. An example showing some of ``add_encoders`` features:
.. highlight:: python .. code-block:: python
def encode_year(idx): return (idx.year - 1950) / 50
add_encoders={ 'cyclic': {'future': ['month']}, 'datetime_attribute': {'future': ['hour', 'dayofweek']}, 'position': {'future': ['relative']}, 'custom': {'future': [encode_year]}, 'transformer': Scaler(), 'tz': 'CET' } .. random_state: int or None Controls the randomness for reproducible forecasting.
Examples -------- >>> from darts.datasets import AirPassengersDataset >>> from darts.models import ARIMA >>> from darts.utils.timeseries_generation import datetime_attribute_timeseries >>> series = AirPassengersDataset().load() >>> # optionally, use some future covariates; e.g. the value of the month encoded as a sine and cosine series >>> future_cov = datetime_attribute_timeseries(series, "month", cyclic=True, add_length=6) >>> # define ARIMA parameters >>> model = ARIMA(p=12, d=1, q=2) >>> model.fit(series, future_covariates=future_cov) >>> pred = model.predict(6, future_covariates=future_cov) >>> print(pred.values()) [[451.36482652] [416.8895219 ] [443.10517554] [481.07884246] [502.11278494] [555.5014505 ]]
References ---------- .. [1] https://numpy.org/doc/stable/reference/generated/numpy.poly1d.html
Capabilities
Capabilities: not setInstallation
Install the published package using pip or uv.
pip install sinapsis-darts-forecasting==1.0.0uv pip install sinapsis-darts-forecasting==1.0.0uv add sinapsis-darts-forecasting==1.0.0Configuration
Effective fields from the inspector schema, including nested Pydantic model fields.
Optional
Default: null
Required
Default: null
Optional
Default: 1
Optional
Default: 12
Optional
Default: 0
Optional
Default: null
Optional
Default: null
Optional
Default: null
Optional
Default: [0,0,0,0]
Optional
Default: false
Optional
Default: 10
Configuration example
Generated from documented defaults. Replace any placeholders and complete required nested settings before running.
templates:
- template_name: "ARIMAWrapper"
class_name: "ARIMAWrapper"
attributes:
arima_init:
d: 1
p: 12
q: 0
trend: null
add_encoders: null
random_state: null
seasonal_order: [0, 0, 0, 0]
validation_mode: false
forecast_horizon: 10
View original docstring example
The source example references XGBModelWrapper, not ARIMAWrapper.
agent:
name: my_test_agent
templates:
- template_name: InputTemplate
class_name: InputTemplate
attributes: {}
- template_name: XGBModelWrapper
class_name: XGBModelWrapper
template_input: InputTemplate
attributes:
forecast_horizon: 100
xgbmodel_init:
lags: 30
lags_past_covariates: 30
output_chunk_length: 100
random_state: 42
n_estimators: 200
learning_rate: 0.1
max_depth: 6
For a full list of options use the sinapsis cli: sinapsis info --all-template-names.
If you want to see all available models, please visit:
https://unit8co.github.io/darts/generated_api/darts.models.forecasting.htmlInheritance
sinapsis_darts_forecasting.templates.time_series_model.TimeSeriesModelEnvironment variables
Environment definitions belong to their canonical Python modules.