BoxCoxWrapper
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.
BoxCox — inherited documentation
Helper class that provides a standard way to create an ABC using inheritance.Box-Cox data transformer.
See [1]_ for more information about Box-Cox transforms.
The transformation is applied independently for each dimension (component) of the time series. For stochastic series, it is done jointly over all samples, 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 ---------- name A specific name for the transformer lmbda The parameter :math:`\lambda` of the Box-Cox transform. If a single float is given, the same :math:`\lambda` value will be used for all dimensions of the series, for all the series. If a sequence is given, there is one value per component in the series. If a sequence of sequence is given, there is one value per component for all series. If `None` given, will automatically find an optimal value of :math:`\lambda` (for each dimension of the time series, for each time series) using :func:`scipy.stats.boxcox_normmax` with ``method=optim_method``. optim_method Specifies which method to use to find an optimal value for the lmbda parameter. Either 'mle' or 'pearsonr'. Ignored if `lmbda` is not `None`. 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, 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 Whether to print operations progress
Examples -------- >>> from darts.datasets import AirPassengersDataset >>> from darts.dataprocessing.transformers import BoxCox >>> series = AirPassengersDataset().load() >>> transformer = BoxCox(lmbda=0.2) >>> series_transformed = transformer.fit_transform(series) >>> print(series_transformed.values()[:5]) [[7.84735157] [7.98214351] [8.2765364 ] [8.21563229] [8.04749318]]
References ---------- .. [1] https://otexts.com/fpp2/transformations.html#mathematical-transformations
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.
Required
Default: null
Required
Default: null
Optional
Default: null
Optional
Default: null
Required
Default: null
Optional
Default: "BoxCox"
Optional
Default: null
Optional
Default: 1
Optional
Default: false
Optional
Default: false
Optional
Default: "mle"
Optional
Default: null
Configuration example
Generated from documented defaults. Replace any placeholders and complete required nested settings before running.
templates:
- template_name: "BoxCoxWrapper"
class_name: "BoxCoxWrapper"
attributes:
method: "<required>"
apply_to: "<required>"
params_key: null
boxcox_init:
name: "BoxCox"
lmbda: null
n_jobs: 1
verbose: false
global_fit: false
optim_method: "mle"
transform_kwargs: null
View original docstring example
The source example references MissingValuesFillerWrapper, not BoxCoxWrapper.
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.htmlInheritance
sinapsis_darts_forecasting.templates.time_series_preprocessing.TimeSeriesPreprocessorEnvironment variables
Environment definitions belong to their canonical Python modules.