pysad.models.SeasonalHybridESD

class pysad.models.SeasonalHybridESD(period, window_size, max_anomalies, alpha=0.05, robust=True, **stl_kwargs)[source]

Window-based Seasonal Hybrid ESD model [BHVK17].

This is the paper’s S-H-ESD method: use the same modified STL residual as SeasonalESD, then replace ESD’s mean and standard deviation with median and MAD-based scale in the test statistic.

Methods

__init__(period, window_size, max_anomalies)

fit(X[, y])

Fits the model to all instances in order.

fit_partial(X[, y])

Adds the next instance to the model window.

fit_score(X[, y])

This helper method applies fit_score_partial to all instances in order.

fit_score_partial(X[, y])

Adds and scores the next instance without adding it twice.

score(X)

Scores all instances via score_partial iteratively.

score_partial(X)

Scores whether the next instance is anomalous in a candidate window.

fit(X, y=None)

Fits the model to all instances in order.

Parameters:
  • X (np.float64 array of shape (num_instances, num_features)) – The instances in order to fit.

  • y (int) – The labels of the instances in order to fit (Optional for unsupervised models, default=None).

Returns:

Fitted model.

Return type:

object

fit_partial(X, y=None)

Adds the next instance to the model window.

fit_score(X, y=None)

This helper method applies fit_score_partial to all instances in order.

Parameters:
  • X (np.float64 array of shape (num_instances, num_features)) – The instances in order to fit.

  • y (np.int32 array of shape (num_instances, )) – The labels of the instances in order to fit (Optional for unsupervised models, default=None).

Returns:

The anomalousness scores of the instances in order.

Return type:

np.float64 array of shape (num_instances,)

fit_score_partial(X, y=None)

Adds and scores the next instance without adding it twice.

score(X)

Scores all instances via score_partial iteratively.

Parameters:

X (np.float64 array of shape (num_instances, num_features)) – The instances in order to score.

Returns:

The anomalousness scores of the instances in order.

Return type:

np.float64 array of shape (num_instances,)

score_partial(X)

Scores whether the next instance is anomalous in a candidate window.