windowed_view#
- pyts.utils.windowed_view(X: ArrayLike, window_size: int, window_step: int = 1) NDArray[Any][source]#
Return a windowed view of a 2D array.
- Parameters:
- Xarray-like, shape = (n_samples, n_timestamps)
Input data.
- window_sizeint
The size of the window. It must be between 1 and
n_timestamps.- window_stepint (default = 1)
The step of the sliding window
- Returns:
- X_newarray, shape = (n_samples, n_windows, window_size)
Windowed view of the input data.
n_windowsis computed as(n_timestamps - window_size + window_step) // window_step.
Examples
>>> import numpy as np >>> from pyts.utils import windowed_view >>> windowed_view(np.arange(6).reshape(1, -1), window_size=2) array([[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]])