nemos.basis._transformer_basis.TransformerBasis.fit#
- TransformerBasis.fit(X, y=None)[source]#
Check the input structure and, if necessary, compute the convolutional kernels.
- Parameters:
X (
TsdFrame
|ndarray
[tuple
[int
,...
],dtype
[TypeVar
(_ScalarType_co
, bound=generic
, covariant=True)]]) – The data to fit the basis functions to, shape (num_samples, num_input).y (ignored) – Not used, present for API consistency by convention.
- Returns:
The transformer object.
- Return type:
self
- Raises:
RuntimeError – If
self.n_basis_input
is None. Callself.set_input_shape
before callingfit
to avoid this.ValueError: – If the number of columns in X do not
self.n_basis_input_
.
Examples
>>> import numpy as np >>> from nemos.basis import MSplineEval, TransformerBasis
>>> # Example input >>> X = np.random.normal(size=(100, 2))
>>> # Define and fit tranformation basis >>> basis = MSplineEval(10).set_input_shape(2) >>> transformer = TransformerBasis(basis) >>> transformer_fitted = transformer.fit(X)