gemseo.mlearning.transformers.scaler.scaler module#

Scaling a variable with a linear transformation.

The Scaler class implements the default scaling method applying to some parameter \(z\):

\[\bar{z} := \text{offset} + \text{coefficient}\times z\]

where \(\bar{z}\) is the scaled version of \(z\). This scaling method is a linear transformation parameterized by an offset and a coefficient.

In this default scaling method, the offset is equal to 0 and the coefficient is equal to 1. Consequently, the scaling operation is the identity: \(\bar{z}=z\). This method has to be overloaded.

class Scaler(name='', offset=0.0, coefficient=1.0)[source]#

Bases: BaseTransformer

Data scaler.

Parameters:
  • name (str) --

    A name for this transformer.

    By default it is set to "".

  • offset (float | RealArray) --

    The offset of the linear transformation.

    By default it is set to 0.0.

  • coefficient (float | RealArray) --

    The coefficient of the linear transformation.

    By default it is set to 1.0.

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

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

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 coefficient: RealArray#

The scaling coefficient.

property offset: RealArray#

The scaling offset.