gemseo / mlearning / transformers / dimension_reduction

Hide inherited members

klsvd module

The Karhunen-Loève SVD algorithm to reduce the dimension of a variable.

The KLSVD class wraps the KarhunenLoeveSVDAlgorithm from OpenTURNS.

class gemseo.mlearning.transformers.dimension_reduction.klsvd.KLSVD(mesh, n_components=None, name='', use_random_svd=False, n_singular_values=None, use_halko2010=True)[source]

Bases: BaseDimensionReduction

The Karhunen-Loève SVD algorithm based on OpenTURNS.

Parameters:
  • mesh (RealArray) – A mesh passed as a 2D NumPy array whose rows are nodes and columns are the dimensions of the nodes.

  • n_components (int | None) – The number of components of the latent space. If None, use the maximum number allowed by the technique, typically min(n_samples, n_features).

  • name (str) –

    A name for this transformer.

    By default it is set to “”.

  • use_random_svd (bool) –

    Whether to use a stochastic algorithm to compute the SVD decomposition; if so, the number of singular values has to be fixed a priori.

    By default it is set to False.

  • n_singular_values (int | None) – The number of singular values to compute when use_random_svd is True; if None, use the default value implemented by OpenTURNS.

  • use_halko2010 (bool) –

    Whether to use the halko2010 algorithm or the halko2011 one.

    By default it is set to True.

compute_jacobian(data)

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)

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()

Duplicate the current object.

Returns:

A deepcopy of the current instance.

Return type:

BaseTransformer

fit(data, *args)

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)

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, *args, **kwargs)

Force a NumPy array to be 2D and evaluate the function f with it.

Parameters:
  • data (ndarray) – A 1D or 2D NumPy array.

  • *args (Any) – The positional arguments.

  • **kwargs (Any) – The optional arguments.

Returns:

Any kind of output; if a NumPy array, its dimension is made consistent with the shape of data.

Return type:

Any

transform(data, *args, **kwargs)

Force a NumPy array to be 2D and evaluate the function f with it.

Parameters:
  • data (ndarray) – A 1D or 2D NumPy array.

  • *args (Any) – The positional arguments.

  • **kwargs (Any) – The optional arguments.

Returns:

Any kind of output; if a NumPy array, its dimension is made consistent with the shape of data.

Return type:

Any

CROSSED: ClassVar[bool] = False

Whether the fit() method requires two data arrays.

property components: RealArray

The principal components.

property eigenvalues: RealArray

The eigen values.

property is_fitted: bool

Whether the transformer has been fitted from some data.

property mesh: RealArray

The mesh.

property n_components: int

The number of components.

name: str

The name of the transformer.

property output_dimension: int

The dimension of the latent space.

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

The parameters of the transformer.

Examples using KLSVD

KL-SVD on Burgers equation

KL-SVD on Burgers equation