gen_time_shift_features#

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

Generator to make time shift features.

Added in version 0.6.0.

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.

  • batch_size (int, default=16) –

    Number of time shift features to generate in each batch.

    Added in version 0.6.1.

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

Yields:
  • index (ndarray of shape (batch_size,)) – The indices of the yielded features.

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

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, batch_size=2):
...     print(i, feat)
[0 1] [[0. 0.]
 [1. 2.]
 [3. 4.]
 [5. 6.]]