MultiNormalizer#

class pytorch_forecasting.data.encoders.MultiNormalizer(normalizers: List[TorchNormalizer])[source]#

Bases: TorchNormalizer

Normalizer for multiple targets.

This normalizers wraps multiple other normalizers.

Parameters:

normalizers (List[TorchNormalizer]) – list of normalizers to apply to targets

Inherited-members:

Methods

extra_repr()

fit(y[, X])

Fit transformer, i.e. determine center and scale of data.

fit_transform(X[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_parameters(*args, **kwargs)

Returns parameters that were used for encoding.

get_params([deep])

Get parameters for this estimator.

get_transform(transformation)

Return transformation functions.

inverse_preprocess(y)

Inverse preprocess re-scaled data (e.g.

inverse_transform(y)

Inverse scale.

preprocess(y)

Preprocess input data (e.g.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

set_transform_request(*[, return_norm, ...])

Request metadata passed to the transform method.

transform(y[, X, return_norm, target_scale])

Scale input data.

Attributes

TRANSFORMATIONS

fit(y: DataFrame | ndarray | Tensor, X: DataFrame | None = None)[source]#

Fit transformer, i.e. determine center and scale of data

Parameters:

y (Union[pd.Series, np.ndarray, torch.Tensor]) – input data

Returns:

self

Return type:

MultiNormalizer

get_parameters(*args, **kwargs) List[Tensor][source]#

Returns parameters that were used for encoding.

Returns:

First element is center of data and second is scale

Return type:

List[torch.Tensor]

set_transform_request(*, return_norm: bool | None | str = '$UNCHANGED$', target_scale: bool | None | str = '$UNCHANGED$') MultiNormalizer#

Request metadata passed to the transform method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to transform if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to transform.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters:
  • return_norm (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for return_norm parameter in transform.

  • target_scale (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for target_scale parameter in transform.

Returns:

self – The updated object.

Return type:

object

transform(y: DataFrame | ndarray | Tensor, X: DataFrame = None, return_norm: bool = False, target_scale: List[Tensor] = None) List[Tuple[ndarray | Tensor, ndarray]] | List[ndarray | Tensor][source]#

Scale input data.

Parameters:
  • y (Union[pd.DataFrame, np.ndarray, torch.Tensor]) – data to scale

  • X (pd.DataFrame) – dataframe with groups columns. Only necessary if GroupNormalizer is among normalizers

  • return_norm (bool, optional) – If to return . Defaults to False.

  • target_scale (List[torch.Tensor]) – target scale to use instead of fitted center and scale

Returns:

List of scaled data, if return_norm=True, returns also scales as second element

Return type:

Union[List[Tuple[Union[np.ndarray, torch.Tensor], np.ndarray]], List[Union[np.ndarray, torch.Tensor]]]