pysad.transform.preprocessing.SeasonalTrendDecomposer

class pysad.transform.preprocessing.SeasonalTrendDecomposer(season_length, trend_window=None)[source]

Streaming seasonal and trend decomposition preprocessor.

The transformer subtracts a rolling mean trend estimate and a running average seasonal estimate for each position in the season. This is an online approximation intended for preprocessing before univariate anomaly scoring; it is not an STL implementation and does not reproduce the modified STL residual used by Seasonal ESD in [BHVK17].

Parameters:
  • season_length (int) – Number of observations in one seasonal period.

  • trend_window (int) – Number of recent observations used to estimate the trend. If None, defaults to season_length.

Methods

__init__(season_length[, trend_window])

fit(X)

Shortcut method that iteratively applies fit_partial to all instances in order.

fit_partial(X)

Fits the next timestep's values to train the decomposer.

fit_transform(X)

Shortcut method that iteratively applies fit_transform_partial to all instances in order.

fit_transform_partial(X)

Fits and transforms the next timestep.

transform(X)

Shortcut method that iteratively applies transform_partial to all instances in order.

transform_partial(X)

Transforms the next timestep by removing trend and seasonality.

fit(X)

Shortcut method that iteratively applies fit_partial to all instances in order.

Parameters:

X (np.float64 array of shape (num_instances, num_features)) – Input feature vectors.

Returns:

The fitted transformer

Return type:

object

fit_partial(X)[source]

Fits the next timestep’s values to train the decomposer.

Parameters:

X (np.float64 array of shape (num_features,)) – Input feature vector.

Returns:

self.

Return type:

object

fit_transform(X)

Shortcut method that iteratively applies fit_transform_partial to all instances in order.

Parameters:

X (np.float64 array of shape (num_instances, num_components)) – Input feature vectors.

Returns:

Projected feature vectors.

Return type:

np.float64 array of shape (num_instances, num_components)

fit_transform_partial(X)[source]

Fits and transforms the next timestep.

Parameters:

X (np.float64 array of shape (num_features,)) – Input feature vector.

Returns:

Residual feature vector.

Return type:

residual_X (np.float64 array of shape (num_features,))

transform(X)

Shortcut method that iteratively applies transform_partial to all instances in order.

Parameters:

X (np.float64 array of shape (num_instances, num_features)) – Input feature vectors.

Returns:

Projected feature vectors.

Return type:

np.float64 array of shape (num_instances, num_components)

transform_partial(X)[source]

Transforms the next timestep by removing trend and seasonality.

Parameters:

X (np.float64 array of shape (num_features,)) – Input feature vector.

Returns:

Residual feature vector.

Return type:

residual_X (np.float64 array of shape (num_features,))