gemseo.mlearning.transformers.base_transformer module#

A transformer to apply operations on NumPy arrays.

The abstract BaseTransformer class implements the concept of a data transformer. Inheriting classes shall implement the BaseTransformer.fit(), BaseTransformer.transform() and possibly BaseTransformer.inverse_transform() methods.

See also

scaler dimension_reduction

class BaseTransformer(name='', **parameters)[source]#

Bases: object

A data transformer fitted from some samples.

Parameters:
  • name (str) --

    A name for this transformer.

    By default it is set to "".

  • **parameters (ParameterType) -- The parameters of the transformer.

compute_jacobian(data)[source]#

Compute the Jacobian of transform().

Parameters:

data (RealArray) -- The data where the Jacobian is to be computed, shaped as (n_observations, n_features) or (n_features, ).

Returns:

The Jacobian matrix, shaped according to data.

Return type:

NoReturn

compute_jacobian_inverse(data)[source]#

Compute the Jacobian of the inverse_transform().

Parameters:

data (RealArray) -- The data where the Jacobian is to be computed, shaped as (n_observations, n_features) or (n_features, ).

Returns:

The Jacobian matrix, shaped according to data..

Return type:

NoReturn

duplicate()[source]#

Duplicate the current object.

Returns:

A deepcopy of the current instance.

Return type:

BaseTransformer

fit(data, *args)[source]#

Fit the transformer to the data.

Parameters:
  • data (ndarray) -- The data to be fitted, shaped as (n_observations, n_features) or (n_observations, ).

  • args (float | int | str)

Return type:

None

fit_transform(data, *args)[source]#

Fit the transformer to the data and transform the data.

Parameters:
  • data (ndarray) -- The data to be transformed, shaped as (n_observations, n_features) or (n_observations, ).

  • args (float | int | str)

Returns:

The transformed data, shaped as data.

Return type:

ndarray

inverse_transform(data)[source]#

Perform an inverse transform on the data.

Parameters:

data (ndarray) -- The data to be inverse transformed, shaped as (n_observations, n_features) or (n_features, ).

Returns:

The inverse transformed data, shaped as data.

Return type:

NoReturn

abstract transform(data)[source]#

Transform the data.

Parameters:

data (ndarray) -- The data to be transformed, shaped as (n_observations, n_features) or (n_features, ).

Returns:

The transformed data, shaped as data.

Return type:

ndarray

CROSSED: ClassVar[bool] = False#

Whether the fit() method requires two data arrays.

property is_fitted: bool#

Whether the transformer has been fitted from some data.

name: str#

The name of the transformer.

property parameters: dict[str, bool | int | float | ndarray | str | None]#

The parameters of the transformer.

class TransformerFactory[source]#

Bases: BaseFactory

A factory of transformers.

Return type:

Any