gemseo / mlearning / transformers

Show inherited members

transformer module

A transformer to apply operations on NumPy arrays.

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

class gemseo.mlearning.transformers.transformer.Transformer(name='Transformer', **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 “Transformer”.

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

compute_jacobian(data)[source]

Compute the Jacobian of transform().

Parameters:

data (ndarray) – 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 (ndarray) – 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:

Transformer

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, Union[bool, int, float, numpy.ndarray, str, NoneType]]

The parameters of the transformer.

class gemseo.mlearning.transformers.transformer.TransformerFactory[source]

Bases: BaseFactory

A factory of Transformer.

Return type:

BaseFactory

failed_imports: dict[str, str]

The class names bound to the import errors.

Examples using Transformer

KL-SVD on Burgers equation

KL-SVD on Burgers equation

PCA on Burgers equation

PCA on Burgers equation

Quality measure for surrogate model comparison

Quality measure for surrogate model comparison

Scaler example

Scaler example

Transformer pipeline example

Transformer pipeline example