gen_poly_features#
- fastcan.narx.gen_poly_features(X, ids, skip_indices=None)#
Generator to make polynomial 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, degree)) – The unique id numbers of output features, which are formed of non-negative int values.
skip_indices (array-like, default=None) – Indices of features that have already been selected and can be skipped.
- Yields:
index (int) – The index of the yielded feature.
feature (ndarray of shape (n_samples,)) – A polynomial feature.
Examples
>>> import numpy as np >>> from fastcan.narx import gen_poly_features, make_poly_ids >>> ids = make_poly_ids(2, 2) >>> X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]]) >>> for i, feat in gen_poly_features(X, ids): ... print(i, feat) 0 [1. 3. 5. 7.] 1 [2. 4. 6. 8.] 2 [ 1. 9. 25. 49.] 3 [ 2. 12. 30. 56.] 4 [ 4. 16. 36. 64.]