nemos.basis.CyclicBSplineConv.compute_features#

CyclicBSplineConv.compute_features(xi)[source]#

Convolve basis functions with input time series.

A bank of basis filters is convolved with the input data. All the dimensions except for the sample-axis are flattened, so that the method always returns a matrix.

For example, if inputs are of shape (num_samples, 2, 3), the output will be (num_samples, num_basis_funcs * 2 * 3).

Parameters:

*xi (ArrayLike) – The input data over which to apply the basis transformation. The samples can be passed as multiple arguments, each representing a different dimension for multivariate inputs.

Return type:

TsdFrame | ndarray[Any, dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]

Notes

This method is intended to be 1-to-1 mappable to sklearn transform method of transformer. This means that for the method to be callable, all the state attributes have to be pre-computed in a method that is mappable to fit, which for us is _fit_basis. It is fundamental that both methods behaves like the corresponding transformer method, with the only difference being the input structure: a single (X, y) pair for the transformer, a number of time series for the Basis.

Examples

>>> import numpy as np
>>> from nemos.basis import CyclicBSplineConv
>>> # Generate data
>>> num_samples = 1000
>>> X = np.random.normal(size=(num_samples, ))  # raw time series
>>> basis = CyclicBSplineConv(10, window_size=11)
>>> features = basis.compute_features(X)  # basis transformed time series
>>> features.shape
(1000, 10)