pmdarima.preprocessing.LogEndogTransformer

class pmdarima.preprocessing.LogEndogTransformer(lmbda=0, neg_action='raise', floor=1e-16)[source][source]

Apply a log transformation to an endogenous array

When y is your endogenous array, the log transform is log(y + lmbda)

Parameters:

lmbda : float, optional (default=0.)

The value to add to y to make it non-negative. If, after adding lmbda, there are still negative values, a ValueError will be raised.

neg_action : str, optional (default=”raise”)

How to respond if any values in y <= 0 after adding lmbda. One of (‘raise’, ‘warn’, ‘ignore’). If anything other than ‘raise’, values <= 0 will be truncated to the value of floor.

floor : float, optional (default=1e-16)

A positive value that truncate values to if there are values in y that are zero or negative and neg_action is not ‘raise’. Note that if values are truncated, invertibility will not be preserved, and the transformed array may not be perfectly inverse-transformed.

Methods

fit(y[, X]) Fit the transformer
fit_transform(y[, X]) Fit and transform the arrays
get_params([deep]) Get parameters for this estimator.
inverse_transform(y[, X]) Inverse transform a transformed array
set_params(**params) Set the parameters of this estimator.
transform(y[, X]) Apply the log transform to the array
__init__(lmbda=0, neg_action='raise', floor=1e-16)[source][source]

Initialize self. See help(type(self)) for accurate signature.

fit(y, X=None, **kwargs)[source][source]

Fit the transformer

Must be called before transform.

Parameters:

y : array-like or None, shape=(n_samples,)

The endogenous (time-series) array.

X : array-like or None, shape=(n_samples, n_features), optional

The exogenous array of additional covariates. Not used for endogenous transformers. Default is None, and non-None values will serve as pass-through arrays.

fit_transform(y, X=None, **kwargs)[source]

Fit and transform the arrays

Parameters:

y : array-like or None, shape=(n_samples,)

The endogenous (time-series) array.

X : array-like or None, shape=(n_samples, n_features), optional

The exogenous array of additional covariates.

**kwargs : keyword args

Keyword arguments required by the transform function.

get_params(deep=True)[source]

Get parameters for this estimator.

Parameters:

deep : bool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params : mapping of string to any

Parameter names mapped to their values.

inverse_transform(y, X=None, **kwargs)[source][source]

Inverse transform a transformed array

Inverse the log transformation on the transformed array. Note that if truncation happened in the transform method, invertibility will not be preserved, and the transformed array may not be perfectly inverse-transformed.

Parameters:

y : array-like or None, shape=(n_samples,)

The transformed endogenous (time-series) array.

X : array-like or None, shape=(n_samples, n_features), optional

The exogenous array of additional covariates. Not used for endogenous transformers. Default is None, and non-None values will serve as pass-through arrays.

Returns:

y : array-like or None

The inverse-transformed y array

X : array-like or None

The inverse-transformed exogenous array

set_params(**params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:

**params : dict

Estimator parameters.

Returns:

self : object

Estimator instance.

transform(y, X=None, **transform_kwargs)[source][source]

Apply the log transform to the array

Parameters:

y : array-like or None, shape=(n_samples,)

The endogenous (time-series) array.

X : array-like or None, shape=(n_samples, n_features), optional

The exogenous array of additional covariates. Not used for endogenous transformers. Default is None, and non-None values will serve as pass-through arrays.

Returns:

y_transform : array-like or None

The log transformed y array

X : array-like or None

The exog array