FourThetaWrapper
Python template · sinapsis_darts_forecasting.templates.time_series_model
Overview
Base Template for Darts Time Series forecasting models.
FourTheta — inherited documentation
The base class for "local" forecasting models, handling only single univariate time series.
Local Forecasting Models (LFM) are models that can be trained on a single univariate target series only. In Darts, most models in this category tend to be simpler statistical models (such as ETS or FFT). LFMs usually train on the entire target 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.
All implementations must implement the `fit()` and `predict()` methods. An implementation of the 4Theta method with configurable `theta` parameter.
See M4 competition `solution <https://github.com/Mcompetitions/M4-methods/blob/master/4Theta%20method.R>`__.
The training time series is de-seasonalized according to `seasonality_period`, or an inferred seasonality period.
`season_mode` must be a ``SeasonalityMode`` Enum member. `model_mode` must be a ``ModelMode`` Enum member. `trend_mode` must be a ``TrendMode`` Enum member.
You can access the different Enums with ``from darts import SeasonalityMode, TrendMode, ModelMode``.
When called with `theta = X`, `model_mode = Model.ADDITIVE` and `trend_mode = Trend.LINEAR`, this model is equivalent to calling `Theta(theta=X)`.
Parameters ---------- theta Value of the theta parameter. Defaults to 2. If theta = 1, then the fourtheta method restricts to a simple exponential smoothing (SES). If theta = 0, then the fourtheta method restricts to a simple `trend_mode` regression. seasonality_period User-defined seasonality period. If not set, will be tentatively inferred from the training series upon calling `fit()`. model_mode Type of model combining the Theta lines. Either ModelMode.ADDITIVE or ModelMode.MULTIPLICATIVE. Defaults to `ModelMode.ADDITIVE`. season_mode Type of seasonality. Either SeasonalityMode.MULTIPLICATIVE, SeasonalityMode.ADDITIVE or SeasonalityMode.NONE. Defaults to `SeasonalityMode.MULTIPLICATIVE`. trend_mode Type of trend to fit. Either TrendMode.LINEAR or TrendMode.EXPONENTIAL. Defaults to `TrendMode.LINEAR`. normalization If `True`, the data is normalized so that the mean is 1. Defaults to `True`.
Notes ----- Even though this model is an improvement of :class:`Theta`, it is a naive implementation of the algorithm, which can potentially be slower.
Examples -------- >>> from darts.datasets import AirPassengersDataset >>> from darts.models import FourTheta >>> series = AirPassengersDataset().load() >>> model = FourTheta(theta=2) >>> model.fit(series) >>> pred = model.predict(6) >>> print(pred.values()) [[443.3949283 ] [434.39769555] [495.28886231] [481.08962991] [481.78610361] [546.61463773]]
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: 2
Optional
Default: "additive"
Optional
Default: "linear"
Optional
Default: "multiplicative"
Optional
Default: true
Optional
Default: null
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: "FourThetaWrapper"
class_name: "FourThetaWrapper"
attributes:
fourtheta_init:
theta: 2
model_mode: {}
trend_mode: {}
season_mode: {}
normalization: true
seasonality_period: null
validation_mode: false
forecast_horizon: 10
View original docstring example
The source example references XGBModelWrapper, not FourThetaWrapper.
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.