module coreforecast.scalers

Global Variables

  • TYPE_CHECKING

function boxcox_lambda

boxcox_lambda(
    x: ndarray,
    method: str,
    season_length: Optional[int] = None,
    lower: float = -0.9,
    upper: float = 2.0
)float

Find optimum lambda for the Box-Cox transformation

Args:

  • x (np.ndarray): Array with data to transform.
  • method (str): Method to use. Valid options are ‘guerrero’ and ‘loglik’. ‘guerrero’ minimizes the coefficient of variation for subseries of x and supports negative values. ‘loglik’ maximizes the log-likelihood function.
  • season_length (int, optional): Length of the seasonal period. Only required if method=‘guerrero’.
  • lower (float): Lower bound for the lambda.
  • upper (float): Upper bound for the lambda.

Returns:

  • float: Optimum lambda.

function boxcox

boxcox(x: ndarray, lmbda: float) → ndarray

Apply the Box-Cox transformation

Args:

  • x (np.ndarray): Array with data to transform.
  • lmbda (float): Lambda value to use.

Returns:

  • np.ndarray: Array with the transformed data.

function inv_boxcox

inv_boxcox(x: ndarray, lmbda: float) → ndarray

Invert the Box-Cox transformation

Args:

  • x (np.ndarray): Array with data to transform.
  • lmbda (float): Lambda value to use.

Returns:

  • np.ndarray: Array with the inverted transformation.

class LocalMinMaxScaler

Scale each group to the [0, 1] interval


method fit

fit(ga: 'GroupedArrayT') → _BaseLocalScaler

Compute the statistics for each group.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • self: The fitted scaler object.

method fit_transform

fit_transform(ga: 'GroupedArrayT') → ndarray

“Compute the statistics for each group and apply the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

method inverse_transform

inverse_transform(ga: 'GroupedArrayT') → ndarray

Use the computed statistics to invert the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the inverted transformation.

method stack

stack(scalers: Sequence[ForwardRef('_BaseLocalScaler')]) → _BaseLocalScaler

method take

take(idxs: ndarray) → _BaseLocalScaler

method transform

transform(ga: 'GroupedArrayT') → ndarray

Use the computed statistics to apply the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

class LocalStandardScaler

Scale each group to have zero mean and unit variance


method fit

fit(ga: 'GroupedArrayT') → _BaseLocalScaler

Compute the statistics for each group.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • self: The fitted scaler object.

method fit_transform

fit_transform(ga: 'GroupedArrayT') → ndarray

“Compute the statistics for each group and apply the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

method inverse_transform

inverse_transform(ga: 'GroupedArrayT') → ndarray

Use the computed statistics to invert the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the inverted transformation.

method stack

stack(scalers: Sequence[ForwardRef('_BaseLocalScaler')]) → _BaseLocalScaler

method take

take(idxs: ndarray) → _BaseLocalScaler

method transform

transform(ga: 'GroupedArrayT') → ndarray

Use the computed statistics to apply the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

class LocalRobustScaler

Scale each group using robust statistics

Args:

  • scale (str): Type of robust scaling to use. Valid options are ‘iqr’ and ‘mad’. If ‘iqr’ will use the inter quartile range as the scale. If ‘mad’ will use median absolute deviation as the scale.

method __init__

__init__(scale: str)

method fit

fit(ga: 'GroupedArrayT') → _BaseLocalScaler

Compute the statistics for each group.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • self: The fitted scaler object.

method fit_transform

fit_transform(ga: 'GroupedArrayT') → ndarray

“Compute the statistics for each group and apply the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

method inverse_transform

inverse_transform(ga: 'GroupedArrayT') → ndarray

Use the computed statistics to invert the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the inverted transformation.

method stack

stack(scalers: Sequence[ForwardRef('_BaseLocalScaler')]) → _BaseLocalScaler

method take

take(idxs: ndarray) → _BaseLocalScaler

method transform

transform(ga: 'GroupedArrayT') → ndarray

Use the computed statistics to apply the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

class LocalBoxCoxScaler

Find the optimum lambda for the Box-Cox transformation by group and apply it

Args:

  • season_length (int, optional): Length of the seasonal period. Only required if method=‘guerrero’.
  • lower (float): Lower bound for the lambda.
  • upper (float): Upper bound for the lambda.
  • method (str): Method to use. Valid options are ‘guerrero’ and ‘loglik’. ‘guerrero’ minimizes the coefficient of variation for subseries of x and supports negative values. ‘loglik’ maximizes the log-likelihood function.

method __init__

