pysindy.feature_library.base.BaseFeatureLibrary

class pysindy.feature_library.base.BaseFeatureLibrary[source]

Base class for feature libraries.

Forces subclasses to implement fit, transform, and get_feature_names methods.

Methods

calc_trajectory

correct_shape

Correct the shape of x, given what we know of the problem

fit

Compute number of output features.

get_feature_names

Return feature names for output features.

get_spatial_grid

reshape_samples_to_spatial_grid

Adapt predictions to fitted spatial grid.

set_fit_request

Configure whether metadata should be requested to be passed to the fit method.

set_transform_request

Configure whether metadata should be requested to be passed to the transform method.

transform

Transform data.

validate_input

Attributes

size

n_features_in_

n_output_features_

correct_shape(x: AxesArray)[source]

Correct the shape of x, given what we know of the problem

abstractmethod fit(x, y=None)[source]

Compute number of output features.

Parameters:

x (array-like, shape (n_samples, n_features)) – The data.

Returns:

self

Return type:

instance

abstractmethod get_feature_names(input_features=None) list[str][source]

Return feature names for output features.

Parameters:

input_features (list of string, length n_features, optional) – String names for input features if available. By default, “x0”, “x1”, … “xn_features” is used.

Returns:

output_feature_names

Return type:

list of string, length n_output_features

reshape_samples_to_spatial_grid(x: ndarray) AxesArray[source]

Adapt predictions to fitted spatial grid.

set_fit_request(*, x: bool | None | str = '$UNCHANGED$') BaseFeatureLibrary

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

x (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for x parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_transform_request(*, x: bool | None | str = '$UNCHANGED$') BaseFeatureLibrary

Configure whether metadata should be requested to be passed to the transform method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to transform if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to transform.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

x (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for x parameter in transform.

Returns:

self – The updated object.

Return type:

object

abstractmethod transform(x)[source]

Transform data.

Parameters:

x (array-like, shape [n_samples, n_features]) – The data to transform, row by row.

Returns:

xp – The matrix of features, where n_output_features is the number of features generated from the combination of inputs.

Return type:

np.ndarray, [n_samples, n_output_features]