gen_time_shift_features#

fastcan.narx.gen_time_shift_features(X, ids, skip_indices=None, **kwargs)#

Generator to make time shift features.

Added in version 0.5.1.

Parameters:
  • X (array-like of shape (n_samples, n_features)) – The data to transform, column by column.

  • ids (array-like of shape (n_outputs, 2)) – The unique id numbers of output features, which are (feature_idx, delay).

  • skip_indices (array-like, default=None) – Indices of features that have already been selected and can be skipped.

  • **kwargs (dict) – Additional keyword arguments to be passed to numpy.pad().

Yields:
  • index (int) – The index of the yielded feature.

  • feature (ndarray of shape (n_samples,)) – A time shift feature.

Examples

>>> import numpy as np
>>> from fastcan.narx import gen_time_shift_features, make_time_shift_ids
>>> ids = make_time_shift_ids(2, 1)
>>> X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])
>>> for i, feat in gen_time_shift_features(X, ids, mode="edge"):
...     print(i, feat)
0 [1. 1. 3. 5.]
1 [2. 2. 4. 6.]