pmdarima.preprocessing.BoxCoxEndogTransformer

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

Apply the Box-Cox transformation to an endogenous array

The Box-Cox transformation is applied to non-normal data to coerce it more towards a normal distribution. It’s specified as:

(((y + lam2) ** lam1) - 1) / lam1, if lmbda != 0, else
log(y + lam2)
Parameters:

lmbda : float or None, optional (default=None)

The lambda value for the Box-Cox transformation, if known. If not specified, it will be estimated via MLE.

lmbda2 : float, optional (default=0.)

The value to add to y to make it non-negative. If, after adding lmbda2, 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 lmbda2. 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[, exogenous]) Fit the transformer
fit_transform(y[, exogenous]) Fit and transform the arrays
get_params([deep]) Get parameters for this estimator.
inverse_transform(y[, exogenous]) Inverse transform a transformed array
set_params(**params) Set the parameters of this estimator.
transform(y[, exogenous]) Transform the new array
__init__(lmbda=None, lmbda2=0, neg_action='raise', floor=1e-16)[source][source]

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

fit(y, exogenous=None)[source][source]

Fit the transformer

Learns the value of lmbda, if not specified in the constructor. If defined in the constructor, is not re-learned.

Parameters:

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

The endogenous (time-series) array.

exogenous : 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, exogenous=None, **transform_kwargs)[source]

Fit and transform the arrays

Parameters:

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

The endogenous (time-series) array.

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

The exogenous array of additional covariates.

**transform_kwargs : keyword args

Keyword arguments required by the transform function.

get_params(deep=True)[source]

Get parameters for this estimator.

Parameters:

deep : boolean, optional

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, exogenous=None)[source][source]

Inverse transform a transformed array

Inverse the Box-Cox 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.

exogenous : 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

exogenous : 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.

Returns:self
transform(y, exogenous=None, **_)[source][source]

Transform the new array

Apply the Box-Cox transformation to the array after learning the lambda parameter.

Parameters:

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

The endogenous (time-series) array.

exogenous : 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 Box-Cox transformed y array

exogenous : array-like or None

The exog array