pysad.models.SeasonalESD
- class pysad.models.SeasonalESD(period, window_size, max_anomalies, alpha=0.05, robust=True, **stl_kwargs)[source]
Window-based Seasonal ESD model [BHVK17].
This is the paper’s S-ESD method: compute the modified STL residual
X - seasonal - median(X)over a fixed-size PySAD window, then apply generalized ESD with mean and standard deviation to the residuals.- Parameters:
period (int) – Number of observations in one seasonal period.
window_size (int) – Number of recent observations used for STL and ESD.
max_anomalies (int) – Maximum number of anomalies tested by ESD.
alpha (float) – ESD significance level. (Default=0.05).
robust (bool) – Whether to use robust STL fitting. (Default=True).
**stl_kwargs – Additional keyword arguments passed to STL.
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 instaces via score_partial iteratively.
Scores whether the next instance is anomalous in a candidate window.
- fit(X, y=None)
Fits the model to all instances in order.
- 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,)
- score(X)
Scores all instaces 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,)