Docs /Templates/ sinapsis-darts-forecasting

ScalerWrapper

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.

Scaler — inherited documentation

Helper class that provides a standard way to create an ABC using inheritance.Generic wrapper class for using scalers on time series.

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

When the scaler is applied on multivariate series, the scaling is done per-component. When the series are stochastic, the scaling is done across all samples (for each given component). The transformation is applied independently for each dimension (component) of the time series, effectively merging all samples of a component in order to compute the transform.

Notes ----- The scaler will not scale the series' static covariates. This has to be done either before constructing the series, or later on by extracting the covariates, transforming the values and then reapplying them to the series. For this, see TimeSeries properties `TimeSeries.static_covariates` and method `TimeSeries.with_static_covariates()`

Parameters ---------- scaler The scaler to transform the data with. It must provide ``fit()``, ``transform()`` and ``inverse_transform()`` methods. Default: :class:`sklearn.preprocessing.MinMaxScaler(feature_range=(0, 1))`; this will scale all the values of a time series between 0 and 1. name A specific name for the scaler global_fit Optionally, whether all `TimeSeries` passed to the `fit()` method should be used to fit a *single* set of parameters, or if a different set of parameters should be independently fitted to each provided `TimeSeries`. If `True`, then a `Sequence[TimeSeries]` is passed to `ts_fit` and a single set of parameters is fitted using all provided `TimeSeries`. If `False`, then each `TimeSeries` is individually passed to `ts_fit`, and a different set of fitted parameters if yielded for each of these fitting operations. See `FittableDataTransformer` documentation for further details. 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

Notes ----- In case the :class:`Scaler` is applied to multiple ``TimeSeries`` objects, a deep-copy of the chosen scaler will be instantiated, fitted, and stored, for each ``TimeSeries``.

Examples -------- >>> from sklearn.preprocessing import MinMaxScaler >>> from darts import TimeSeries >>> from darts.dataprocessing.transformers import Scaler >>> series = TimeSeries.from_values([-2, 0, 2]) >>> scaler = MinMaxScaler(feature_range=(-1, 1)) >>> transformer = Scaler(scaler) >>> series_transformed = transformer.fit_transform(series) >>> print(series_transformed.values()) [[-1.] [ 0.] [ 1.]]

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
scaler_initRequired
__init__Attributes
Required
Default: null
name
str
Optional
Default: "Scaler"
n_jobs
int
Optional
Default: 1
scaler
NoneType
Optional
Default: null
verbose
bool
Optional
Default: false
global_fit
bool
Optional
Default: false
transform_kwargs
dict[str, typing.Any]
Optional
Default: null

Configuration example

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

yaml
templates:
  - template_name: "ScalerWrapper"
    class_name: "ScalerWrapper"
    attributes:
      method: "<required>"
      apply_to: "<required>"
      params_key: null
      scaler_init:
        name: "Scaler"
        n_jobs: 1
        scaler: null
        verbose: false
        global_fit: false
      transform_kwargs: null
View original docstring example

The source example references MissingValuesFillerWrapper, not ScalerWrapper.

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