Docs /Templates/ sinapsis-darts-forecasting

StaticCovariatesTransformerWrapper

sinapsis-darts-forecastingDartsdatadartsdynamicforecasting

Python template · sinapsis_darts_forecasting.templates.time_series_preprocessing

Overview

A dynamic preprocessing template for applying Darts transformations to time series data.

This template allows users to apply various transformations from `darts.dataprocessing.transformers` to different parts of the time series packet (`content`, `past_covariates`, `future_covariates`).

If a transformer requires fitting (e.g., `Scaler`), it stores and retrieves transformation parameters.

StaticCovariatesTransformer — inherited documentation

Helper class that provides a standard way to create an ABC using inheritance.Generic wrapper class for scalers/encoders/transformers of static covariates. This transformer acts only on static covariates of the series passed to ``fit()``, ``transform()``, ``fit_transform()``, and ``inverse_transform()``. It can both scale numerical features, as well as encode categorical features.

The underlying ``transformer_num`` and ``transformer_cat`` have to implement the ``fit()``, ``transform()``, and ``inverse_transform()`` methods (typically from scikit-learn).

By default, numerical and categorical columns/features are inferred and allocated to ``transformer_num`` and ``transformer_cat``, respectively. Alternatively, specify which columns to scale/transform with ``cols_num`` and ``cols_cat``.

Both ``transformer_num`` and ``transformer_cat`` are fit globally on static covariate data from all series passed to :class:`StaticCovariatesTransformer.fit()`

Parameters ---------- transformer_num The transformer to transform numeric static covariate columns with. It must provide ``fit()``, ``transform()`` and ``inverse_transform()`` methods. Default: :class:`sklearn.preprocessing.MinMaxScaler(feature_range=(0, 1))`; this will scale all values between 0 and 1. transformer_cat The encoder to transform categorical static covariate columns with. It must provide ``fit()``, ``transform()`` and ``inverse_transform()`` methods. Default: :class:`sklearn.preprocessing.OrdinalEncoder()`; this will convert categories into integer valued arrays where each integer stands for a specific category. cols_num Optionally, a list of column names for which to apply the numeric transformer ``transformer_num``. By default, the transformer will infer all numerical features based on types, and scale them with `transformer_num`. If an empty list, no column will be scaled. cols_cat Optionally, a list of column names for which to apply the categorical transformer `transformer_cat`. By default, the transformer will infer all categorical features based on types, and transform them with `transformer_cat`. If an empty list, no column will be transformed. name A specific name for the :class:`StaticCovariatesTransformer`. n_jobs The number of jobs to run in parallel. Parallel jobs are created only when a ``Sequence[TimeSeries]`` is passed as input to a method, parallelising operations regarding different ``TimeSeries``. Defaults to `1` (sequential). Setting the parameter to `-1` means using all the available processors. Note: for a small amount of data, the parallelisation overhead could end up increasing the total required amount of time. verbose Optionally, whether to print operations progress

Examples -------- >>> import numpy as np >>> import pandas as pd >>> from darts import TimeSeries >>> from darts.dataprocessing.transformers import StaticCovariatesTransformer >>> static_covs = pd.DataFrame(data={"num": [0, 2, 1], "cat": ["a", "c", "b"]}) >>> series = TimeSeries.from_values( >>> values=np.random.random((10, 3)), >>> columns=["comp1", "comp2", "comp3"], >>> static_covariates=static_covs, >>> ) >>> transformer = StaticCovariatesTransformer() >>> series_transformed = transformer.fit_transform(series) >>> print(series.static_covariates) static_covariates num cat component comp1 0.0 a comp2 2.0 c comp3 1.0 b >>> print(series_transformed.static_covariates) static_covariates num cat component comp1 0.0 0.0 comp2 1.0 2.0 comp3 0.5 1.0

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-darts-forecasting==1.0.0
uv pip install sinapsis-darts-forecasting==1.0.0
uv add sinapsis-darts-forecasting==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

methodRequired
typing.Literal['fit', 'transform', 'fit_transform', 'inverse_transform']
Required
Default: null
apply_toRequired
list[typing.Literal['content', 'past_covariates', 'future_covariates', 'predictions']]
Required
Default: null
metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
params_key
str | None
Optional
Default: null
transform_kwargs
dict[str, typing.Any]
Optional
Default: null
staticcovariatestransformer_initRequired
__init__Attributes
Required
Default: null
name
str
Optional
Default: "StaticCovariatesTransformer"
n_jobs
int
Optional
Default: 1
verbose
bool
Optional
Default: false
cols_cat
typing.Optional[list[str]]
Optional
Default: null
cols_num
typing.Optional[list[str]]
Optional
Default: null
transformer_cat
NoneType
Optional
Default: null
transformer_num
NoneType
Optional
Default: null

Configuration example

Generated from documented defaults. Replace any placeholders and complete required nested settings before running.

yaml
templates:
  - template_name: "StaticCovariatesTransformerWrapper"
    class_name: "StaticCovariatesTransformerWrapper"
    attributes:
      method: "<required>"
      apply_to: "<required>"
      params_key: null
      transform_kwargs: null
      staticcovariatestransformer_init:
        name: "StaticCovariatesTransformer"
        n_jobs: 1
        verbose: false
        cols_cat: null
        cols_num: null
        transformer_cat: null
        transformer_num: null
View original docstring example

The source example references MissingValuesFillerWrapper, not StaticCovariatesTransformerWrapper.

yaml
agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: MissingValuesFillerWrapper
  class_name: MissingValuesFillerWrapper
  template_input: InputTemplate
  attributes:
    method: "transform"
    apply_to: ["content"]
    transform_kwargs:
        method: "linear"
    missingvaluesfiller_init:
        fill: "auto"
        name: "MissingValuesFiller"
        n_jobs: 1
        verbose: False
For a full list of options use the sinapsis cli: sinapsis info --all-template-names
If you want to see all available transformers, please visit: https://unit8co.github.io/darts/generated_api/darts.dataprocessing.transformers.html

Inheritance

Immediate parent: sinapsis_darts_forecasting.templates.time_series_preprocessing.TimeSeriesPreprocessor

Environment variables

Environment definitions belong to their canonical Python modules.

SINAPSIS_BUILD_DOCS · defined elsewhere