gemseo.mlearning.transformers.dimension_reduction.klsvd module#

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

The KLSVD class wraps the KarhunenLoeveSVDAlgorithm from OpenTURNS.

class 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.

inverse_transform(data, *args, **kwargs)#

Force a NumPy array to be at least 2D and evaluate the function f.

f expects a 2D array shaped as (n_points, input_dimension) and returns a nD arrays shaped as (..., n_points, output_dimension) or (..., n_points, output_dimension, input_dimension).

If the original data is a 1D array shaped as (input_dimension,), then this wrapper returns a (n-1)D array shaped as (..., output_dimension) or (..., output_dimension, intput_dimension).

Parameters:
  • data (ndarray) -- A 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 at least 2D and evaluate the function f.

f expects a 2D array shaped as (n_points, input_dimension) and returns a nD arrays shaped as (..., n_points, output_dimension) or (..., n_points, output_dimension, input_dimension).

If the original data is a 1D array shaped as (input_dimension,), then this wrapper returns a (n-1)D array shaped as (..., output_dimension) or (..., output_dimension, intput_dimension).

Parameters:
  • data (ndarray) -- A 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

property components: RealArray#

The principal components.

property eigenvalues: RealArray#

The eigen values.

property mesh: RealArray#

The mesh.

property output_dimension: int#

The dimension of the latent space.