nemos.basis._basis.MultiplicativeBasis.compute_features#
- MultiplicativeBasis.compute_features(*xi)[source]#
Apply the basis transformation to the input data.
This method is designed to be a high-level interface for transforming input data using the basis functions defined by the subclass. Depending on the basis’ mode (‘Eval’ or ‘Conv’), it either evaluates the basis functions at the sample points or performs a convolution operation between the input data and the basis functions.
- Parameters:
*xi (ArrayLike | Tsd | TsdFrame | TsdTensor) – Input data arrays to be transformed. The shape and content requirements depend on the subclass and mode of operation (‘Eval’ or ‘Conv’).
- Return type:
FeatureMatrix
- Returns:
Transformed features. In ‘Eval’ mode, it corresponds to the basis functions evaluated at the input samples. In ‘Conv’ mode, it consists of convolved input samples with the basis functions. The output shape varies based on the subclass and mode.
Notes
Subclasses should implement how to handle the transformation specific to their basis function types and operation modes.
Examples
>>> import numpy as np >>> from nemos.basis import BSplineEval, RaisedCosineLogConv >>> from nemos.glm import GLM >>> basis1 = BSplineEval(n_basis_funcs=5, label="one_input") >>> basis2 = RaisedCosineLogConv(n_basis_funcs=6, window_size=10, label="two_inputs") >>> basis_mul = basis1 * basis2 >>> X_multi = basis_mul.compute_features(np.random.randn(20), np.random.randn(20, 2)) >>> print(X_multi.shape) # num_features: 60 = 5 * 2 * 6 (20, 60)