__init__(
    method: str,
    season_length: Optional[int] = None,
    lower: float = -0.9,
    upper: float = 2.0
)

method fit

fit(ga: 'GroupedArrayT') → _BaseLocalScaler

Compute the statistics for each group.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • self: The fitted scaler object.

method fit_transform

fit_transform(ga: 'GroupedArrayT') → ndarray

“Compute the statistics for each group and apply the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

method inverse_transform

inverse_transform(ga: 'GroupedArrayT') → ndarray

Use the computed lambdas to invert the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the inverted transformation.

method stack

stack(scalers: Sequence[ForwardRef('_BaseLocalScaler')]) → _BaseLocalScaler

method take

take(idxs: ndarray) → _BaseLocalScaler

method transform

transform(ga: 'GroupedArrayT') → ndarray

Use the computed lambdas to apply the transformation.

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

class Difference

Subtract a lag to each group

Args:

  • d (int): Lag to subtract.

method __init__

__init__(d: int)

method fit_transform

fit_transform(ga: 'GroupedArrayT') → ndarray

Apply the transformation

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

method inverse_transform

inverse_transform(ga: 'GroupedArrayT') → ndarray

Invert the transformation

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the inverted transformation.

method stack

stack(scalers: Sequence[ForwardRef('Difference')]) → Difference

method take

take(idxs: ndarray) → Difference

method update

update(ga: 'GroupedArrayT') → ndarray

Update the last observations from each serie

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the updated data.

class AutoDifferences

Find and apply the optimal number of differences to each group.

Args:

  • max_diffs (int): Maximum number of differences to apply.

method __init__

__init__(max_diffs: int)

method fit_transform

fit_transform(ga: 'GroupedArrayT') → ndarray

Compute and apply the optimal number of differences for each group

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

method inverse_transform

inverse_transform(ga: 'GroupedArrayT') → ndarray

Invert the differences

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the inverted transformation.

method stack

stack(scalers: Sequence[ForwardRef('AutoDifferences')]) → AutoDifferences

method take

take(idxs: ndarray) → AutoDifferences

method update

update(ga: 'GroupedArrayT') → ndarray

Update the last observations from each serie

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the updated data.

class AutoSeasonalDifferences

Find and apply the optimal number of seasonal differences to each group.

Args:

  • season_length (int): Length of the seasonal period.
  • max_diffs (int): Maximum number of differences to apply.
  • n_seasons (int | None): Number of seasons to use to determine the number of differences. Defaults to 10. If None will use all samples, otherwise season_length * n_seasons samples will be used for the test. Smaller values will be faster but could be less accurate.

method __init__

__init__(season_length: int, max_diffs: int, n_seasons: Optional[int] = 10)

method fit_transform

fit_transform(ga: 'GroupedArrayT') → ndarray

Compute and apply the optimal number of seasonal differences for each group

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

method inverse_transform

inverse_transform(ga: 'GroupedArrayT') → ndarray

Invert the seasonal differences

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the inverted transformation.

method stack

stack(scalers: Sequence[ForwardRef('AutoDifferences')]) → AutoDifferences

method take

take(idxs: ndarray) → AutoDifferences

method update

update(ga: 'GroupedArrayT') → ndarray

Update the last observations from each serie

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the updated data.

class AutoSeasonalityAndDifferences

Find the length of the seasonal period and apply the optimal number of differences to each group.

Args:

  • max_season_length (int): Maximum length of the seasonal period.
  • max_diffs (int): Maximum number of differences to apply.
  • n_seasons (int | None): Number of seasons to use to determine the number of differences. Defaults to 10. If None will use all samples, otherwise max_season_length * n_seasons samples will be used for the test. Smaller values will be faster but could be less accurate.

method __init__

__init__(max_season_length: int, max_diffs: int, n_seasons: Optional[int] = 10)

method fit_transform

fit_transform(ga: 'GroupedArrayT') → ndarray

Compute the optimal length of the seasonal period and apply the optimal number of differences for each group

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the transformed data.

method inverse_transform

inverse_transform(ga: 'GroupedArrayT') → ndarray

Invert the seasonal differences

Args:

  • ga (GroupedArray): Array with grouped data.

Returns:

  • np.ndarray: Array with the inverted transformation.

method stack

stack(
    scalers: Sequence[ForwardRef('AutoSeasonalityAndDifferences')]
) → AutoSeasonalityAndDifferences

method take

take(idxs: ndarray) → AutoSeasonalityAndDifferences

method update

update(ga: 'GroupedArrayT') → ndarray

This file was automatically generated via lazydocs.