pytorch_forecasting.data.encoders.
TorchNormalizer
Bases: sklearn.base.BaseEstimator, sklearn.base.TransformerMixin
sklearn.base.BaseEstimator
sklearn.base.TransformerMixin
Basic target transformer that can be fit also on torch tensors.
Initialize
method (str, optional) – method to rescale series. Either “identity”, “standard” (standard scaling) or “robust” (scale using quantiles 0.25-0.75). Defaults to “standard”.
center (bool, optional) – If to center the output to zero. Defaults to True.
transformation (Union[str, Tuple[Callable, Callable]] optional) –
Transform values before applying normalizer. Available options are
None (default): No transformation of values
log: Estimate in log-space leading to a multiplicative model
(e.g. if many small values <<1 are present). Note, that inverse transform is still only torch.exp() and not torch.expm1().
logit: Apply logit transformation on values that are between 0 and 1
softplus: Apply softplus to output (inverse transformation) and x + 1 to input (transformation)
relu: Apply max(0, x) to output
Tuple[Callable, Callable] of PyTorch functions that transforms and inversely transforms values.
eps (float, optional) – Number for numerical stability of calculations. Defaults to 1e-8.
Methods
fit(y)
fit
Fit transformer, i.e. determine center and scale of data.
fit_transform(X[, y])
fit_transform
Fit to data, then transform it.
get_parameters(*args, **kwargs)
get_parameters
Returns parameters that were used for encoding.
get_params([deep])
get_params
Get parameters for this estimator.
inverse_preprocess(y)
inverse_preprocess
Inverse preprocess re-scaled data (e.g.
inverse_transform(y)
inverse_transform
Inverse scale.
preprocess(y)
preprocess
Preprocess input data (e.g.
set_params(**params)
set_params
Set the parameters of this estimator.
transform(y[, return_norm, target_scale])
transform
Rescale data.
Attributes
TRANSFORMATIONS
Fit transformer, i.e. determine center and scale of data
y (Union[pd.Series, np.ndarray, torch.Tensor]) – input data
self
First element is center of data and second is scale
torch.Tensor
Inverse preprocess re-scaled data (e.g. take exp).
Uses transform attribute to determine how to apply inverse transform.
return rescaled series with type depending on input type
Union[np.ndarray, torch.Tensor]
y (torch.Tensor) – scaled data
de-scaled data
Preprocess input data (e.g. take log).
Uses transform attribute to determine how to apply transform.
return_norm (bool, optional) – [description]. Defaults to False.
target_scale (torch.Tensor) – target scale to use instead of fitted center and scale
data with type depending on input type. returns second element if return_norm=True
return_norm=True
Union[Tuple[Union[np.ndarray, torch.Tensor], np.ndarray], Union[np.ndarray, torch.Tensor]]