TimeSeriesOD: Windowed bridge that wraps any PyOD detector for
time series anomaly detection.
Creates sliding windows from a time series, runs any PyOD detector on
the resulting window matrix, and maps anomaly scores back to individual
timestamps.
detectorstr or BaseDetector, optional (default=’IForest’)
Any PyOD detector. String resolves to a default-configured
instance via the shortcut registry. If a BaseDetector instance
is passed, it will be cloned.
window_sizeint, optional (default=50)
Size of the sliding window.
stepint, optional (default=1)
Step size between consecutive windows.
score_aggregationstr, optional (default=’max’)
How to aggregate window-level scores to timestamp-level scores.
One of ‘max’ or ‘mean’.
contaminationfloat, optional (default=0.1)
Expected proportion of outliers in the dataset.
Must be in (0, 0.5].
Validates the input, creates sliding windows, fits the inner
detector on the window matrix, and maps scores back to
timestamps using the masked-score workflow.
Configure whether metadata should be requested to be passed to the predict_proba method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict_proba if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict_proba.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
Configure whether metadata should be requested to be passed to the predict method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
MatrixProfile: Time series anomaly detection using the STOMP algorithm.
Computes the Matrix Profile via the STOMP (Scalable Time-series Ordered
Matrix Profile) algorithm, which identifies anomalous subsequences by
measuring z-normalized Euclidean distance to the nearest non-trivial
match.
Yeh, C.C.M., Zhu, Y., Ulanova, L., Begum, N., Ding, Y., Dau, H.A.,
Silva, D.F., Mueen, A. and Keogh, E., 2016. Matrix profile I:
All pairs similarity joins for time series: a unifying view that
includes motifs, discords and shapelets. In ICDM, pp. 1317-1322.
Matrix Profile time series anomaly detector using STOMP.
Computes the Matrix Profile via the STOMP algorithm, identifying
anomalous subsequences by measuring z-normalized Euclidean distance
to the nearest non-trivial neighbor. Subsequences with high
Matrix Profile values (discords) are anomalous.
This is a transductive detector: it only scores the training
data. decision_function, predict, predict_proba, and
predict_confidence raise NotImplementedError when called
with new data.
Yeh, C.C.M., Zhu, Y., Ulanova, L., Begum, N., Ding, Y., Dau, H.A.,
Silva, D.F., Mueen, A. and Keogh, E., 2016. Matrix profile I:
All pairs similarity joins for time series. In ICDM, pp. 1317-1322.
Configure whether metadata should be requested to be passed to the predict_proba method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict_proba if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict_proba.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
Configure whether metadata should be requested to be passed to the predict method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
Spectral Residual anomaly detector for time series.
Computes a saliency map via the spectral residual of the
log-amplitude spectrum. This is a dense method that produces
one anomaly score per timestamp with no gaps.
Configure whether metadata should be requested to be passed to the predict_proba method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict_proba if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict_proba.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
Configure whether metadata should be requested to be passed to the predict method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
KShape: k-Shape clustering-based time series anomaly detection.
Adapts the k-Shape clustering algorithm (Paparrizos & Gravano, SIGMOD 2015)
for anomaly detection. Sliding-window subsequences are clustered using
shape-based distance (SBD), and each subsequence is scored by its SBD to
the nearest centroid. Subsequences far from all centroids are anomalous.
Reference:
Paparrizos, J. and Gravano, L., 2015. k-Shape: Efficient and accurate
clustering of time series. In Proceedings of the 2015 ACM SIGMOD
International Conference on Management of Data (pp. 1855-1870).
k-Shape clustering-based time series anomaly detector.
Extracts sliding-window subsequences, clusters them using the
k-Shape algorithm (shape-based distance + eigenvalue centroid
update), and scores each subsequence by its SBD to the nearest
centroid. Subsequences far from all centroids are considered
anomalous.
This is an inductive detector: after fitting on training data,
decision_function can score new time series.
Configure whether metadata should be requested to be passed to the predict_proba method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict_proba if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict_proba.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
Configure whether metadata should be requested to be passed to the predict method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
SAND: Streaming Anomaly detection with Normalization and Drift adaptation.
Simplified PyOD adaptation of:
Boniol, P., Paparrizos, J., Palpanas, T. and Franklin, M.J., 2021.
SAND: Streaming subsequence anomaly detection.
Proceedings of the VLDB Endowment, 14(10), pp. 1717-1729.
This implementation extracts z-normalized sliding-window subsequences,
initializes k centroids using k-Shape on the first batch, then scores
remaining subsequences by SBD (shape-based distance) to their nearest
centroid. Centroids are updated every batch_size subsequences via
exponential moving average with parameter alpha.
Extracts z-normalized sliding-window subsequences, initializes
k centroids via k-Shape on the first batch, and scores each
subsequence by its SBD to the nearest centroid. Centroids are
updated every batch_size subsequences using an exponential
moving average, enabling drift adaptation.
Configure whether metadata should be requested to be passed to the predict_proba method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict_proba if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict_proba.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
Configure whether metadata should be requested to be passed to the predict method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
LSTMAD: LSTM-based time series anomaly detection using prediction
error with Mahalanobis distance scoring.
Simplified PyOD adaptation of Malhotra et al., ESANN 2015.
Single-step prediction (horizon=1). Error vector per timestamp has
n_channels dimensions. Anomaly score = Mahalanobis distance of
prediction errors from a fitted multivariate Gaussian.
Trains a stacked LSTM to predict the next timestep, then scores
each timestamp by the Mahalanobis distance of its prediction error
from a multivariate Gaussian fitted on training errors.
Configure whether metadata should be requested to be passed to the predict_proba method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict_proba if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict_proba.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
Configure whether metadata should be requested to be passed to the predict method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
AnomalyTransformer: Transformer-based time series anomaly detector
with association discrepancy.
Implements the Anomaly Transformer (Xu et al., ICLR 2022) which uses
anomaly-attention with series-association and prior-association to detect
anomalies in time series via a minimax optimization strategy.
Reference:
Xu, J., Wu, H., Wang, J., & Long, M. (2022).
Anomaly Transformer: Time Series Anomaly Detection with Association
Discrepancy. In International Conference on Learning Representations.
Anomaly Transformer for time series anomaly detection.
Implements the Anomaly Transformer (Xu et al., ICLR 2022), a
Transformer-based architecture with anomaly-attention that computes
series-association and prior-association to detect anomalies via
association discrepancy and minimax training.
Configure whether metadata should be requested to be passed to the predict_proba method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict_proba if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict_proba.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.
Configure whether metadata should be requested to be passed to the predict method.
Note that this method is only relevant when this estimator is used as a
sub-estimator within a meta-estimator and metadata routing is enabled
with enable_metadata_routing=True (see sklearn.set_config()).
Please check the User Guide on how the routing
mechanism works.
The options for each parameter are:
True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.
False: metadata is not requested and the meta-estimator will not pass it to predict.
None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.
str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (sklearn.utils.metadata_routing.UNCHANGED) retains the
existing request. This allows you to change the request for some
parameters and not others.