compute_window_size
- dtaianomaly.windowing.compute_window_size(X: ndarray, window_size: int | str, lower_bound: int = 10, relative_lower_bound: float = 0.0, upper_bound: int = 1000, relative_upper_bound: float = 1.0, threshold: float = 0.89, default_window_size: int = None) int[source]
Compute the window size of the given time series [11].
Given a time series, automatically compute the window size. This can be done either automatically, using a number of procedures for estimating the window size, or based on a user-defined value.
- Parameters:
- Xarray-like of shape (n_samples, n_attributes)
Input time series.
- window_sizeint or str
The method by which a window size should be computed. Valid options are:
int: Simply return the given window size.'fft': Compute the window size by selecting the dominant Fourier frequency.'acf': Compute the window size as the leg with the highest autocorrelation.'mwf': Computes the window size using the Multi-Window-Finder method [18].'suss': Computes the window size using the Summary Statistics Subsequence method [10].
- lower_boundint, default=10
The lower bound on the automatically computed window size. Only used if
window_sizeequals'fft','acf','mwf'or'suss'.- relative_lower_boundfloat, default=0.0
The lower bound on the automatically computed window size, relative to the length of the given time series. Only used if
window_sizeequals'fft','acf','mwf'or'suss'.- upper_boundint, default=1000
The lower bound on the automatically computed window size. Only used if
window_sizeequals'fft','acf', or'mwf'.- relative_upper_boundfloat, default=1.0
The upper bound on the automatically computed window size, relative to the length of the given time series. Only used if
window_sizeequals'fft','acf', or'mwf'.- thresholdfloat, default=0.89
The threshold for selecting the optimal window size using
'suss'.- default_window_sizeint, default=None
The default window size, in case an invalid automatic window size was computed. By default, the value is set to None, which means that an error is thrown.
- Returns:
- int
The computed window size.
Warning
Automatically computing the windwow size only works for univariate time series!
See also
dominant_fourier_frequencyCompute the window size based on the fft.
highest_autocorrelationCompute the window size based on the acf.
multi_window_finderCompute the window size with mwf.
summary_statistics_subsequencesCompute the window size with suss.
Examples
>>> from dtaianomaly.data import demonstration_time_series >>> from dtaianomaly.windowing import compute_window_size >>> X, _ = demonstration_time_series() >>> compute_window_size(X, 64) 64 >>> compute_window_size(X, 'fft') 107 >>> compute_window_size(X, 'acf') 112 >>> compute_window_size(X, 'mwf') 112 >>> compute_window_size(X, 'suss') 62